Given the write.table line below:
write.table(results,file = "mydata.csv",row.names = TRUE,col.names = TRUE,sep = ",", append = TRUE)
I have the below result: enter image description here
However I would like to have row.names set up for a specific character vector (called "text" in my algorithm) to have the below result for a 400 rows (Note: Again, every row is already known. My concern is how to specify it so that my output file (mydata.csv) capture it. Please see below for desired outcome: enter image description here Please let me know if I have not been clear , and I will provide more details. Thanks a lot for your help
From the row.names
argument of help(write.table)
:
either a logical value indicating whether the row names of
x
are to be written along withx
, or a character vector of row names to be written .
So you could add your row names vector text
in the row.names
argument.
write.table(results, row.names = text, ...)
Also note that row.names = TRUE
and col.names = TRUE
are the default values in write.table()
, so you do not need to include them. I'm also not sure why you're using append = TRUE
. Taking those out, your call would then be
write.table(results, row.names = text, file = "mydata.csv", sep = ",")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.