Reputation: 2533
myf<- function(col,row){
x=5*col+row
write.table(x,"res_row_col.txt")}
myf(5,6)
I expected the file to be:
res_5_6.txt
But the file was written as:
res_row_col.txt
Upvotes: 0
Views: 53
Reputation: 927
Use the paste0 function:
myf<- function(col,row){
x=5*col+row
write.table(x,paste0("res_", row, "_", col, ".txt"))}
myf(5,6)
Upvotes: 2
Reputation: 141
You are using row and col as string in "res_row_col", you have to 'expend' them to write what is inside the variables.
Maybe something like that by cutting the string and using concatenation : "res_" . row . "_" . col
Upvotes: 1