Importing matrix csv data into R - how to convert into dataframe

僤鯓⒐⒋嵵緔 提交于 2019-12-31 06:28:07

问题


I have a set of csv data that is saved in matrix format attached image is an example of the matrix I would like to load the data into R and have it stored as a data frame with x$Year,x$Death,x$ASMR. How would I be able to do that?

Thanks!

CS


回答1:


I think you're just looking for read.csv() and then change the colnames. I am assuming your file is separated by commas.

x <- read.csv('matrix.csv', sep=',', header=T)
colnames(x) <- c('Year', 'Death', 'ASMR')


来源:https://stackoverflow.com/questions/46019182/importing-matrix-csv-data-into-r-how-to-convert-into-dataframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!