[R] help usin scan on large matrix (caveats to what has been discussed before)

peter dalgaard pdalgd at gmail.com
Thu Aug 12 12:24:22 CEST 2010


On Aug 12, 2010, at 11:30 AM, Martin Tomko wrote:

> 
> c<-scan(file=f,what=list(c("",(rep(integer(0),cols)))), skip=1)
> m<-matrix(c, nrow = rows, ncol=cols,byrow=TRUE);
> 
> for some reason I end up with a character matrix, which I don't want. Is this the proper way to skip the first column (this is not documented anywhere - how does one skip the first column in scan???). is my way of specifying "integer(0)" correct?

No. Well, integer(0) is just superfluous where 0L would do, since scan only looks at the types not the contents, but more importantly, what= wants a list of as many elements as there are columns and you gave it 

> list(c("",(rep(integer(0),5))))
[[1]]
[1] ""

I think what you actually meant was

c(list(NULL),rep(list(0L),5))



> 
> And finally - would any sparse matrix package be more appropriate, and can I use a sparse matrix for the image() function producing typical heat,aps? I have seen that some sparse matrix packages produce different looking outputs, which would not be appropriate.
> 
> Thanks
> Martin
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list