Re: [Rd] (PR#9254)R script editor fails to read script longer then 1000 chars (non-English language settings)
Yes, thank you. The conditions are that you are running in a locale with a different encoding from the system codepage, when a limit in graphapp was hit (so although the script is read correctly, it was not displayed correctly). Fixed for 2.4.0. On Tue, 26 Sep 2006, [EMAIL PROTECTED] wrote: > Full_Name: Otto Shtirlitz > Version: 2.3.1 > OS: Win XP SP2 > Submission from: (NULL) (71.102.102.246) > > > I believe it's the same situation as described in bug 9248. R script editor > cannot open file exceeding 1000 characters even if created in the same editor. > File is > all ANSI with symbols < 128 and with window line endings CR/LF (0x0D 0x0A). > The trick is the local settings : even if the OS is US if the language > settings > for non-Unicode (Control Panel\Regional and Language options\Advanced\Language > for non-Unicode programs) is set to Russian in my case R only reads the first > 1000 chars (and appends some garbage). If this setting is switched back to > English the problem goes away. > > __ > R-devel@r-project.org 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 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Not all functions work in RSPerl package?
Hi, Prof Duncan I am sorry to report to a wrong place. But I am lucky to meet you by chance, right? Thanks first ^^ 1. The variable y1 is an array get from Perl, each element is from a database (the type should be numeric). Here is the code for that. $query = qq{ select exonCount, count(hsEnsGene) as geneCount from countTop1000ks group by exonCount order by exonCount; }; $sql=$orthologDB->prepare($query); $sql->execute()or die "Could not execute '$query' ..."; my @x1; my @y1; while(my($exonCount, $geneCount) = $sql->fetchrow_array()) { push(@x1, $exonCount); push(@y1, $geneCount); } Here is the result if I print out the value in @y1: print "y1---",join(" ",@y1), "---end\n"; % y1---101 44 33 26 8 15 18 13 3 5 4 2 1 4 1 1---end But when I call &R::callWithNames("barplot", {'',[EMAIL PROTECTED], 'main', 'Barplot the Gene number per exon with top1000 low Ks', 'xlab', "Exon(low ks) number in the gene",'ylab', 'Numbers of gene'}); It always says non-numeric argument: % Error in -0.01 * height : non-numeric argument to binary operator If I asign the value to another array, like my @x=(101, 44, 33, 26, 8, 15, 18, 13, 3, 5, 4, 2, 1, 4, 1, 1); &R::callWithNames("barplot", {'',[EMAIL PROTECTED], 'main', 'Barplot the Gene number per exon with top1000 low Ks', 'xlab', "Exon(low ks) number in the gene",'ylab', 'Numbers of gene'}); then it works. I don't know why and what the difference is. I also thought whether it is because of the different data type between Perl and R, because in Perl, "3" and 3 could be same sometime. So I call &R::callWithNames("as.numeric",{'',[EMAIL PROTECTED]); before I call &R::callWithNames("barplot", {'',[EMAIL PROTECTED]); Same error! Same case if I change to use the R::boxplot([EMAIL PROTECTED]) as you said. I am not sure I explain clear this time. Looking forwards to your response! Regards, -Xianjun On Thu, 2006-09-21 at 07:33 -0700, Duncan Temple Lang wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > > > Hi Xianjun > > [Important: Please don't send mail about an R package to r-bugs. That is > for reporting bugs in R itself. Add on packages are different > and it is only a coincidence that I am one of the R-core developers > and package author. In general, all bug reports about > a package should be sent to the author and questions should go to the > author and the r-devel or r-help list as appropriate.] > > > Is the problem you report a bug? Well not necessarily in RSPerl, > but in your code. Unfortunately, you haven't told me what > the variable y1 contains so it is hard to figure out what > is going into the computations. > > A couple of things: > a) Your example is calling boxplot in the first call and barplot > in the second. > > b) in the first example, you are passing @y1 and in the second > you are passing [EMAIL PROTECTED] > > I would guess that [EMAIL PROTECTED] is more appropriate and you might > try that > in the first case. > > c) the first case doesn't have any named arguments (just '') so why > use callWithNames. Just R::boxplot([EMAIL PROTECTED]) > > > You are calling the R functions, but you are getting an error during > the invocation. The error message is coming from R. So the > problem is that you are passing inputs to the functions that it cannot > handle. This can happen directly in R and so also in RSPerl. My guess > is that you don't have the correct type of data in @y1 or that you are > not passing it in the call as a reference. > > Xianjun Dong wrote: > > Hi, > > > > It looks that not all function in R could be implemented by RSPerl. For > > example, when I call > > > > &R::callWithNames("boxplot", {'',@y1}); > > or > > R::barplot([EMAIL PROTECTED]); > > > > There would be error: > > > > Error in -0.01 * height : non-numeric argument to binary operator > > Caught error in R::call() > > > > The same happened when calling "barplot", but it's ok to call plot. > > > > Is it a bug? > > > > - -- > Duncan Temple Lang[EMAIL PROTECTED] > Department of Statistics work: (530) 752-4782 > 4210 Mathematical Sciences Building fax: (530) 752-7099 > One Shields Ave. > University of California at Davis > Davis, > CA 95616, > USA > -BEGIN PGP SIGNATURE- > Version: GnuPG v1.4.3 (Darwin) > > iD8DBQFFEqKy9p/Jzwa2QP4RAoVcAJ4rK3CKGBCxlgdlJYke59l/Rm4rAQCffS1x > nhSyWBrhQre0UXvv3DKD0KI= > =EVsZ > -END PGP SIGNATURE- [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] modifs on ls
Hi all, It would be great to be able to use a syntax like : R> ls("grid:::grid\.") instead of : R> ls("package:grid", pattern = "^grid\.") Here is a modified version of `ls` that does the job. [ The only modifs are just after the if(!missing(name)) ] Does that make sense ? Cheers, Romain ls <- objects <- function (name, pos = -1, envir = as.environment(pos), all.names = FALSE, pattern) { if (!missing(name)) { if(length(grep(":::", name))){ spl <- strsplit(name, ":::")[[1]] name <- paste("package:", spl[1] , sep="") pattern <- paste("^", spl[2], sep="") } nameValue <- try(name) if(identical(class(nameValue), "try-error")) { name <- substitute(name) if (!is.character(name)) name <- deparse(name) pos <- name } else pos <- nameValue } all.names <- .Internal(ls(envir, all.names)) if (!missing(pattern)) { if ((ll <- length(grep("[", pattern, fixed=TRUE))) > 0 && ll != length(grep("]", pattern, fixed=TRUE))) { if (pattern == "[") { pattern <- "\\[" warning("replaced regular expression pattern '[' by '['") } else if (length(grep("[^]\\[<-", pattern) > 0)) { pattern <- sub("\\[<-", "\\[<-", pattern) warning("replaced '[<-' by '[<-' in regular expression pattern") } } grep(pattern, all.names, value = TRUE) } else all.names } -- *mangosolutions* /data analysis that delivers/ Tel +44 1249 467 467 Fax +44 1249 467 468 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] sprintf behavior (PR#9250)
On Mon, 25 Sep 2006 [EMAIL PROTECTED] wrote: > On Mon, 25 Sep 2006, [EMAIL PROTECTED] wrote: > ... > > sprintf("\p") doesn't show the backslash, this occurs with all strings that > > start with certain letters. There is however no explanation to this > > behavior. > > There is: see ?Quote (and C behaves in the same way). > > > And there seems to be no way to get a guaranteed backslash in sprintf. > > "\\", see the FAQ 7.8 for example. Splus's parser emits a warning when it sees a backslash outside of the recognized backslash sequence. E.g., > nchar("\Backslashed?") [1] 12 Warning messages: The initial backslash is ignored in \B -- not a recognized escape sequence. Use \\ to make a backslash You might want to add that warning to R's parser. I've seen the error in several R packages. E.g., bayesmix/R/JAGScontrol.R: text[4] <- "-inits.R\"\n\initialize\n" SciViews/svDialogs/R/fixedDlg.wxPython.R:if (length(grep("[\.]", basename(res))) == 0) The warning is mostly emitted when the error is benign, but it might help get people to think about what they are typing. Bill Dunlap Insightful Corporation bill at insightful dot com 360-428-8146 "All statements in this message represent the opinions of the author and do not necessarily reflect Insightful Corporation policy or position." __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] S4 accessors
Ross Boylan <[EMAIL PROTECTED]> writes: > Did you want this offlist? I'm happy keeping it on the list. No, I accidentally responded privately and I believe I already resent my reply to the list. Sorry about that. I've cc'd the list for this response. >> If anyone else is going to extend your classes, then you are doing >> them a disservice by not making these proper methods. It means that >> you can control what happens when they are called on a subclass. > My style has been to define a function, and then use setMethod if I want > to redefine it for an extension. That way the original version becomes > the generic. > > So I don't see what I'm doing as being a barrier to adding methods. Am > I missing something? You are not, but someone else might be: suppose you release your code and I would like to extend it. I am stuck until you decide to make generics. > Originally I tried defining the original using setMethod, but this > generates a complaint about a missing function; that's one reason I fell > into this style. You have to create the generic first if it doesn't already exist: setGeneric("foo", function(x) standardGeneric("foo")) >> For accessors, I like to document them in the methods section of the >> class documentation. > This is for accessors that really are methods, not my fake > function-based accessors, right? Which might be a further argument not to have the distinction in the first place ;-) To me, simple accessors are best documented with the class. If I have an instance, I will read help on it and find out what I can do with it. > If you use foo as an accessor method, where do you define the associated > function (i.e., \alias{foo})? I believe such a definition is expected by > R CMD check and is desirable for users looking for help on foo (?foo) > without paying attention to the fact it's a method. Yes you need an alias for the _generic_ function. You can either add the alias to the class man page where one of its methods is documented or you can have separate man pages for the generics. This is painful. S4 documentation, in general, is rather difficult and IMO this is in part a consequence of the more general (read more powerful) generic function based system. IOW, I think these are good questions. They are ones that I struggle with and do not know of any truly satisfying answers. Best, + seth -- Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center http://bioconductor.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] S4 accessors
On Tue, 2006-09-26 at 10:43 -0700, Seth Falcon wrote: > Ross Boylan <[EMAIL PROTECTED]> writes: > >> If anyone else is going to extend your classes, then you are doing > >> them a disservice by not making these proper methods. It means that > >> you can control what happens when they are called on a subclass. > > > My style has been to define a function, and then use setMethod if I want > > to redefine it for an extension. That way the original version becomes > > the generic. > > > > So I don't see what I'm doing as being a barrier to adding methods. Am > > I missing something? > > You are not, but someone else might be: suppose you release your code > and I would like to extend it. I am stuck until you decide to make > generics. This may be easier to do concretely. I have an S4 class A. I have defined a function foo that only operates on that class. You make a class B that extends A. You wish to give foo a different implementation for B. Does anything prevent you from doing setMethod("foo", "B", function(x) blah blah) (which is the same thing I do when I make a subclass)? This turns my original foo into the catchall method. Of course, foo is not appropriate for random objects, but that was true even when it was a regular function. > > > Originally I tried defining the original using setMethod, but this > > generates a complaint about a missing function; that's one reason I fell > > into this style. > > You have to create the generic first if it doesn't already exist: > >setGeneric("foo", function(x) standardGeneric("foo")) I wonder if it might be worth changing setMethod so that it does this by default when no existing function exists. Personally, that would fit the style I'm using better. > > >> For accessors, I like to document them in the methods section of the > >> class documentation. > > > This is for accessors that really are methods, not my fake > > function-based accessors, right? > > Which might be a further argument not to have the distinction in the > first place ;-) > > To me, simple accessors are best documented with the class. If I have > an instance, I will read help on it and find out what I can do with > it. > > > If you use foo as an accessor method, where do you define the associated > > function (i.e., \alias{foo})? I believe such a definition is expected by > > R CMD check and is desirable for users looking for help on foo (?foo) > > without paying attention to the fact it's a method. > > Yes you need an alias for the _generic_ function. You can either add > the alias to the class man page where one of its methods is documented > or you can have separate man pages for the generics. This is > painful. S4 documentation, in general, is rather difficult and IMO > this is in part a consequence of the more general (read more powerful) > generic function based system. As my message indicates, I too am struggling with an appropriate documentation style for S4 classes and methods. Since "Writing R Extensions" has said "Structure of and special markup for documenting S4 classes and methods are still under development." for as long as I cam remember, perhaps I'm not the only one. Some of the problem may reflect the tension between conventional OO and functional languages, since R remains the latter even under S4. I'm not sure if it's the tools or my approach that is making things awkward; it could be both! Ross __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Infinite Loop when installing a package from source (PR#9258)
Full_Name: Charles Dupont Version: Version 2.3.1 OS: linux Submission from: (NULL) (160.129.129.136) I think that this is infinite. I let it run for 30 minutes. During which it consumed 98% of my memory (1Gb) and steadily helled 90-99% of CPU. Steps to reproduce problem 1. get a source package e.g. Hmisc. 2. $ echo "library(Hmisc)" > Hmisc/R/test.R 3. $ R CMD INSTALL -d -l Hmisc.Rcheck -d Hmisc Here is the output of the call 'Rcmd INSTALL': in startdir= /home/dupontct/R with tmpdir= /tmp/R.INSTALL.IO1457 lib= '/home/dupontct/Hmisc.Rcheck', pkgs= ' "/home/dupontct/R/Hmisc"' before checking lockdir= '/home/dupontct/Hmisc.Rcheck/00LOCK' after checking lockdir build_help_opts= '--debug --txt --html --latex --example' 'Rcmd INSTALL': now doing 'eval ... do_install': * Installing *source* package 'Hmisc' ... ** libs ++ mkdir -p /home/dupontct/Hmisc.Rcheck/Hmisc/libs ++ test -f src/Makefile ++ cd src +++ ls cidxcn.f cidxcp.f hoeffd.f jacklins.f largrec.f ranksort.c rcorr.f string_box.c wclosest.f '*.cc' '*.cpp' '*.f90' '*.f95' ++ srcs='cidxcn.f cidxcp.f hoeffd.f jacklins.f largrec.f ranksort.c rcorr.f string_box.c wclosest.f' +++ cd /usr/lib/R/bin/exec +++ ls ++ archs=R ++ R_ARCH_keep= ++ test -n 'cidxcn.f cidxcp.f hoeffd.f jacklins.f largrec.f ranksort.c rcorr.f string_box.c wclosest.f' ++ test -x ../configure ++ for arch in '${archs}' ++ rm -f cidxcn.o cidxcp.o hoeffd.o jacklins.o largrec.o ranksort.o rcorr.o string_box.o wclosest.o Hmisc.so '*.sl' '*.dylib' ++ test R = R ++ R_ARCH= ++ export R_ARCH ++ sh /usr/lib/R/bin/SHLIB -o Hmisc.so cidxcn.f cidxcp.f hoeffd.f jacklins.f largrec.f ranksort.c rcorr.f string_box.c wclosest.f gfortran -fpic -g -O2 -c cidxcn.f -o cidxcn.o gfortran -fpic -g -O2 -c cidxcp.f -o cidxcp.o gfortran -fpic -g -O2 -c hoeffd.f -o hoeffd.o gfortran -fpic -g -O2 -c jacklins.f -o jacklins.o gfortran -fpic -g -O2 -c largrec.f -o largrec.o gcc -I/usr/share/R/include -I/usr/share/R/include -fpic -g -O2 -std=gnu99 -c ranksort.c -o ranksort.o gfortran -fpic -g -O2 -c rcorr.f -o rcorr.o gcc -I/usr/share/R/include -I/usr/share/R/include -fpic -g -O2 -std=gnu99 -c string_box.c -o string_box.o gfortran -fpic -g -O2 -c wclosest.f -o wclosest.o gcc -shared -o Hmisc.so cidxcn.o cidxcp.o hoeffd.o jacklins.o largrec.o ranksort.o rcorr.o string_box.o wclosest.o -lgfortran -lm -lgcc_s -L/usr/lib/R/lib -lR ++ cp Hmisc.so /home/dupontct/Hmisc.Rcheck/Hmisc/libs ++ R_ARCH= ++ cd .. ++ false ++ chmod 755 /home/dupontct/Hmisc.Rcheck/Hmisc/libs/Hmisc.so ++ true ++ set +x ** R ** inst ** preparing package for lazy loading Loading required package: chron Controll C administered here. After Ctrl-C additional output followed. Warning message: use of NULL environment is deprecated Error: unable to load R code in package 'Hmisc' Error: unable to load R code in package 'Hmisc' Error: unable to load R code in package 'Hmisc' Error: unable to load R code in package 'Hmisc' Error: unable to load R code in package 'Hmisc' Error: unable to load R code in package 'Hmisc' Error: unable to load R code in package 'Hmisc' Error: unable to load R code in package 'Hmisc' Error: unable to load R code in package 'Hmisc' Error: unable to load R code in package 'Hmisc' Error: unable to load R code in package 'Hmisc' Execution halted ** Removing '/home/dupontct/Hmisc.Rcheck/Hmisc' On further exploration I found that the problem resides in the tools:::code2LazyLoadDB function. The call to sys.source falls into an infinite loop when it tries to evaluate the line "library(Hmisc)" from the test.R file. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] standardization of slot access
Hi, I'm usually confused about when to use 'slot' or '@'. I've frequently read that it's always preferable to use accessor functions, so I would think the '@' operator should be avoided. However, ?slot contains the following advise: "Generally, the only reason to use the functional form rather than the simpler operator is _because_ the slot name has to be computed." How do we decide whether to use the function or the operator? Cheers, -- Seb __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] standardization of slot access
I think the point is that if you use @ and then later redesign the internals of the class so that that component is not longer stored but is, instead, computed then @ will no longer be possible to use in that instance and a method call will be required which means that the internal change implies that the user interface must change. Of course, that is undesirable. In some programming languages like Python one can access a variable and call a function using the exact same syntax so that it would be possible to make such an internal change without affecting the user. On 9/26/06, Sebastian P. Luque <[EMAIL PROTECTED]> wrote: > Hi, > > I'm usually confused about when to use 'slot' or '@'. I've frequently > read that it's always preferable to use accessor functions, so I would > think the '@' operator should be avoided. However, ?slot contains the > following advise: > > > "Generally, the only reason to use the functional form rather than the > simpler operator is _because_ the slot name has to be computed." > > > How do we decide whether to use the function or the operator? > > > Cheers, > > -- > Seb > > __ > R-devel@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] standardization of slot access
I think slot() is only necessary in the case where you have a <- "myslot" slot(object, a) which is equivalent to [EMAIL PROTECTED] It seems unlikely that you would use slot() during interactive use, but perhaps more so in programming. Even still, I rather infrequently find the need for slot() because classes have defined slot names---if you're going to access a slot, just use the name that you gave it in the class definition since that doesn't change from instance to instance. -roger Sebastian P. Luque wrote: > Hi, > > I'm usually confused about when to use 'slot' or '@'. I've frequently > read that it's always preferable to use accessor functions, so I would > think the '@' operator should be avoided. However, ?slot contains the > following advise: > > > "Generally, the only reason to use the functional form rather than the > simpler operator is _because_ the slot name has to be computed." > > > How do we decide whether to use the function or the operator? > > > Cheers, > -- Roger D. Peng | http://www.biostat.jhsph.edu/~rpeng/ __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] standardization of slot access
I believe that the "accessor" functions you've read about are not the slot() function, rather they are functions specifically designed for extracting certain data from an object. An example is the 'coef()' extractor function, which extracts coefficients from many model objects. The name of the accessor function need not bear any resemblance to the actual name of the slot in which the data is stored, and indeed, there does not even need to be a one-to-one relationship between accessor functions and slots. AFAIK, slot() and '@' can be regarded as syntactic variants (please correct me if I'm wrong). -- Tony Plate Sebastian P. Luque wrote: > Hi, > > I'm usually confused about when to use 'slot' or '@'. I've frequently > read that it's always preferable to use accessor functions, so I would > think the '@' operator should be avoided. However, ?slot contains the > following advise: > > > "Generally, the only reason to use the functional form rather than the > simpler operator is _because_ the slot name has to be computed." > > > How do we decide whether to use the function or the operator? > > > Cheers, > __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] standardization of slot access
Thank you all for your comments, which confirm the feeling I had that 'slot' is only needed in the rare occasions Roger mentioned. Although 'slot' is an accessor function, it seems it's not quite analogous to functions or methods for accessing components of objects. Cheers, -- Seb __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] standardization of slot access
On Tue, 26 Sep 2006, Sebastian P. Luque wrote: > Thank you all for your comments, which confirm the feeling I had that > 'slot' is only needed in the rare occasions Roger mentioned. Although > 'slot' is an accessor function, it seems it's not quite analogous to > functions or methods for accessing components of objects. > I find that slot() is useful in explaining to users what is going on. I also find that used inside s/lapply that say function(x) slot(x, "y") is a natural way to access contents of lists of objects. So I wouldn't conclude that it is only rarely used, and would recommend its use in explaining to students/users what is going on in new-style objects. Roger > > Cheers, > > -- Roger Bivand Economic Geography Section, Department of Economics, Norwegian School of Economics and Business Administration, Helleveien 30, N-5045 Bergen, Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43 e-mail: [EMAIL PROTECTED] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel