r - Write csv or table variables to file -
lets have file this:
a b c d 2 3 4 5 9 8 7 4 5 7 8 4
i export column a
, c
nothing else.
can version of write.csv
or write.table
e.g. write.csv(myobject$a && myobject$b, file="outfile.csv")
this should work
write.csv(myobject[,c("a","b")], file="outfile.csv",row.names=false)
the brackets in myobject[rows,cols]
select rows , columns of data frame or matrix. if rows argument left empty, rows returned; , "cols". vector can used select multiple rows or columns. in case, we're selecting rows (because part blank) , columns "a" , "b".
the row.names=false
option prevents rownames being printed. in cases, might want keep them, of course.
Comments
Post a Comment