Reputation: 543
I tried this code to get a data file from R into an excel file write.table(T1h1,file="table.xls").
When I opened the excel file it looks like this
T1h11 19198.7
T1h12 21090.7
T1h13 20474
T1h14 19557.3
T1h15 35335.3
T1h16 37534
T1h17 23355.3
T1h18 28823.3
T1h19 24003.3
T1h110 14978.7
T1h111 32976.7
T1h112 22928.7
T1h113 13316.7
T1h114 26042.7
T1h115 11271.3
Is there any way to get just the data without the row number such as T1h11, T1h12, T1h13 etc.
Upvotes: 0
Views: 262
Reputation: 270160
1. As long as your data frame only has one column then this works (at least it does work on Excel 2013 under Windows which is what I am using); however, assuming you started Excel by entering DF.xls
into the Windows cmd line or double clicking on DF.xls
in Windows Explorer when Excel starts it will warn you that the file is not a real xls
file and you can click on Yes or No to allow it to read it anyways or not:
DF <- data.frame(a = 1:3, row.names = letters[1:3])
write.table(DF, file = "DF.xls", row.names = FALSE)
2. If more than one column exists then the above will result in Excel reading all the columns into a single Excel column. This is not very useful so in that case replace the last line with:
write.csv(DF, file = "DF.csv", row.names = FALSE)
in which case Excel will read it in as a csv file.
3. See this R wiki page for more options.
Upvotes: 4