문제

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?

도움이 되었습니까?

해결책

Just use load("m.Rdata")

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

Consider reading on basics of R - The Workspace

다른 팁

use

write.table(mat, file="m.Rdata")
m<-read.table("m.Rdata") 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top