问题
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