Saving matrix in Rdata and updating Rdata file

核能气质少年 提交于 2019-12-13 14:17:57

问题


I have a matrix:

mat<-matrix(data=1:30,ncol=10,nrow=3)

I would like to save this to Rdata:

save(mat, file="m.Rdata")

Then load it back:

m<-load("m.Rdata")

Then look at its contents:

m
[1] "mat"

All it displays is the name of the matrix saved but the values are lost.

What am I doing wrong?

Also

Once I have saved the matrix I would like to create a new matrix:

mat2<-matrix(data=30:59,ncol=10,nrow=3)

I would then like to save this mat2 into the same Rdata file, what is the right procedure?


回答1:


Just use load("m.Rdata")

And try ls(). You should see your matrix name.

Consider reading on basics of R - The Workspace



来源:https://stackoverflow.com/questions/18529643/saving-matrix-in-rdata-and-updating-rdata-file

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