Re: [R] matrix from list

2008-04-27 Thread Olivier Lefevre
It's true one may have to set some rules but I think you are blowing it up. First, it is true one would have to agree for list[[vec]] to always return a matrix but it is the useful behaviour since you can already get a vector with unlist(list[vec]). Second, as to the raggedness, matrix(), array

Re: [R] matrix from list

2008-04-26 Thread Olivier Lefevre
Martin Maechler wrote: > The difference to as.matrix() is that data.matrix() also > produces a numeric matrix in the case the data frame contains > factors. Thanks, that is useful but it is becoming a little rococo: so may ways to do this. Also, what if I have a list, not a data frame? read

Re: [R] matrix from list

2008-04-26 Thread Olivier Lefevre
Olivier Lefevre wrote: > Anyway you are right that it would still return the kind of object, only > subsetted, which is not I want. I mean [] would do that; I know [[]] doesn't. Yet I still don't see why one accepts vector arguments but not the other: they are both indexing

Re: [R] matrix from list

2008-04-25 Thread Olivier Lefevre
Greg Snow wrote: > The '[[' only returns a single element from a data structure I know but that is precisely what I find arbitrary. Anyway you are right that it would still return the kind of object, only subsetted, which is not I want. As someone kindly pointed out to me offline, besides the u

Re: [R] matrix from list

2008-04-24 Thread Olivier Lefevre
Yes, unlist is the magic wand I was looking for. Thanks a million! Having said that, I find it rather arbitrary that you can write mat[1:4] but not list[[1:2]]; IMO there should be no need for a "magic" operator like unlist: list[[1:length(list)]] could do the job. -- O.L.

Re: [R] How to test for NULL?

2008-04-24 Thread Olivier Lefevre
chenxh007 wrote: > is.null Thanks! That one is mentioned in the LRM under ยง2.1.6 (NULL), so I should have found it... -- O.L. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www

[R] matrix from list

2008-04-24 Thread Olivier Lefevre
Another possibly simple thing that I cannot get right is how to extract the data part of a list as a matrix. The data were read from xls, with labels, and thus are of list mode, e.g., col1 col2 1 0.1 1.1 2 0.2 1.2 I want to extract from that just the numeric data part, i.e., (in this case

[R] How to test for NULL?

2008-04-24 Thread Olivier Lefevre
x == NULL returns logical(0) instead of FALSE or TRUE as you might expect and I cannot find the right way to write this test in R. Thanks in advance for any hint, -- O.L. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-hel

Re: [R] sqlSave (RODBC) question

2008-03-19 Thread Olivier Lefevre
FWIW, this is on SQL Server. -- O.L. __ R-help@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, reproduci

[R] sqlSave (RODBC) question

2008-03-17 Thread Olivier Lefevre
I am having a hard time understanding how to make sure the right types (esp. in the case of dates) are passed to the db, partly because of a lack of concrete examples in the docs and partly because the docs are a bit elliptic: the docs merely say that "the types are selected by consulting argum

Re: [R] RODBC: DNS vs. connection string

2008-03-04 Thread Olivier Lefevre
I meant a DSN, not a DNS... -- O.L. __ R-help@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, reproducib

[R] RODBC: DNS vs. connection string

2008-03-04 Thread Olivier Lefevre
I am able to connect to an SQL Server Express 2005 instance using either a local source or a connection string (i.e., the two forms of odbcConnect) but sqlColumns returns different results. Specifically two string columns are reported as being of type ntext and length 1073741823 in the first case v