Re: [Rd] Bug in merge() in R-2.0.0 alpha
On Wed, 15 Sep 2004, Uwe Ligges wrote: > In some cases, merge() has a problem in R-2.0.0 alpha (2004-09-14): > >x <- structure(c("a", "b", "2", "0.2-26", "O", "O"), .Dim = c(2, 3), > .Dimnames = list(c("1", "2"), c("P", "V", "2"))) > >y <- structure(c("a", "b", "2", "0.2-25", "O", "O"), .Dim = c(2, 3), > .Dimnames = list(c("1", "2"), c("P", "V", "1"))) > >merge(x, y, all.y=TRUE) > > Error in "[<-"(`*tmp*`, ri, value = NULL) : > incompatible types > > > Looks like the NA handling has changed anywhere. Peter was right. rbind.data.frame had ## copy names if any names(value[[jj]])[ri] <- names(xj) but did not test if there were any. It would probably be a good idea if that did work but for now I have added a test. -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
FW: [Rd] Parsing multi-line strings. Bug? Feature?
> Kevin Wright <[EMAIL PROTECTED]> writes: > > > R 1.9.1 requires multi-line strings to contain a backslash at the > > end of each line (except the last line). As noted by Mark > > Bravington (http://tolstoy.newcastle.edu.au/R/help/02b/5199.html) > > this requirement appears to be undocumented. > > > > In S-Plus 6.2, multi-line strings do not need a backslash for continuation. > > > > I recently (http://tolstoy.newcastle.edu.au/R/devel/04b/0256.html) > > requested compatability with S-Plus and was told to contribute > > a patch and then it would be considered. Here is the proposed patch. <> > > Thanks for considering this patch. > > Peter Dalgaard wrote: > Sorry, I don't think that is good enough (notwithstanding the > nonstandard comment character). Notice that Splus does this: > > > x <- "foo > Continue string: bar > Continue string: baz" > > (and the entry is interruptible with Ctrl-C too) > > There's a very good reason for the change of prompt, as anyone who has > debugged SAS code with stray quotes will tell you: The system would > appear to be completely unresponsive because all input is being eaten > by the string readers. I think the following patch in StringValue might address Peter Dalgaard's point: when a bare newline is found (i.e. not preceded by a backslash), it's pushed back onto the character stack via xxungetc(c) and StringValue pretends that it's just read a backslash instead. Then, as usual, it looks for the next character which is of course a newline, and proceeds as normal. Output is from diff gram.c on R-devel from 7/9/2004. I hope the comments look sufficiently standard now (I'm not a C programmer). Mark 3122a3123,3124 > /* Old behaviour was: return ERROR; */ > /* Now pretend there was a backslash before EOL */ 3124c3126 < return ERROR; --- > c = '\\'; > *** Mark Bravington CSIRO (CMIS) PO Box 1538 Castray Esplanade Hobart TAS 7001 phone (61) 3 6232 5118 fax (61) 3 6232 5012 [EMAIL PROTECTED] __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] cor() fails with big dataframe
Hello, I have a big dataframe with *NO* na's (9 columns, 293380 rows). # doing memory.limit(size = 10) cor(x) #gives Error in cor(x) : missing observations in cov/cor In addition: Warning message: NAs introduced by coercion #I found the obvious workaround: COR <- matrix(rep(0, 81),9,9) for (i in 1:9) for (j in 1:9) {if (i>j) COR[i,j] <- cor (x[,i],x[,j])} #which works fine, with no warning #looks like a "cor()" bug. #I checked absence of NA's by x <- x[complete.cases(x),] summary(x) apply(x,2, function (x) (sum(is.na(x #I use R 1.9.1 Cheers, Mayeul KAUFFMANN Université Pierre Mendès France Grenoble - France __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Bug in merge() in R-2.0.0 alpha
Uwe Ligges <[EMAIL PROTECTED]> writes: > In some cases, merge() has a problem in R-2.0.0 alpha (2004-09-14): > >x <- structure(c("a", "b", "2", "0.2-26", "O", "O"), .Dim = c(2, 3), > .Dimnames = list(c("1", "2"), c("P", "V", "2"))) > >y <- structure(c("a", "b", "2", "0.2-25", "O", "O"), .Dim = c(2, 3), > .Dimnames = list(c("1", "2"), c("P", "V", "1"))) > >merge(x, y, all.y=TRUE) > > Error in "[<-"(`*tmp*`, ri, value = NULL) : > incompatible types > > > Looks like the NA handling has changed anywhere. Names handling, more likely: > v <- structure(list("2" = NA), .Names = "2", class = "data.frame", row.names = "2") > u <- structure(list("2" = structure(1, .Names = "1", .Label = "O", class = > "factor")), .Names = "2", class = "data.frame", row.names = "1") > uu <- structure(list("2" = structure(1, .Label = "O", class = "factor")), .Names = > "2", class = "data.frame", row.names = "1") > rbind(v,u) 2 2 1O > rbind(v,uu) 2 2 1O > rbind(u,v) Error during wrapup: incompatible types > rbind(uu,v) 2 1O 2 (Notice that the only difference between u and uu is the .Names bit) -- O__ Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] file.info() on file larger than 2GB
This appears to be fairly easy to solve, at least on Linux. R-devel now has an option --enable-linux-lfs that sets up the appropriate flags (and a very few other code changes were needed). Similar options work on Solaris. I have been able to create a 2.5Gb text file, move around it and read lines from here and there including near the end, both as a plain file and as a gzip-ed file. And file.info reports correctly. On Tue, 31 Aug 2004, Prof Brian Ripley wrote: > This is a purely OS issue: your OS has not been set up so the fopen and > stat calls handle > 2Gb files. There is one R issue: the size will > overflow in file.info. > > For example, under Solaris 64-bit applications can handle such files > whereas 32-bit ones need calls to stat64, fopen64 etc. > > It seems a very exotic need, but if someone wants to find out how to use > the OS-specific ways to extend stat etc and supply patches, please do so. > > We don't put OS-specific limitations on help pages. > > On Tue, 31 Aug 2004, Roger D. Peng wrote: > > > I've got a file that's approximately 2.2GB and it seems to be foiling > > file.info(). When I run `stat' from the shell I get > > > > zooey:> stat data.csv > >File: `data.csv' > >Size: 2271197563 Blocks: 4440280IO Block: 4096 regular file > > Device: 342h/834d Inode: 9994308 Links: 1 > > Access: (0644/-rw-r--r--) Uid: ( 500/ rpeng) Gid: ( 500/ rpeng) > > Access: 2004-08-31 09:50:04.0 -0400 > > Modify: 2004-08-26 19:09:42.0 -0400 > > Change: 2004-08-31 09:53:29.0 -0400 > > Take a look at the source code for stat, in coreutils. > > > But, file.info() in R-devel gives me: > > > > > file.info("data.csv") > > size isdir mode mtime ctime atime uid gid uname grname > > data.csv NANA NA NA > > > > I assume this has something to do with the underlying call to `stat' > > in `do_fileinfo'. > > > > This alone is not much of a problem but I also can't seem to be able > > to open a file connection to the same file. For example, > > > > > con <- file("data.csv") > > > open(con, "r") > > Error in open.connection(con, "r") : unable to open connection > > In addition: Warning message: > > cannot open file `data.csv' > > > > Also, interestingly, > > > > > file.exists("data.csv") > > [1] FALSE > > > > I take it all these things are related. > > > > Is it possible to fix this within R? Or should there be a note in the > > help pages? > > > > > version > > _ > > platform i686-pc-linux-gnu > > arch i686 > > os linux-gnu > > system i686, linux-gnu > > status Under development (unstable) > > major2 > > minor0.0 > > year 2004 > > month08 > > day 31 > > language R > > > > -roger > > > > __ > > [EMAIL PROTECTED] mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > > > > > -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] prototype in setClass.
It works better if you give setClass the right arguments. In your second call, you omitted the representation= argument, so you need to name the prototype argument: setClass("AtomList" ,contains="List" ,prototype = prototype(content="Atom")## would like to specify this ) With this change: R> new("AtomList") An object of class "AtomList" list() Slot "uniq": [1] FALSE Slot "content": [1] "Atom" (We can probably do some bullet-proofing, since the object returned from prototype() has a specific class, but that may have to wait until 2.0.1.) Wolski wrote: > > Hi! > > To specify a prototype in the setClass declaration is a great feature. > But prototype seems no to work for slots of the "super" class. > eg. The following code is declaring first the super class "List". This class has a > slot "content". > The class "AtomList" inherits from it and I would like to set content="Atom" by > prototype(content="Atom"). > But after new("AtomList") is called the slot content is empty as you can see running > the code below. > > setClass("List" > ,representation( > uniq="logical" > ,content="character" # would > like to set this when declaring the inheriting class. > ,names="character") > ,contains="list" > ,prototype(uniq=FALSE) > ) > > setClass("AtomList" > ,contains="List" > ,prototype(content="Atom")## would like to > specify this > ) > > new("AtomList") > > An object of class "AtomList" > list() > Slot "uniq": > [1] FALSE > > Slot "content": > character(0) > ###<-still not specified even if provided in prototype. > > Slot "names": > character(0) > > Version: > > R : Copyright 2004, The R Foundation for Statistical Computing > Version 2.0.0 alpha (2004-09-14), ISBN 3-900051-07-0 > or > R1.9.1 patched. > > /E > > __ > [EMAIL PROTECTED] mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel -- John M. Chambers [EMAIL PROTECTED] Bell Labs, Lucent Technologiesoffice: (908)582-2681 700 Mountain Avenue, Room 2C-282 fax:(908)582-3340 Murray Hill, NJ 07974web: http://www.cs.bell-labs.com/~jmc __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Bug in merge() in R-2.0.0 alpha
In some cases, merge() has a problem in R-2.0.0 alpha (2004-09-14): x <- structure(c("a", "b", "2", "0.2-26", "O", "O"), .Dim = c(2, 3), .Dimnames = list(c("1", "2"), c("P", "V", "2"))) y <- structure(c("a", "b", "2", "0.2-25", "O", "O"), .Dim = c(2, 3), .Dimnames = list(c("1", "2"), c("P", "V", "1"))) merge(x, y, all.y=TRUE) Error in "[<-"(`*tmp*`, ri, value = NULL) : incompatible types Looks like the NA handling has changed anywhere. Uwe Ligges __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-devel