Switching from Matlab to R
On Mon, 21 May 2012, Michael Sumner wrote:
You can write out to binary or text from Matlab and read that in with readBin or read.table, there is also the R.matlab package to read some .mat files directly.
If you mean (particularly sparse) spatial weights in the spatial
regression sense, then in Matlab do for example:
[i,j,w] = find(weights);
wts = [i,j,w];
save -ascii wts.txt wts
and in R
library(spdep)
lw0 <- read.dat2listw("wts.txt")
lw <- nb2listw(lw0$neighbours, glist=lw0$weights, style="W")
If more general structures, follow Mike's suggestions.
Roger
On Monday, May 21, 2012, Saima Bashir wrote:
I want to import weight matrix into R from Matlab. Is it possible? if yes
then how??
Thanks
Saima
[[alternative HTML version deleted]]
_______________________________________________ R-sig-Geo mailing list R-sig-Geo at r-project.org <javascript:;> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Roger Bivand Department of Economics, NHH Norwegian School of Economics, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: Roger.Bivand at nhh.no