r - Print horizontally with write.table command -
here writing small code number needs printed horizantally in txt file been generated here "note.txt"
for(n in 1:4) { write.table(n,"note.txt",append = true) }
i getting output
"x" "1" 1 "x" "1" 2 "x" "1" 3 "x" "1" 4
whereas want output :
1 2 3 4
or
1,2,3,4
please me.
paste function in r can used combine vector/strings using separator ( use attribute collapse
in paste command specify separator).
if vector v contains set of numbers printed horizontally.
v=c(1:4); write(paste(as.character(v), collapse=","),"note.txt",append="true";
Comments
Post a Comment