如何将双矩阵导出到excel或csv? [英] How do I export a double matrix to an excel or csv?
问题描述
我问
在R工作室中获取数据后,您只需使用 write.csv
命令写入csv格式: / p>
write.csv(my_df,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 This will create a file As this won't be working for a double matrix, you could form a new character matrix in the following way and then use Please try this. 这篇关于如何将双矩阵导出到excel或csv?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! 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)
write.csv
command for writing into csv format:write.csv(my_df, "your_file_name.csv", row.names=T)
your_file_name.csv
with the data of my_df
in your current working directory.EDIT:
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)