如何将双矩阵导出为excel或csv? [英] How do I export a double matrix to an excel or csv?
问题描述
我问了
在R studio中获取数据后,您可以使用 write.csv
命令写入csv格式: / p>
Write.csv(my_df,your_file_name.csv,row.names = T)
这将创建一个文件 your_file_name.csv
>
当前工作目录中的 write.csv
:
my_df_new< - matrix(0,9,1715)
my_df_new [,2:1715]< - my_df [,2:1715]
my_df_new [,1]< - as.character(my_df [,1])$ b $ b write.csv(my_df_new,your_file_name.csv,row.names = T)
请尝试这个。
I asked a question about using R to perform some web scraping for some data analysis.
Now I have the data I want. It is in a double matrix.
I am using . How do I export that double matrix to use in Excel?
EDIT:
I also have mydtm as a DocumentTermMatrix. Would that one be easier to extract?
EDIT: The code is included here : https://gist.github.com/simkimsia/7613396
Once you have got the data in the R studio, you can simply use the write.csv
command for writing into csv format:
write.csv(my_df, "your_file_name.csv", row.names=T)
This will create a file your_file_name.csv
with the data of my_df
in your current working directory.
EDIT:
As this won't be working for a double matrix, you could form a new character matrix in the following way and then use write.csv
:
my_df_new <- matrix(0, 9, 1715)
my_df_new[,2:1715] <- my_df[,2:1715]
my_df_new[,1] <- as.character(my_df[,1])
write.csv(my_df_new, "your_file_name.csv", row.names=T)
Please try this.
这篇关于如何将双矩阵导出为excel或csv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!