Starting with creating our data file data.txt:
12
54
7
332
54
1
0
We have changed just one line so that it now has * 10
rather than + 17
:
lines <- readLines(file("data.txt"))
for (line in lines){
number <- as.numeric(line)
new_number <- number * 10
print(new_number)
}
Rscript file.R
[1] 120
[1] 540
[1] 70
[1] 3320
[1] 540
[1] 10
[1] 0