Re: [Rd] Problem with fitdistr for gamma in R 2.2.0
Thanks to both Peters for involvment. I will add argument for method to be used in optim. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] update.packages() and loaded packages (PR#8448)
Hello! This is not a severe bug, but an inconsistency in update.packages(). I updated packages and I was not carefull enough to detach loaded packages. The update.packages() warrned me about this, which is fine, but at the end of the update the following warrning was issued (the whole session output can be found at the end of this mail): ... The downloaded packages are in C:\Documents and Settings\GGorjan\Local Settings\Temp\RtmpVwI1ob\downloaded_packages updating HTML package descriptions Warning message: number of rows of result is not a multiple of vector length (arg 1) in: cbind(1, pkgs, lib) R> version _ platform i386-pc-mingw32 arch i386 os mingw32 system i386, mingw32 status Patched major2 minor2.1 year 2005 month12 day 26 svn rev 36870 language R -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. -- R> update.packages(ask='graphics') --- Please select a CRAN mirror for use in this session --- Warning: packages 'gdata, gplots, gtools, R2WinBUGS' are in use and will not be installed trying URL 'http://www.fastmirrors.org/cran/bin/windows/contrib/2.2/coda_0.10-3.zip' Content type 'application/zip' length 288711 bytes opened URL downloaded 281Kb trying URL 'http://www.fastmirrors.org/cran/bin/windows/contrib/2.2/hdrcde_1.01.zip' Content type 'application/zip' length 102191 bytes opened URL downloaded 99Kb trying URL 'http://www.fastmirrors.org/cran/bin/windows/contrib/2.2/limma_2.4.4.zip' Content type 'application/zip' length 1331703 bytes opened URL downloaded 1300Kb trying URL 'http://www.fastmirrors.org/cran/bin/windows/contrib/2.2/locfit_1.5-2.zip' Content type 'application/zip' length 577663 bytes opened URL downloaded 564Kb trying URL 'http://www.fastmirrors.org/cran/bin/windows/contrib/2.2/Matrix_0.99-3.zip' Content type 'application/zip' length 2395983 bytes opened URL downloaded 2339Kb trying URL 'http://www.fastmirrors.org/cran/bin/windows/contrib/2.2/vcd_0.9-7.zip' Content type 'application/zip' length 1278635 bytes opened URL downloaded 1248Kb package 'coda' successfully unpacked and MD5 sums checked package 'hdrcde' successfully unpacked and MD5 sums checked package 'limma' successfully unpacked and MD5 sums checked package 'locfit' successfully unpacked and MD5 sums checked package 'Matrix' successfully unpacked and MD5 sums checked package 'vcd' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Documents and Settings\GGorjan\Local Settings\Temp\RtmpVwI1ob\downloaded_packages updating HTML package descriptions Warning message: number of rows of result is not a multiple of vector length (arg 1) in: cbind(1, pkgs, lib) R> detach(package:gdata) R> detach(package:gplots) R> detach(package:gtools) R> detach(package:R2WinBUGS) R> update.packages(ask='graphics') trying URL 'http://www.fastmirrors.org/cran/bin/windows/contrib/2.2/gdata_2.1.2.zip' Content type 'application/zip' length 336256 bytes opened URL downloaded 328Kb trying URL 'http://www.fastmirrors.org/cran/bin/windows/contrib/2.2/gplots_2.2.0.zip' Content type 'application/zip' length 441270 bytes opened URL downloaded 430Kb trying URL 'http://www.fastmirrors.org/cran/bin/windows/contrib/2.2/gtools_2.2.3.zip' Content type 'application/zip' length 127243 bytes opened URL downloaded 124Kb trying URL 'http://www.fastmirrors.org/cran/bin/windows/contrib/2.2/R2WinBUGS_1.1-0.zip' Content type 'application/zip' length 1188431 bytes opened URL downloaded 1160Kb package 'gdata' successfully unpacked and MD5 sums checked package 'gplots' successfully unpacked and MD5 sums checked package 'gtools' successfully unpacked and MD5 sums checked package 'R2WinBUGS' successfully unpacked and MD5 sums checked The downloaded packages are in C:\Documents and Settings\GGorjan\Local Settings\Temp\RtmpVwI1ob\downloaded_packages updating HTML package descriptions __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] NaN in R distribution functions
Dear R developers, I noticed that core R distribution functions return NaN, when parameter values are out of parameter space. I have looked in source code and found that warnings and return of NaN are done internally in C code. For dgamma.c the line 49 is: if (shape <= 0 || scale <= 0) ML_ERR_return_NAN; OK. How should this be implemented if distribution functions are written directly in R? I came up with this if (any(shape <= 0)) { warning("shape must be positive") return(NaN) } I think that it would be nice that returning NaN for undefined parameter values in distribution functions would also be documented in Writing R Extension. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] NaN in R distribution functions
Prof Brian Ripley wrote: > On Wed, 28 Dec 2005, Gregor Gorjanc wrote: > >> Dear R developers, >> >> I noticed that core R distribution functions return NaN, when parameter >> values are out of parameter space. I have looked in source code and >> found that warnings and return of NaN are done internally in C code. For >> dgamma.c the line 49 is: >> >> if (shape <= 0 || scale <= 0) ML_ERR_return_NAN; >> >> OK. How should this be implemented if distribution functions are written >> directly in R? I came up with this >> >> if (any(shape <= 0)) { >> warning("shape must be positive") >> return(NaN) >> } > > > As the R-level code is vectorized, NaN is unlikely to be the appropriate > return value. You will find that only the relevant entries are NaN, for > example > >> dgamma(1, shape=-1:2) > > [1] NaN NaN 0.3678794 0.3678794 > Warning message: > NaNs produced in: dgamma(x, shape, scale, log) > Yes, you are right. >> I think that it would be nice that returning NaN for undefined parameter >> values in distribution functions would also be documented in Writing R >> Extension. > > It is purely a convention for use in the standalone libRmath with which > the code is shared. Otherwise returning NA or giving an error would > seem more appropriate. > > `Writing R Extensions' does not cover writing distribution functions, > and is certainly not intended to mandate how such extensions are written. I understand, however it would be really nice to have some guideline so that developers would write more or less similar code. I had a problem with one such functions, since it stopped if parameters values were out of parameter space. I used that function in optim() and it was annoyingly stopping the optimization. It was not much to change the function to return NaN (this could be as well NA as you have pointed out), but it would be nice that this would be the default. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] noweb and R
Terry Take a look in R News - there was a paper published on that topic. gg __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Registration of native routines
Dear R developers, I am working on registration of native C and FORTRAN routines and have encountered "inconsistencies" about this issue. I am referring to "Registering native routines" section of R-ext manual. *(DL_FUNC), &F77_SUB, &F77_SYMBOL On line 5108 of R-ext.texi the array for method myCall is defined as {"myCall", &myCall, 3}, but looking at examples in src/library/stats/src/init.c I notice addition of (DL_FUNC) i.e. upper definition would be {"myCall", (DL_FUNC) &myCall, 3}, This probably shows my poor knowledge of C, but what is the role of (DL_FUNC)? Looking around the code I notice that DL_FUNC is used also in other places. IMHO I would suggest that (DL_FUNC) is also "mentioned" in the manual. Additionally, what is the role of &F77_SUB() in registration of FORTRAN subroutines i.e. the following line is one example from src/library/stats/src/init.c. {"lowesw", (DL_FUNC) &F77_SUB(lowesw), 4} src/main/registration.c for example uses &F77_SYMBOL() instead of &F77_SUB(). Poking around the source I see that this is related to _. I would again suggest to add this to the manual. *Type and style field For .C() and .Fortran() manual says that registration array can also hold type and style fields. It is shown how type field should look like, but nothing usable is said about style except Typically, one omits this information in the registration data. Why would one omit this if The purpose is to allow @R{} to transfer values more efficiently across the R-C/FORTRAN interface by avoiding copying values when it is not necessary.? Thank you! Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Same method for more than one class
Hi, when defining method (I used length bellow just for the simplicity) for myClass (S4 class) I use setMethod(f="length", signature(x="myClass"), def=function(x) { cat("works") }) If I have myClass1 and myClass2 and mentioned method, which is not the default one, applies to both classes I have to write two setMethod() statements. Would it be possible to use signature(x=c("myClass1", "myClass2")) Currently it issues an error setClass(Class="myClass1", representation=representation(x="integer")) setClass(Class="myClass2", representation=representation(x="integer")) setMethod(f="length", signature(x="myClass1"), def=function(x) { cat("works") }) ## OK. setMethod(f="length", signature(x=c("myClass1", "myClass1")), def=function(x) { cat("works") }) Error in signature(x = c("myClass1", "myClass1")) : bad class specified for element 1 (should be a single character string) Regards, Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Same method for more than one class
Sean Davis wrote: ... > > Could you do: > > catFun <- function(x) { > cat("Works") > } > setMethod(f="length", signature(x="myClass1"),def=catFun) > setMethod(f="length", signature(x="myClass2"),def=catFun) Yep, that is what I wanted. setMethod(f="length", signature(x=c("myClass1", "myClass2")) would be shorter, but your proposal is also OK. Thank you again, Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Segmentation fault on bin/R --version in R-devel
Hello! I have tried to build and install latest version of R, but I am not able to perform the install, due to seg. fault. I did the following after SVN checkout and wget for recommendeds: ./configure --prefix=/usr/local/R-devel make make install ... ... tcut texthtmllatex example tobin texthtmllatex example untangle.specials texthtmllatex example veteran texthtmllatex ** building package indices ... * DONE (survival) make[2]: Leaving directory `/home/share/projectSoft/R/R/src/library/Recommended' make[1]: Leaving directory `/home/share/projectSoft/R/R/src/library/Recommended' make[1]: Entering directory `/home/share/projectSoft/R/R/doc/manual' make[1]: Nothing to be done for `front-matter'. make[1]: Nothing to be done for `html-non-svn'. make[1]: Leaving directory `/home/share/projectSoft/R/R/doc/manual' SVN-REVISION is unchanged make[1]: Entering directory `/home/share/projectSoft/R/R/m4' make[1]: Nothing to be done for `install'. make[1]: Leaving directory `/home/share/projectSoft/R/R/m4' make[1]: Entering directory `/home/share/projectSoft/R/R/tools' make[1]: Nothing to be done for `install'. make[1]: Leaving directory `/home/share/projectSoft/R/R/tools' make[1]: Entering directory `/home/share/projectSoft/R/R/doc' installing doc ... /usr/bin/install -c -m 644 ../NEWS "/usr/local/R-devel/lib/R/doc" sh: line 1: 15129 Segmentation fault ../bin/R --version 2>/dev/null help2man: can't get `--version' info from ../bin/R make[1]: *** [R.1] Error 139 make[1]: Leaving directory `/home/share/projectSoft/R/R/doc' make: *** [install] Error 1 gcc --version gcc (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. As can be seen I have Debian GNU/Linux. Any clues? Thank you! Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Segmentation fault on bin/R --version in R-devel
Simon Urbanek wrote: > Thanks, Gregor, it should be now fixed in the current R-devel. > > Cheers, > Simon Which I gladly confirm. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] fortune() in .Rprofile conflicts with R CMD INSTALL
Hello, This is about fortune package, but I think that might be related also to base R, so I am sending to package maintainer and R-devel list. I have the following in my .Rprofile to break monotony of code writing library(utils) library(fortunes) fortune() detach("package:fortunes") so I get a fortune every time I start R. It seems that this conflicts with R CMD INSTALL in latest R-devel on Linux. Two things can happen: 1. R CMD INSTALL fails -- $ R-devel CMD INSTALL connectedness * Installing to library ' My preference goes with the numbering scheme attributed to a tribe on some island in the Pacific which consists of a 'factor' with four levels: 'one', 'two', 'three', and 'lots'. Hence, I'd go with 'lots of R users'. -- Dirk Eddelbuettel (in a discussion about trying to estimate the number of R users) R-help (April 2004) /usr/local/R-devel/lib/R/library' ERROR: cannot write to or create directory ' My preference goes with the numbering scheme attributed to a tribe on some island in the Pacific which consists of a 'factor' with four levels: 'one', 'two', 'three', and 'lots'. Hence, I'd go with 'lots of R users'. -- Dirk Eddelbuettel (in a discussion about trying to estimate the number of R users) R-help (April 2004) /usr/local/R-devel/lib/R/library' 2. R CMD INSTALL installs package in wrong place - see bellow -- $ R-devel CMD INSTALL connectedness * Installing to library ' If you imagine that this pen is Trellis, then Lattice is not this pen. -- Paul Murrell (on the difference of Lattice (which eventually was called grid) and Trellis) DSC 2001, Wien (March 2001) /usr/local/R-devel/lib/R/library' * Installing *source* package 'connectedness' ... ** R ** data ** inst cat: /home/ggorjan/programs/R/devel/r-ggorjan/: Is a directory cat: If: No such file or directory cat: you: No such file or directory cat: imagine: No such file or directory cat: that: No such file or directory cat: this: No such file or directory cat: pen: No such file or directory cat: is: No such file or directory cat: Trellis,: No such file or directory cat: then: No such file or directory cat: Lattice: No such file or directory cat: is: No such file or directory cat: not: No such file or directory cat: this: No such file or directory cat: pen.: No such file or directory cat: Paul: No such file or directory cat: Murrell: No such file or directory cat: (on: No such file or directory cat: the: No such file or directory cat: difference: No such file or directory cat: of: No such file or directory cat: Lattice: No such file or directory cat: (which: No such file or directory cat: eventually: No such file or directory cat: was: No such file or directory cat: called: No such file or directory cat: grid): No such file or directory cat: and: No such file or directory cat: Trellis): No such file or directory cat: DSC: No such file or directory cat: 2001,: No such file or directory cat: Wien: No such file or directory cat: (March: No such file or directory cat: 2001): No such file or directory cat: /usr/local/R-devel/lib/R/library/connectedness/R/connectedness: No such file or directory ** help >>> Building/Updating help pages for package 'connectedness' Formats: text html latex example connect texthtmllatex connectedness texthtmllatex example levelsBySubsettexthtmllatex example plot.connectednesstexthtmllatex example subset.connectedness texthtmllatex example ** building package indices ... * DONE (connectedness) $ tree -d . |-- \012If you imagine that this pen is Trellis, then Lattice is not this pen.\012 -- Paul Murrell (on the difference of Lattice (which eventually was called\012 grid) and Trellis)\012 DSC 2001, Wien (March 2001)\012\012 | `-- usr | `-- local | `-- R-devel | `-- lib | `-- R | `-- library | `-- connectedness | |-- Meta | |-- R | |-- R-ex | |-- data | |-- doc | |-- help | |-- html | |-- latex | |-- man | `-- unitTests |-- connectedness | |-- R | |-- data | |-- inst | | |-- doc | | `-- unitTests | |-- man | `-- tests ... Looks like a bug to me. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] fortune() in .Rprofile conflicts with R CMD INSTALL
Seth Falcon fhcrc.org> writes: > The quick fix for you is, I believe, > > if (interactive()) { > library(fortunes) > fortune() > detach("package:fortunes") > } > > Whether something could be changed so that R's output doesn't confuse > itself and gcc when doing R CMD INSTALL, seems like it should be > possible. Yes, this solves my! problem. I do not know what is causing this behaviour. This did not happen with 2.4.1 Thank you Seth. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] fortune() in .Rprofile conflicts with R CMD INSTALL
Kurt Hornik wrote: >> Kurt Hornik writes: >> Well, r-devel's src/scripts/INSTALL.in now has > >> if test -z "${lib}"; then >> lib=`echo "cat(.libPaths()[1])" | \ >> R_DEFAULT_PACKAGES=NULL "${R_EXE}" --no-save --slave` >> message "Installing to library '$lib'" > >> so we need to find a way to "just get" the result of cat(.libPaths()[1]) >> into $lib as intended. > >> One idea might be ensuring that this gets into the last line on its own, >> and then taking $lib as the last line of what we got ... > > I think I found (and committed) a solution for this. Yep, looks OK now. Thanks, Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R-Forge?
Hello! I have recently found RForge.net (http://www.rforge.net/) by Simon Urbanek and found out today that the site is accepting subscriptions. Great! However, browsing a bit on the site I found a link to another forge: R-Forge (http://r-forge.r-project.org/). Is/will the last one be the "offcial" forge for R packages, given that it has domain r-project.org? Regards, Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Sweave.sh shell script on CRAN
Dear developeRs, Martin Maechler has suggested that I resend this email to R-devel instead to R-packages for further comments and potential availability for Windows. -- I have uploaded my Sweave (bash) shell script on CRAN. It is available at http://cran.r-project.org/contrib/extra/scripts/ In short this script runs Sweave on given Rnw file(s) and post process produced tex file(s) with LaTeX and friends directly from command line. It has quite a rich set of command line options to mainly ease the LaTeX compilation. Please do not hesitate to contact me in case you find errors or have suggestions and/or code contributions. I am particularly, interested in making this script work under Windows. -- I do not have any experience with use of (bash) shell scripts under Windows. Sweave.sh can be used with Cygwin, but I am not sure how to use shell script without Cygwin. I noticed that some "scripts" in R*/bin directory on our Windows machine are perl (build, check, INSTALL, ...) and shell (Rd2dvi.sh, Stangle.sh, Sweave.sh, ...) scripts. This therefore means that R ships also perl and shell interpreter or am I missing something? Thanks! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Facultywww: http://www.bfro.uni-lj.si/MR/ggorjan Zootechnical Department blog: http://ggorjan.blogspot.com Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale fax: +386 (0)1 72 17 888 Slovenia, Europetel: +386 (0)1 72 17 861 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Sweave.sh shell script on CRAN
Duncan Murdoch wrote: >> I do not have any experience with use of (bash) shell scripts under >> Windows. Sweave.sh can be used with Cygwin, but I am not sure how to use >> shell script without Cygwin. I noticed that some "scripts" in R*/bin >> directory on our Windows machine are perl (build, check, INSTALL, ...) >> and shell (Rd2dvi.sh, Stangle.sh, Sweave.sh, ...) scripts. This >> therefore means that R ships also perl and shell interpreter or am I >> missing something? > > We don't ship Perl or sh.exe, but we do describe how to get them in the > R Admin manual. Maybe I got this totally wrong. Say someone who uses Windows finds R and installs it via setup file. Can he/she launch the folowing without having Perl and/or sh.exe? R CMD script whateverOption > I'd be interested in talking to you about integration of my patchDVI > functions into your script. They allow forward and reverse search > between the .dvi file and the .Rnw file (in yap and xdvi, at least). I am all ears. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Sweave.sh shell script on CRAN
Gabor Grothendieck wrote: > On Windows sweave.bat is a Windows XP batchfile that will run sweave > and then latex and then display the file on screen. Issuing the command > sweave without args from the Windows command line gives info on how to > use it. > Nice to see windows "equivalent". However, I must say that my script provides several ways to get to the result e.g. if you use prosper you need to go via postscript, beamer behaves differently etc. There are now the following ways of LaTeX processing: Command and path Script option Used tools - texi2dvi - PS -tp, --texi2dvi2ps texi2dvi and dvips - PS to PDF -tld, --texi2dvi2ps2pdf texi2dvi, dvips and ps2pdf - PDF -td, --texi2dvi2pdf texi2dvi with pdf option - latex - PS -lp, --latex2dvi2ps hardcoded 'latex+co' + dvips - PS to PDF -lld, --latex2dvi2ps2pdf hardcoded 'latex+co' + dvips - pdflatex - PDF -ld, --latex2pdf hardcoded 'latex+co' + dvips > To install sweave.bat you must place sweave.bat (and Rcmd.bat) both > from this batchfiles distribution anywhere in your path. It does not > require > sh.exe and does not make use of perl but does use "Rcmd sweave" > so would have no prerequisites beyond latex, Acrobot (or other viewer) > and those of Rcmd. As I stated I am not sure how Rcmd works, but Sweave in SVN is a shell script as well as Rcmd! How does it become an exe file? Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Sweave.sh shell script on CRAN
Gabor Grothendieck wrote: ... > If by "Sweave in SVN" you are referring to sweave.bat in the batchfiles > distribution then its not a shell file; rather, its a Windows batch file. Nope. I meant Sweave.sh in R SVN. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Sweave.sh shell script on CRAN
Duncan Murdoch wrote: ... >> Maybe I got this totally wrong. Say someone who uses Windows finds R and >> installs it via setup file. Can he/she launch the folowing without >> having Perl and/or sh.exe? >> >> R CMD script whateverOption > > No. Installing a binary package has a pure R implementation so it > doesn't need R CMD, but most of the capabilities of R CMD are not > available with a basic R install. > > There are two reasons for this. One is that the extra tools that are > needed take up a lot of space, so they would make the setup file really > huge. That's an issue of less importance these days than in the past. > > Another issue that is still important is that not all the tools needed > have licenses compatible with redistribution: in particular ActiveState > Perl and the Microsoft Help Workshop. There are other Perl > implementations, but in the past Brian Ripley found that they didn't > work. I don't know if that's still true. (In fact, I don't know if the > licenses still limit redistribution.) OK. Thank you for this explanation. I can not live without unix shell and therefore never noticed that under Windows say R CMD INSTALL or other R CMD scripts do not work without sh.exe (and/or Perl). Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Sweave.sh shell script on CRAN
Duncan Murdoch wrote: >> Can you just clarify what the dependencies are for >> >> Rcmd sweave >> >> where Rcmd is the Rcmd command distributed with R that is run >> from the Windows command line. Does that require perl or other >> tools to run? > > That needs sh.exe, not Perl. But it's just the equivalent of > > echo "library('utils'); Sweave('filename')" | Rterm --no-restore --slave Then sweave.bat from batchfiles depends on sh.exe as my Sweave.sh. However, I guess that above line can also be done with MS command line. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] format() applied to an NA character string (PR#9616)
Peter Dalgaard biostat.ku.dk> writes: > This happens on Linux too, given slightly larger widths: > > R version 2.5.0 RC (2007-04-17 r41210) > > > x <- as.character(NA) > > format(x,width=64) I can confirm this on Linux also. > format(x,width=36) [1] "NA " R> format(x,width=64) *** caught segfault *** address 0x20202020, cause 'memory not mapped' Traceback: 1: switch(mode(x), "NULL" = "NULL", character = .Internal(format(x, trim, digits, nsmall, width, adj, na.encode, scientific)), call = , expression = , "function" = , "(" = deparse(x), raw = as.character(x), prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3, na.encode, scientific)), big.mark = big.mark, big.interval = big.interval, small.mark = small.mark, small.interval = small.interval, decimal.mark = decimal.mark, zero.print = zero.print, preserve.width = if (trim) "individual" else "common")) 2: format.default(x, width = 64) 3: format(x, width = 64) Version: platform = i686-pc-linux-gnu arch = i686 os = linux-gnu system = i686, linux-gnu status = Under development (unstable) major = 2 minor = 6.0 year = 2007 month = 04 day = 18 svn rev = 41219 language = R version.string = R version 2.6.0 Under development (unstable) (2007-04-18 r41219) Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Problem with: Vignette dependencies (\VignetteDepends{} entries) must be contained in
Hello! I have just discovered a possible bug or lack of my knowledge. The last option is not so uncommon and I decided to ask here before flooding the bugs repository. Say I have a package test with vignette. Moving package directory to some other name, say test2, fails R CMD check with $ R CMD check test2 * checking for working latex ... OK * using log directory '/home/ggorjan/programs/R/devel/test2.Rcheck' * using R version 2.4.1 (2006-12-18) * checking for file 'test2/DESCRIPTION' ... OK * checking extension type ... Package * this is package 'test' version '0.1.0' * checking package dependencies ... ERROR Vignette dependencies not required: test Vignette dependencies (\VignetteDepends{} entries) must be contained in the DESCRIPTION Depends/Suggests entries. I got the same behaviour with recent R-devel (2007-04-18 r41219). Search on R-{help,devel} and BioC mailing lists did not show any relevant info for this error. Search in R-devel sources reveals that above error string comes from src/library/tools/R/{all.R,QC.R} - function print.check_package_depends, which in turns uses info from function .check_package_depends and it seems to me that relevant code is on lines 2436-2447. I am attaching both test and test2 tarballs so anyone can test this easily. Version: platform = i486-pc-linux-gnu arch = i486 os = linux-gnu system = i486, linux-gnu status = major = 2 minor = 4.1 year = 2006 month = 12 day = 18 svn rev = 40228 language = R version.string = R version 2.4.1 (2006-12-18) -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Facultywww: http://www.bfro.uni-lj.si/MR/ggorjan Zootechnical Department blog: http://ggorjan.blogspot.com Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale fax: +386 (0)1 72 17 888 Slovenia, Europetel: +386 (0)1 72 17 861 -- test.tgz Description: application/compressed-tar test2.tgz Description: application/compressed-tar __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Problem with: Vignette dependencies (\Vignet teDepends{} entries) must be contained in
Gregor Gorjanc bfro.uni-lj.si> writes: > > Hello! > > I have just discovered a possible bug or lack of my knowledge. The last > option is not so uncommon and I decided to ask here before flooding the > bugs repository. > > Say I have a package test with vignette. Moving package directory to > some other name, say test2, fails R CMD check with This problem is due to my specification in Rnw file i.e. % \VignetteDepends{test} If I remove this or remove just test and leave some other packages in it (that are also in DESCRIPTION Depends field), then previously reported error in R CMD check does not show up. It seems that I have not understood \VignetteDepends{} properly. I thought that we need to specify all packages that are needed for vignette to work. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] developing a package: increase the number of functions
Prof Brian Ripley stats.ox.ac.uk> writes: ... > > Do you have a NAMESPACE? Hi Albart! About the NAMESACE issue. Functions that are specified in NAMESPACE are available when you install a package, while internal ones can only be accessed with myInternalFun:::myPackage Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Typo in regex help page
Hi! I believe there is a typo in R/src/library/base/man/regex.Rd The 52nd line looks like: The metacharacters are in EREs are ... ^^^ Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Typo in regex help page
Hi! I believe there is a typo in R/src/library/base/man/regex.Rd The 52nd line looks like: The metacharacters are in EREs are ... ^^^ Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] faqs
Gabor Grothendieck gmail.com> writes: > inst/NEWS would have the advantage of consistency with R itself > which also has a NEWS file. > ... > > My vote is for inst/ChangeLog. I wote for inst/NEWS, while inst/ChangeLog can also be present to show more details such as svn log. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Bug in format.default(): na.encode does not have any effect for (PR#12318)
Hi! If I use format() on numeric vector, na.encode argument does not have any e= ffect. This was reported before: - https://stat.ethz.ch/pipermail/r-help/2007-October/143881.html - http://tolstoy.newcastle.edu.au/R/e2/devel/06/09/0360.html It works for other (say character) classes! > format(c("a", NA), na.encode=3DTRUE) [1] "a " "NA" > format(c("a", NA), na.encode=3DFALSE) [1] "a" NA I explored this a bit and found out that format.default() uses prettyNum(.I= nternal(format(...))) for formatting the logical, numeric, complex, ... classes. Simple tests (se= e bellow) show that .Internal(format()) does not obey the na.encode argument. ## Encode NA as "NA" > .Internal(format(x=3Dc(1, NA), trim=3DFALSE, digits=3DNULL, nsmall=3D0, w= idth=3DNULL, adj=3D1, na.encode=3DTRUE, scientific=3DNA)) [1] " 1" "NA" ## Do not encode NA as "NA" > .Internal(format(x=3Dc(1, NA), trim=3DFALSE, digits=3DNULL, nsmall=3D0, w= idth=3DNULL, adj=3D1, na.encode=3DFALSE, scientific=3DNA)) [1] " 1" "NA" ## --> no effect ## Does prettyNum encode NA as "NA" > prettyNum(c("1", NA)) [1] "1" NA ## --> not for character > prettyNum(c(1, NA)) [1] "1" "NA" ## --> but it does for numeric I did all my tests with my Ubuntu box running R > version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 7.1 year 2008 month 06 day23 svn rev45970 language R version.string R version 2.7.1 (2008-06-23) -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Facultywww: http://gregor.gorjanc.googlepages.com Zootechnical Department blog: http://ggorjan.blogspot.com Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale fax: +386 (0)1 72 17 888 Slovenia, Europetel: +386 (0)1 72 17 861 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Methods for format() are not consistent with NA values (PR#12385)
Hi! Methods for format() are not consistent when applied to vectors having NA values. Some methods encode NA values to "NA" by default, while other do not. It would be much more easier to write other functions if these functions would all behave consistently. Examples produced with R > version _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major 2 minor 7.1 year 2008 month 06 day23 svn rev45970 language R version.string R version 2.7.1 (2008-06-23) testData <- data.frame( fac1=3Dfactor(c(NA, letters[1:9], "hjh")), fac2=3Dfactor(c(letters[6:15], NA)), cha1=3Dc(letters[17:26], NA), cha2=3Dc(NA, "longer", letters[25:17]), stringsAsFactors=3DFALSE) levels(testData$fac1) <- c(levels(testData$fac1), "unusedLevel") testData$Date <- as.Date("1900-1-1") testData$Date[2] <- NA testData$POSIXt <- as.POSIXct(strptime("1900-1-1 01:01:01", format=3D"%Y-%m-%d %H:%M:%S")) testData$POSIXt[5] <- NA ## --- Character --- > format(testData$cha1) [1] "q " "r " "s " "t " "u " "v " "w " "x " "y " "z " "NA" > format(testData$cha1, na.encode=3DTRUE) [1] "q " "r " "s " "t " "u " "v " "w " "x " "y " "z " "NA" > format(testData$cha1, na.encode=3DFALSE) [1] "q" "r" "s" "t" "u" "v" "w" "x" "y" "z" NA ## --- Factor --- > format(testData$fac1) [1] "NA " "a " "b " "c " "d " "e " "f " "g " "h " "i " "hjh" > format(testData$fac1, na.encode=3DTRUE) [1] "NA " "a " "b " "c " "d " "e " "f " "g " "h " "i " "hjh" > format(testData$fac1, na.encode=3DFALSE) [1] NA"a " "b " "c " "d " "e " "f " "g " "h " "i " "hjh" ## --- Numeric et al. --- ## na.encode has no effect ## --- Date --- > format(testData$Date) [1] "1900-01-01" NA "1900-01-01" "1900-01-01" "1900-01-01" [6] "1900-01-01" "1900-01-01" "1900-01-01" "1900-01-01" "1900-01-01" [11] "1900-01-01" > format(testData$Date, na.encode=3DTRUE) [1] "1900-01-01" NA "1900-01-01" "1900-01-01" "1900-01-01" [6] "1900-01-01" "1900-01-01" "1900-01-01" "1900-01-01" "1900-01-01" [11] "1900-01-01" > format(testData$Date, na.encode=3DFALSE) [1] "1900-01-01" NA "1900-01-01" "1900-01-01" "1900-01-01" [6] "1900-01-01" "1900-01-01" "1900-01-01" "1900-01-01" "1900-01-01" [11] "1900-01-01" ## --- POSIXt --- > format(testData$POSIXt) [1] "1900-01-01 01:01:01" "1900-01-01 01:01:01" "1900-01-01 01:01:01" [4] "1900-01-01 01:01:01" NA"1900-01-01 01:01:01" [7] "1900-01-01 01:01:01" "1900-01-01 01:01:01" "1900-01-01 01:01:01" [10] "1900-01-01 01:01:01" "1900-01-01 01:01:01" > format(testData$POSIXt, na.encode=3DTRUE) [1] "1900-01-01 01:01:01" "1900-01-01 01:01:01" "1900-01-01 01:01:01" [4] "1900-01-01 01:01:01" NA"1900-01-01 01:01:01" [7] "1900-01-01 01:01:01" "1900-01-01 01:01:01" "1900-01-01 01:01:01" [10] "1900-01-01 01:01:01" "1900-01-01 01:01:01" > format(testData$POSIXt, na.encode=3DFALSE) [1] "1900-01-01 01:01:01" "1900-01-01 01:01:01" "1900-01-01 01:01:01" [4] "1900-01-01 01:01:01" NA"1900-01-01 01:01:01" [7] "1900-01-01 01:01:01" "1900-01-01 01:01:01" "1900-01-01 01:01:01" [10] "1900-01-01 01:01:01" "1900-01-01 01:01:01" -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Facultywww: http://gregor.gorjanc.googlepages.com Zootechnical Department blog: http://ggorjan.blogspot.com Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale fax: +386 (0)1 72 17 888 Slovenia, Europetel: +386 (0)1 72 17 861 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Wishlist - better object.size() function
Benjamin Hofner imbe.med.uni-erlangen.de> writes: ... > - Why is the function returning the size in bytes? This is (in most > cases) overly accurate and for humans hard to read. I would suggest to > have it printed in mb per default and additionally add a switch to > choose the appropriate unit. > > This is a first proposal: ... There was a such proposal some time ago. See https://stat.ethz.ch/pipermail/r-devel/2006-August/038935.html https://stat.ethz.ch/pipermail/r-devel/2006-September/042673.html http://tolstoy.newcastle.edu.au/R/e2/devel/06/09/0181.html Unfortunatelly, there was no interest in adding this to R. I removed the files mentioned in above posts. However, the proposed implementation was added to my "private-playground" package ggmisc. The package can be downloaded at http://gregor.gorjanc.googlepages.com/ggmisc_0.2.1.tar.gz http://gregor.gorjanc.googlepages.com/ggmisc_0.2.1.zip gg __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Align legend title wish remainder (PR#13415)
Full_Name: Gregor Gorjanc Version: 2.8.0 and above OS: generic Submission from: (NULL) (82.192.44.219) This is just a remainder for a wish to align legend title as reported and "solved" at https://stat.ethz.ch/pipermail/r-devel/2008-December/051642.html Thanks! Regards, Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Undocumented argument na.last in factor()
Hello! I just noticed that argument na.last in factor() is not documented. Did I miss something or ...? I just wonder how base package passes then R CMD check. I checked also in source man page in R-devel. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Internal codes of the factor
Hello! I am writing some functions and I repeatedly acces internal factor codes. I figured out that internal codes are 1:n where 1 represents 1st level, 2 2nd level etc. This is not documented and I wonder if this is on purpose and subject to change or would be a good idea to add this to documentation for factor? I can prepair a pacth if this is accepted. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Undocumented argument na.last in factor()
Martin Maechler wrote: >>>>>>"Gregor" == Gregor Gorjanc <[EMAIL PROTECTED]> >>>>>>on Tue, 14 Mar 2006 09:58:22 +0100 writes: > > > Gregor> Hello! I just noticed that argument na.last in > Gregor> factor() is not documented. Did I miss something or > Gregor> ...? I just wonder how base package passes then R > Gregor> CMD check. I checked also in source man page in > Gregor> R-devel. > > I wondered too -- for a few moments only -- after reading your > message... > > *BUT* na.last is *not* an argument to factor()! > > Look more carefully at str(factor) or args(factor) > (or the help page) ! Argh, yes you are right. Argument na.last is for sort for levels. I apologize for this. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Internal codes of the factor
Berwin A Turlach wrote: > G'day Gregor, > > >>>>>>"GG" == Gregor Gorjanc <[EMAIL PROTECTED]> writes: > > > GG> I am writing some functions and I repeatedly acces internal > GG> factor codes. I figured out that internal codes are 1:n where > GG> 1 represents 1st level, 2 2nd level etc. This is not > GG> documented [...] > The help page for factor states in the 'Details' section: > > The encoding of the vector happens as follows. First all the > values in 'exclude' are removed from 'levels'. If 'x[i]' equals > 'levels[j]', then the 'i'-th element of the result is 'j'. If no > match is found for 'x[i]' in 'levels', then the 'i'-th element of > the result is set to 'NA'. > > Note in particular the part on "then the 'i'-th element of the result > is 'j'". This pretty much documents that the internal codes are 1:n > and 'NA', as documented in the following sentence. Thanks for this pointer to documentation. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] Collapsing levels of a factor
>> x <- factor(1:3, labels = c("b" , "f", "minus")) >> x > [1] b f minus > Levels: b f minus > > I want to change all "minus" to "b". I know that the simplest way to do this > is > >> levels(x) <- c("b", "f", "b") > > and also that > >> x[x == "minus"] <- "b" >> x <- factor(x) > > works. But why not > >> x <- ifelse(x == "minus", "b", x) >> x <- factor(x) > x > [1] 1 2 b > Levels: 1 2 b > I find particulary usefull the list approach. Here is the example from levels help page. I like this approach, since you can modify list and apply it to a factor via levels. ## we can add levels this way: f <- factor(c("a","b")) levels(f) <- c("c", "a", "b") f f <- factor(c("a","b")) levels(f) <- list(C="C", A="a", B="b") f I was playing around this last week and wrote a simple function[1], which can save you some work in getting such a list from a factor. Is R core interested in it? [1]http://www.bfro.uni-lj.si/MR/ggorjan/software/R/ggmisc/factorMap.R -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] levels for list and data.frame
Hello! Does R core find the following pacth usefull - I created methods for levels for list and data.frame, which can be usefull to get a list of levels for entries in a list or columns in a data.frame. Patch is attached and shown bellow example # Example > tmp <- list() > tmp$a <- factor(letters[1:10]) > tmp$b <- factor(letters[5:14]) > tmp$c <- 1:10 > tmp1 <- as.data.frame(tmp) > tmp2 <- list() > tmp2$"1" <- tmp > tmp2$"2" <- tmp1 > str(tmp2) List of 2 $ 1:List of 3 ..$ a: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10 ..$ b: Factor w/ 10 levels "e","f","g","h",..: 1 2 3 4 5 6 7 8 9 10 ..$ c: int [1:10] 1 2 3 4 5 6 7 8 9 10 $ 2:`data.frame': 10 obs. of 3 variables: ..$ a: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10 ..$ b: Factor w/ 10 levels "e","f","g","h",..: 1 2 3 4 5 6 7 8 9 10 ..$ c: int [1:10] 1 2 3 4 5 6 7 8 9 10 > levels(tmp2) $"1" $"1"$a [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" $"1"$b [1] "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" $"2" $"2"$a [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" $"2"$b [1] "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" > levels(tmp2, drop = FALSE) $"1" $"1"$a [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" $"1"$b [1] "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" $"1"$c NULL $"2" $"2"$a [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" $"2"$b [1] "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" $"2"$c NULL -- $ svn diff factor.R Index: factor.R === --- factor.R(revision 37559) +++ factor.R(working copy) @@ -25,7 +25,25 @@ ## Help old S users: category <- function(...) .Defunct() -levels <- function(x) attr(x, "levels") +levels <- function(x, ...) UseMethod("levels") + +levels.default <- function(x, ...) attr(x, "levels") + +levels.list <- function(x, drop = TRUE) +{ +tmp <- lapply(x, levels, drop = drop) +if (drop) { +tmp1 <- unlist(lapply(tmp, is.null)) +tmp <- tmp[!tmp1] +} +return(tmp) +} + +levels.data.frame <- function(x, ...) +{ +return(levels.list(x, ...)) +} + nlevels <- function(x) length(levels(x)) "levels<-" <- function(x, value) UseMethod("levels<-") -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. -- factor.R.diff.gz Description: GNU Zip compressed data __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] levels for list and data.frame
oops, this does not pass R CMD check. I will have to read manuals a bit more. ... * checking S3 generic/method consistency ... WARNING levels: function(x, ...) levels.list: function(x, drop) levels: function(x, ...) levels.data.frame: function(x, drop) ... Anyway, I would like to ask what is the "opinion" about writing methods for classes as list and data.frame. Methods for this might not be as simple as for numeric, character, factor and it would be nice that there would be some guidelines for at least: - what should be the "general" output i.e. list or something else - I understand that it is hard to say in advance, but a common policy might not hurt - what to do if a method for a list or data.frame can not be applied to each entry/column > Hello! > > Does R core find the following pacth usefull - I created methods for > levels for list and data.frame, which can be usefull to get a list of > levels for entries in a list or columns in a data.frame. Patch is > attached and shown bellow example > > # Example >> tmp <- list() >> tmp$a <- factor(letters[1:10]) >> tmp$b <- factor(letters[5:14]) >> tmp$c <- 1:10 >> tmp1 <- as.data.frame(tmp) >> tmp2 <- list() >> tmp2$"1" <- tmp >> tmp2$"2" <- tmp1 >> str(tmp2) > List of 2 > $ 1:List of 3 > ..$ a: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10 > ..$ b: Factor w/ 10 levels "e","f","g","h",..: 1 2 3 4 5 6 7 8 9 10 > ..$ c: int [1:10] 1 2 3 4 5 6 7 8 9 10 > $ 2:`data.frame': 10 obs. of 3 variables: > ..$ a: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10 > ..$ b: Factor w/ 10 levels "e","f","g","h",..: 1 2 3 4 5 6 7 8 9 10 > ..$ c: int [1:10] 1 2 3 4 5 6 7 8 9 10 > >> levels(tmp2) > $"1" > $"1"$a > [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" > > $"1"$b > [1] "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" > > > $"2" > $"2"$a > [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" > > $"2"$b > [1] "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" > >> levels(tmp2, drop = FALSE) > $"1" > $"1"$a > [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" > > $"1"$b > [1] "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" > > $"1"$c > NULL > > > $"2" > $"2"$a > [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" > > $"2"$b > [1] "e" "f" "g" "h" "i" "j" "k" "l" "m" "n" > > $"2"$c > NULL > > -- > > $ svn diff factor.R > Index: factor.R > === > --- factor.R(revision 37559) > +++ factor.R(working copy) > @@ -25,7 +25,25 @@ > ## Help old S users: > category <- function(...) .Defunct() > > -levels <- function(x) attr(x, "levels") > +levels <- function(x, ...) UseMethod("levels") > + > +levels.default <- function(x, ...) attr(x, "levels") > + > +levels.list <- function(x, drop = TRUE) > +{ > +tmp <- lapply(x, levels, drop = drop) > +if (drop) { > +tmp1 <- unlist(lapply(tmp, is.null)) > +tmp <- tmp[!tmp1] > +} > +return(tmp) > +} > + > +levels.data.frame <- function(x, ...) > +{ > +return(levels.list(x, ...)) > +} > + > nlevels <- function(x) length(levels(x)) > > "levels<-" <- function(x, value) UseMethod("levels<-") > -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] [Fwd: Re: levels for list and data.frame]
I unintentionally missed to cc to r-devel. Original Message Subject: Re: [Rd] levels for list and data.frame Date: Tue, 21 Mar 2006 20:50:21 +0100 From: Gregor Gorjanc <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: Martin Maechler <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> Martin Maechler wrote: > Hi Gregor, > > before even considering methods for "list" and "data.frame", > can you explain why you think it is important for levels() to > become a generic function at all? > For me, levels belong to factors (or then to contour plots, or > co-plots ) but exactly because level is a too generic word, it > seems to me to be problematic as a generic function. > > How would describe the purpose of the levels() generic? > You are right. I was in situation where I wanted to get levels from all entries (factors) of a list and considered to write a method for this instead of always using lapply(). It went quite smoothly, if I skip R CMD check error. After that I began to think and post a question to R-devel. Perhaps levels is really to generic, however one can set levels also for non-factors. Although, I agree that this is of no use. I was also playing with levels<- and find it quite hard to do something general and usable for lists and data.frame. If we put levels aside, is there any opinion/policy about list, data.frame methods? Just curiosity. > >>>>>>"Gregor" == Gregor Gorjanc <[EMAIL PROTECTED]> >>>>>>on Mon, 20 Mar 2006 23:27:21 +0100 writes: > > > Gregor> oops, this does not pass R CMD check. I will have to read manuals > a bit > Gregor> more. > > Gregor> ... > Gregor> * checking S3 generic/method consistency ... WARNING > Gregor> levels: > Gregor> function(x, ...) > Gregor> levels.list: > Gregor> function(x, drop) > > Gregor> levels: > Gregor> function(x, ...) > Gregor> levels.data.frame: > Gregor> function(x, drop) > Gregor> ... > > Gregor> Anyway, I would like to ask what is the "opinion" about writing > methods > Gregor> for classes as list and data.frame. Methods for this might not be > as > Gregor> simple as for numeric, character, factor and it would be nice > that there > Gregor> would be some guidelines for at least: > Gregor> - what should be the "general" output i.e. list or something else > - I > Gregor> understand that it is hard to say in advance, but a common policy > might > Gregor> not hurt > Gregor> - what to do if a method for a list or data.frame can not be > applied to > Gregor> each entry/column > > > >> Hello! > >> > >> Does R core find the following pacth usefull - I created methods for > >> levels for list and data.frame, which can be usefull to get a list of > >> levels for entries in a list or columns in a data.frame. Patch is > >> attached and shown bellow example > >> > >> # Example > >>> tmp <- list() > >>> tmp$a <- factor(letters[1:10]) > >>> tmp$b <- factor(letters[5:14]) > >>> tmp$c <- 1:10 > >>> tmp1 <- as.data.frame(tmp) > >>> tmp2 <- list() > >>> tmp2$"1" <- tmp > >>> tmp2$"2" <- tmp1 > >>> str(tmp2) > >> List of 2 > >> $ 1:List of 3 > >> ..$ a: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10 > >> ..$ b: Factor w/ 10 levels "e","f","g","h",..: 1 2 3 4 5 6 7 8 9 10 > >> ..$ c: int [1:10] 1 2 3 4 5 6 7 8 9 10 > >> $ 2:`data.frame': 10 obs. of 3 variables: > >> ..$ a: Factor w/ 10 levels "a","b","c","d",..: 1 2 3 4 5 6 7 8 9 10 > >> ..$ b: Factor w/ 10 levels "e","f","g","h",..: 1 2 3 4 5 6 7 8 9 10 > >> ..$ c: int [1:10] 1 2 3 4 5 6 7 8 9 10 > >> > >>> levels(tmp2) > >> $"1" > >> $"1"$a > >> [1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" > >> > >> $"1"$b > >> [1] "e" "f" "g" "h" "i" "j" "k" "
Re: [Rd] levels for list and data.frame
Martin Maechler wrote: >>>>>>"Gregor" == Gregor Gorjanc <[EMAIL PROTECTED]> >>>>>>on Tue, 21 Mar 2006 20:50:21 +0100 writes: > > > Gregor> Martin Maechler wrote: > >> Hi Gregor, > >> > >> before even considering methods for "list" and > >> "data.frame", can you explain why you think it is > >> important for levels() to become a generic function at > >> all? For me, levels belong to factors (or then to > >> contour plots, or co-plots ) but exactly because level is > >> a too generic word, it seems to me to be problematic as a > >> generic function. > >> > >> How would describe the purpose of the levels() generic? > >> > > Gregor> You are right. I was in situation where I wanted to > Gregor> get levels from all entries (factors) of a list and > Gregor> considered to write a method for this instead of > Gregor> always using lapply(). It went quite smoothly, if I > Gregor> skip R CMD check error. After that I began to think > Gregor> and post a question to R-devel. Perhaps levels is > Gregor> really to generic, however one can set levels also > Gregor> for non-factors. Although, I agree that this is of > Gregor> no use. I was also playing with levels<- and find it > Gregor> quite hard to do something general and usable for > Gregor> lists and data.frame. > > Gregor> If we put levels aside, is there any opinion/policy > Gregor> about list, data.frame methods? Just curiosity. > > I don't understand the question. Do you mean the question if > methods should be written for "list" or for "data.frame" (which > inherit from "list")? Yes. > But in any case, can you please take this back to R-devel? > It has started there, and people should be able to see the > continuation / conclusion. > Hmm, replay all to your mail does not include r-devel, weird. Done. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Example in ?order
Hello! On R Version 2.2.1 (2005-12-20 r36812) and in SVN The following part of the example in ?order says ## For character vectors we can make use of rank: cy <- as.character(y) rbind(x,y,z)[, order(x, -rank(y), z)] But "cy" is not used in there. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Wish: Add fill argument to warning and stop (PR#8823)
Full_Name: Gregor Gorjanc Version: R 2.2.1 OS: Linux Submission from: (NULL) (82.192.44.229) Hello! It would be nice if warning() and stop() would have fill argument as it is in cat(). Thanks! _ platform i486-pc-linux-gnu arch i486 os linux-gnu system i486, linux-gnu status major2 minor2.1 year 2005 month12 day 20 svn rev 36812 language R __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] separators in data()
Ben, you confused read.csv and read.csv2. Separator in read.csv is ",", while it is ";" in read.csv2. This is due to use of different decimal symbols in some european languages - mine is one of them and I really hate this. So the situation is: decimal separator english . , some european lang. , ; There is then of course also a need to handle decimal separator and this is done in read.csv2. > just out of curiosity: > > why is the default behavior in data() for reading in .csv files > to use sep=";" (semicolon rather than comma)? is this a historical > artifact of some sort, or is there other logic to it? It caught > me by surprise since I was expecting it to be sep="," as in > read.csv() ... > > cheers > Ben Bolker -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Wish/suggestion: add output of citation() to package "manuals" (PR#9009)
Dear R core, influenced by recent panel discussion in Vienna I think that it would be nice to add package specific output of citation() function to package reference manuals. I think that apropriate place would be just after fields from DESCRIPTION file. This will be OK for CRAN, but not for locally installed packages as there is not reference manual there (at least on my linux box) - why is this the case? Perhaps output of citation() could be added to package specific help page i.e. to mypackage.package.Rd file. The same could be done with R's manuals. I know that there is an entry in FAQ on this and that there is a note after launching R, but questions about apropriate reference on R-help list are quite frequent. Perhaps this is so due to the habit that one looks into the paper/book/manual about relevant information for reference. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Test for argument in ...
Hello! Say I have a function foo1, which has argument ... to pass various arguments to foo2 i.e. foo1 <- function(x, ...) { foo2(x, ...) } Say that foo2 accepts argument arg1 and I would like to do the following: - if foo1 is called as foo1(x) then I would like to assign some value to arg1 inside foo1 before calling foo2 arg1 <- "some value" foo2(x, arg1=arg1) - if foo1 is called foo1(arg1="some other value") do not assign some value to arg1 and call foo2 foo2(arg1=arg1) However, I am not able to do this since I do not know how to test/check if arg1 was given in foo1. Is it possible to test whether some argument was passed in "..." i.e. something like foo1 <- function(x, ...) { if(testForArgumentInThreeDots(arg1)) arg1 <- "some value" foo2(x, arg1=arg1, ...) } Thanks! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Test for argument in ...
Gabor Grothendieck wrote: > Try this: > >> f <- function(...) if (!is.null(list(...)$arg1)) cat("arg1 found\n") >> else cat("arg1 not found\n") >> f(arg1 = 3) > arg1 found >> f(arg2 = 3) > arg1 not found Thanks! Use of list(...) really helps me here. > On 7/1/06, Gregor Gorjanc <[EMAIL PROTECTED]> wrote: >> Hello! >> >> Say I have a function foo1, which has argument ... to pass various >> arguments to foo2 i.e. >> >> foo1 <- function(x, ...) >> { >> foo2(x, ...) >> } >> >> Say that foo2 accepts argument arg1 and I would like to do the following: >> - if foo1 is called as foo1(x) then I would like to assign some value to >> arg1 inside foo1 before calling foo2 >> >> arg1 <- "some value" >> foo2(x, arg1=arg1) >> >> - if foo1 is called foo1(arg1="some other value") do not assign some >> value to arg1 and call foo2 >> >> foo2(arg1=arg1) >> >> However, I am not able to do this since I do not know how to test/check >> if arg1 was given in foo1. Is it possible to test whether some argument >> was passed in "..." i.e. something like >> >> foo1 <- function(x, ...) >> { >> if(testForArgumentInThreeDots(arg1)) arg1 <- "some value" >> foo2(x, arg1=arg1, ...) >> } >> >> Thanks! >> >> -- >> Lep pozdrav / With regards, >>Gregor Gorjanc >> >> -- >> University of Ljubljana PhD student >> Biotechnical Faculty >> Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan >> Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si >> >> SI-1230 Domzale tel: +386 (0)1 72 17 861 >> Slovenia, Europefax: +386 (0)1 72 17 888 >> >> -- >> "One must learn by doing the thing; for though you think you know it, >> you have no certainty until you try." Sophocles ~ 450 B.C. >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Test for argument in ...
Hi, Gabor Grothendieck wrote: > Try this: > >> f <- function(...) if (!is.null(list(...)$arg1)) cat("arg1 found\n") >> else cat("arg1 not found\n") >> f(arg1 = 3) > arg1 found >> f(arg2 = 3) > arg1 not found Actually it is not OK. Bellow is simplified example that shows, what I would like to do: foo1 <- function(x, ...) { if(is.null(list(...)$decreasing)) { decreasing <- TRUE } else { decreasing <- list(...)$decreasing } return(order(x, ..., decreasing=decreasing)) } > foo1(c(5, 2, 3, 4)) [1] 1 4 3 2 >foo1(c(5, 2, 3, 4), decreasing=FALSE) Error in order(x, ..., decreasing = decreasing) : formal argument "decreasing" matched by multiple actual arguments > On 7/1/06, Gregor Gorjanc <[EMAIL PROTECTED]> wrote: >> Hello! >> >> Say I have a function foo1, which has argument ... to pass various >> arguments to foo2 i.e. >> >> foo1 <- function(x, ...) >> { >> foo2(x, ...) >> } >> >> Say that foo2 accepts argument arg1 and I would like to do the following: >> - if foo1 is called as foo1(x) then I would like to assign some value to >> arg1 inside foo1 before calling foo2 >> >> arg1 <- "some value" >> foo2(x, arg1=arg1) >> >> - if foo1 is called foo1(arg1="some other value") do not assign some >> value to arg1 and call foo2 >> >> foo2(arg1=arg1) >> >> However, I am not able to do this since I do not know how to test/check >> if arg1 was given in foo1. Is it possible to test whether some argument >> was passed in "..." i.e. something like >> >> foo1 <- function(x, ...) >> { >> if(testForArgumentInThreeDots(arg1)) arg1 <- "some value" >> foo2(x, arg1=arg1, ...) >> } >> >> Thanks! >> >> -- >> Lep pozdrav / With regards, >>Gregor Gorjanc >> >> -- >> University of Ljubljana PhD student >> Biotechnical Faculty >> Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan >> Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si >> >> SI-1230 Domzale tel: +386 (0)1 72 17 861 >> Slovenia, Europe fax: +386 (0)1 72 17 888 >> >> -- >> "One must learn by doing the thing; for though you think you know it, >> you have no certainty until you try." Sophocles ~ 450 B.C. >> >> __ >> R-devel@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-devel >> -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Test for argument in ...
Yes, this works. Thanks Gabor! Gabor Grothendieck wrote: > That's because you are passing the argument twice. Try this: > >> foo1 <- function(x, ...) > + { > + L <- list(...) > + if (is.null(L$decreasing)) L$decreasing <- TRUE > + do.call(order, c(list(x), L)) > + } >> >> foo1(c(5, 2, 3, 4), decreasing=FALSE) > [1] 2 3 4 1 > > On 7/1/06, Gregor Gorjanc <[EMAIL PROTECTED]> wrote: >> Hi, >> >> Gabor Grothendieck wrote: >> > Try this: >> > >> >> f <- function(...) if (!is.null(list(...)$arg1)) cat("arg1 found\n") >> >> else cat("arg1 not found\n") >> >> f(arg1 = 3) >> > arg1 found >> >> f(arg2 = 3) >> > arg1 not found >> >> Actually it is not OK. Bellow is simplified example that shows, what I >> would like to do: >> >> foo1 <- function(x, ...) >> { >> if(is.null(list(...)$decreasing)) { >>decreasing <- TRUE >> } else { >>decreasing <- list(...)$decreasing >> } >> return(order(x, ..., decreasing=decreasing)) >> } >> >> > foo1(c(5, 2, 3, 4)) >> [1] 1 4 3 2 >> >> >foo1(c(5, 2, 3, 4), decreasing=FALSE) >> Error in order(x, ..., decreasing = decreasing) : >>formal argument "decreasing" matched by multiple actual arguments >> >> > On 7/1/06, Gregor Gorjanc <[EMAIL PROTECTED]> wrote: >> >> Hello! >> >> >> >> Say I have a function foo1, which has argument ... to pass various >> >> arguments to foo2 i.e. >> >> >> >> foo1 <- function(x, ...) >> >> { >> >> foo2(x, ...) >> >> } >> >> >> >> Say that foo2 accepts argument arg1 and I would like to do the >> following: >> >> - if foo1 is called as foo1(x) then I would like to assign some >> value to >> >> arg1 inside foo1 before calling foo2 >> >> >> >> arg1 <- "some value" >> >> foo2(x, arg1=arg1) >> >> >> >> - if foo1 is called foo1(arg1="some other value") do not assign some >> >> value to arg1 and call foo2 >> >> >> >> foo2(arg1=arg1) >> >> >> >> However, I am not able to do this since I do not know how to >> test/check >> >> if arg1 was given in foo1. Is it possible to test whether some >> argument >> >> was passed in "..." i.e. something like >> >> >> >> foo1 <- function(x, ...) >> >> { >> >> if(testForArgumentInThreeDots(arg1)) arg1 <- "some value" >> >> foo2(x, arg1=arg1, ...) >> >> } >> >> >> >> Thanks! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Test for argument in ...
Bill Dunlap wrote: > On Sun, 2 Jul 2006, Gregor Gorjanc wrote: > >> Yes, this works. >> >> Thanks Gabor! >> >> Gabor Grothendieck wrote: >>> That's because you are passing the argument twice. Try this: >>> >>>> foo1 <- function(x, ...) >>> + { >>> + L <- list(...) >>> + if (is.null(L$decreasing)) L$decreasing <- TRUE >>> + do.call(order, c(list(x), L)) >>> + } >>>> foo1(c(5, 2, 3, 4), decreasing=FALSE) >>> [1] 2 3 4 1 > > How does this differ from >foo2 <- function(x, ..., decreasing=TRUE) > order(x, ..., decreasing = decreasing) > ? I agree, but I wanted to learn ... argument in a more general way. That was just an example - not a good one as you have showed. >> x<-c(5,2,3,4) >> identical(foo2(x), foo1(x)) > [1] TRUE >> identical(foo2(x,decreasing=F), foo1(x,decreasing=F)) > [1] TRUE >> identical(foo2(x,decreasing=T), foo1(x,decreasing=T)) > [1] TRUE -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] "Template" for model.matrix functions
Hello! I would like to write a function that would create a (part) of a model matrix to be used in lm() like functions i.e lm(y ~ myFunc(x)) Where can I find a good example or a template for this as well as for predict method? Thanks! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Bug?: summary() fails after use of na.action="na.exclude" in lm()
Hello! I have encountered a weird problem and I am wondering if this is a bug. Here is the example: n <- 50 x <- runif(n=n) y1 <- 2 * x + rnorm(n=n) y2 <- 5 * x + rnorm(n=n) y2[sample(1:n, size=5)] <- NA y <- cbind(y1, y2) fit <- lm(y1 ~ 1, na.action="na.exclude") summary(fit) ## Goes ok here fit <- lm(y2 ~ 1, na.action="na.exclude") summary(fit) ## But fails if we use matrix of response variables fit <- lm(y ~ 1, na.action="na.exclude") summary(fit) ## Response y1 : ## ## Call: ## lm(formula = y1 ~ 1, na.action = "na.exclude") ## ## Residuals: ## Error in quantile.default(resid) : missing values and NaN's not allowed if 'na.rm' is FALSE Am I doing something wrong here? -- Btw. man page of lm says (in the begining of the details): "A typical model has the form 'response ~ terms' where 'response' is the (numeric) response vector ..." ^^^^^^ Should not this part say that repsponse can also be a matrix? Thanks -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Making a patch
Hi, Andrew Robinson ms.unimelb.edu.au> writes: > > Dear R developers, > > is there a preferred format or strategy for making a patch to > contribute to a package that is maintained by R-core? Berwin Turlach > and I have written a very minor extension to lmeControl to allow it to > pass an argument to nlminb for the maximum number of evaluations of > the objective function. I've edited the nlme/R/lme.R and > nlme/man/lmeControl.Rd files. I can diff the files, but the options > seem numerous. I haven't been able to find any hinst on the preferred > approach. Any advice would be welcomed. > look at http://article.gmane.org/gmane.comp.lang.r.devel/8858 perhaps this (with modifications if necesarry) could be added to developer page http://developer.r-project.org/ Afterall, there is a good guide on posting mails to r-mailing lists and it would be good to have the same for pacthes. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] RFC: Redefining length() ?
Hi, Martin Maechler stat.math.ethz.ch> writes: > > So I did open a new subject and move the discussion to R-devel > now. > > > "MM" == Martin Maechler stat.math.ethz.ch> > > on Mon, 24 Jul 2006 11:46:05 +0200 writes: > > > "Gabor" == Gabor Grothendieck gmail.com> > > on Sun, 23 Jul 2006 09:02:35 -0400 writes: > > Gabor> Looking at the diff.POSIXt code we see the problem is > Gabor> that it takes the length of the input using length > Gabor> which is wrong since in the case of POSIXlt the > Gabor> length is always 9 (or maybe length should be defined > Gabor> differently for POSIXlt?). > > MM> Though I agree with Spencer that a user may expect > MM> length() to behave differently, but I don't think this > MM> would be a good idea. Yes, length() is generic, but its > MM> help() emphasizes that for lists, length() should be the > MM> number of list elements. Of course anyone one *can* > MM> define length() methods that behave differently for > MM> his/her classes, but then one would also want to make > MM> sure that e.g. x[length(x)] or 'x[length(x)] <- value' > MM> works and -- in a case of simple S3 class built on a > MM> list, would work differently than if x was a the simple list. I think that having generic for POSIXlt would be more natural than default length, which is (as stated by Gabor) always 9. When I see a date or time with all additions I always think of it as one "element". So it would be naturaly that length() would return number of dates/times in POSIXlt object. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Package Unit Testing
Martin Maechler stat.math.ethz.ch> writes: > > > "miguel" == miguel manese gmail.com> > > on Mon, 3 Jul 2006 09:43:12 +0800 writes: > > miguel> Hello, Do we have like an official unit testing > miguel> framework for packages? Like we do R CMD check, and > miguel> say the scripts in /test are executed? > > yes. Just it's "./tests", not './test'. > > More specifically, all ./tests/*.R are executed and for those > foobar.R for which there's a foobar.Rout.save file, > the output is (R CMD Rdiff)ed agains the result of running foobar.R > > All this should be pretty obvious from the manual > "Writing R Extensions". > What was it in there that was not clear enough? I just tried to find relevant information and searched the whole Writing R Extensions manual on word test. I have find information Martin stated above, but failed to find how *.Rout.save should be created. I think that manual should say that. Did I miss something obvious? I am also not able to find Rdiff COMMAND in man page of R under Debian. Browsing a bit in sources reveals that *.Rout.save is copy of R session (starts with "welcome" text and later one code and output is there). But how does one generate such a file? Additionally, does testing also test the first "welcome" text - different version of R haave a bit different "welcome" text and that should be an error then or ... Thanks! Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Package Unit Testing
Torsten Hothorn wrote: ... >> Browsing a bit in sources reveals that *.Rout.save is copy of R session >> (starts with "welcome" text and later one code and output is there). >> But how does one generate such a file? > > either R CMD BATCH or simply run R CMD check once and copy > .Rcheck/tests/*.Rout into /tests/*Rout.save > >> Additionally, does testing also >> test the first "welcome" text - different version of R haave a bit >> different >> "welcome" text and that should be an error then or ... > > R CMD check takes care of that. Thank you. I am also attaching a small gzipped patch for R-exts.texi. I did not wrap the lines in the text. If that is necesarry I can do it and resend the patch. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. -- R-exts.texi-tests-patch.gz Description: GNU Zip compressed data __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Making a patch
Gregor Gorjanc bfro.uni-lj.si> writes: > > Hi, > > Andrew Robinson ms.unimelb.edu.au> writes: > > > > Dear R developers, > > > > is there a preferred format or strategy for making a patch to > > contribute to a package that is maintained by R-core? Berwin Turlach ... > > look at > > http://article.gmane.org/gmane.comp.lang.r.devel/8858 Is there also any strategy in accepting patches in plain text or "somehow compressed" format? The later due to line wrapping in some mailers, etc. Thanks! Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] unique.default() drops names (PR#9130)
Hello! unique on a vector or list drops names, while it does not in case of data.frames and matrix - rownames and colnames here, but they are intuitively the same as names. The following code shows this effect: vecTest <- c("A", "D", "B", "D", "A") names(vecTest) <- paste("name", vecTest, sep="") unique(vecTest) listTest <- as.list(vecTest) unique(listTest) dfTest <- data.frame(vecTest) unique(dfTest) matTest <- as.matrix(vecTest) colnames(matTest) <- "col1" unique(matTest) I did not bump into .Internal(unique(x)), but the following change (diff to latest SVN version) to unique.default seems to work. Is this acceptable? Index: R/src/library/base/R/duplicated.R === --- R/src/library/base/R/duplicated.R (revision 38809) +++ R/src/library/base/R/duplicated.R (working copy) @@ -38,7 +38,12 @@ { if(!is.logical(incomparables) || incomparables) .NotYetUsed("incomparables != FALSE") +if(!is.null(names(x))) { +namesX <- names(x) +isNamed <- TRUE +} z <- .Internal(unique(x)) +if(isNamed) names(z) <- namesX[match(z, x)] if(is.factor(x)) factor(z, levels = seq(len=nlevels(x)), labels = levels(x), ordered = is.ordered(x)) --please do not edit the information below-- Version: platform = i486-pc-linux-gnu arch = i486 os = linux-gnu system = i486, linux-gnu status = major = 2 minor = 3.1 year = 2006 month = 06 day = 01 svn rev = 38247 language = R version.string = Version 2.3.1 (2006-06-01) Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical FacultyURI: http://www.bfro.uni-lj.si/MR/ggorjan Zootechnical Department mail: gregor.gorjanc bfro.uni-lj.si Groblje 3 tel: +386 (0)1 72 17 861 SI-1230 Domzale fax: +386 (0)1 72 17 888 Slovenia, Europe -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] unique.default() drops names (PR#9130)
Prof Brian Ripley wrote: > From the help page (?unique) > > Value: > > For a vector, an object of the same type of 'x', but with only one > copy of each duplicated element. No attributes are copied (so the > result has no names). > > Please take your own advice and `learn by doing as you are asked in the > posting guide'. Thank you for the reply! I appologize for not reading the latest documentation - there was no word about droping names in 2.3.1. However, I do wonder why simple fix (as shown in previous mail) is not OK. Afterall, there is considerable variability on what unique methods drop and what they preserve. Say: * factor - keep all levels as in x * data.frame - keep rownames (which are "needed" by default anyway) * matrix - keep rownames as well as colnames and I am perfectly fine with all these, I just wonder why names should be dropped if x is atomic and not (rownames and colnames) if x is a matrix, array or data.frame. Did I miss something or does addition of names back to atomic x break existing code? R> x <- c(1, 2, 3, 2) R> names(x) <- 1:length(x) R> unique(x) [1] 1 2 3 R> y <- matrix(x) R> colnames(y) <- 1; rownames(y) <- names(x) R> t(unique(y)) colnames(y) <- 1; rownames(y) <- names(x) -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Wishlist: multiple classes in \method{}{} (Rd markup) (PR#9135)
Hello! I wish that one could use \method{myMethod}{classA, classB}(x, arg1, arg2, arg3, ...) instead of \method{myMethod}{classA}(x, arg1, arg2, arg3, ...) \method{myMethod}{classB}(x, arg1, arg2, arg3, ...) when methods for both classA and classB have same set of arguments. This way there would be a line or two less markup in Rd file as well as in produced help page - one with note for both (or several classes) is more than enough. This might also ease reading of help pages. Thank you very much for such a great software! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] unique.default() drops names (PR#9130)
Seth Falcon fhcrc.org> writes: > I see value in unique() keeping names and from what I understand > the documentation could be changed to match > > I don't know if there are good reasons for dropping names from > vectors. > > Given that unique is very commonly used, I think the way to make such > a change is in the C code, not at the R level. So in that sense, I > think the patch you sent is not ideal. Below is a patch to > do_duplicated that keeps names. Lightly tested. No doc included. I > would consider more testing and doc if there was interest. Thank you Seth for your time on this. I also think that there is value in keeping names and I agree that C code is the best place to do the fix. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Error in options(...) : invalid continue parameter
Hello! It seems that prompt and continue argument of options() must be at least of length one i.e. > options(prompt="") Error in options(...) : prompt parameter invalid > options(prompt=" ") # bla, bla, ... > options(prompt="> ") > # bla, bla, ... > options(continue="") Error in options(...) : invalid continue parameter > options(continue=" ") > ls( ) This could be properly documented as shown bellow. I do not think that it is worth bothering with modifying the code to allow empty prompt and continue argument. Cheers! Index: R/src/library/base/man/options.Rd === --- options.Rd (revision 38890) +++ options.Rd (working copy) @@ -58,7 +58,7 @@ like \code{x <- 1:3; x[5] <- 6}.} \item{\code{continue}:}{a string setting the prompt used for lines - which continue over one line.} + which continue over one line. Must be at least of length 1.} \item{\code{defaultPackages}:}{the packages that are attached by default when \R starts up. Initially set from value of the @@ -179,7 +179,7 @@ argument.} \item{\code{prompt}:}{a string, used for \R's prompt; should usually - end in a blank (\code{" "}).} + end in a blank (\code{" "}). Must be at least of length 1.} -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Small typo in list.Rd
Hello! There is a tiny typo in list.Rd. Index: R/src/library/base/man/list.Rd === --- ../man/list.Rd (revision 38909) +++ ../man/list.Rd (working copy) @@ -59,7 +59,7 @@ inconsistent with functions such as \code{\link{as.character}}, and is for efficiency since lists can be expensive to copy.) - \code{is.list} returns \code{TRUE} iff its argument + \code{is.list} returns \code{TRUE} if its argument -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Small typo in list.Rd
Hin-Tak Leung wrote: > Gregor Gorjanc wrote: >> Hello! >> >> There is a tiny typo in list.Rd. >> >> Index: R/src/library/base/man/list.Rd >> === >> --- ../man/list.Rd (revision 38909) >> +++ ../man/list.Rd (working copy) >> @@ -59,7 +59,7 @@ >>inconsistent with functions such as \code{\link{as.character}}, and is >>for efficiency since lists can be expensive to copy.) >> >> - \code{is.list} returns \code{TRUE} iff its argument >> + \code{is.list} returns \code{TRUE} if its argument >> > > Those are not typo's - (there are two "iff"'s in that paragraph). > "iff" is a short-hand for "if and only if", in some culture. OK, I did not know that and I appologize for making noise on the list for this. However, I wonder how many people know this? It is fine to have some short-hands (as IMHO, RTFM, etc. in e-mails), but these can be an obstacle for exact understanding of the documentation, specially for non-english users. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Wishlist: add mapply to lapply
Hello! mapply() could be added in see also section in lapply() help pages. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Byte size in human readable format
Dear R-core, My friend and I have written a function to convert byte size into human readable format as can be done with -h argument in say ls, df or du shell commands. I have also tried to wrap it with print method with object.size. Is there any intereset to include such a function into say utils package? Any additional comments, suggestions are more than welcome. Function and its man page can be found at http://www.bfro.uni-lj.si/MR/ggorjan/tmp/object.size.R http://www.bfro.uni-lj.si/MR/ggorjan/tmp/humanReadable.Rd -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Small "typo" in R/src/library/grDevices/man/postscript.Rd
Hello! I believe there is one "be" to much in line 198 of "R/src/library/grDevices/man/postscript.Rd": used. These fonts are be useful for other languages: ... ^^ -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] make test-Specific?
Hello! In Writing R Extensions manual, section "Testing R code"[1] says: "be careful to check if make test-Specific or particularly, cd tests; make no-segfault.Rout" Actually, make test-Specific also needs "cd tests;" in front. [1]http://cran.r-project.org/doc/manuals/R-exts.html#Testing-R-code -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Summary() fails after use of na.action="na.exclude" in lm() (PR#9191)
Hello! I have already reported on this behaviour at [1] and now I have checked the same example on r-devel and the problem is still there. Thomas Lumley inidicated problem [2]. Example: n <- 50 x <- runif(n=n) y1 <- 2 * x + rnorm(n=n) y2 <- 5 * x + rnorm(n=n) y2[sample(1:n, size=5)] <- NA y <- cbind(y1, y2) ## Goes ok here fit <- lm(y1 ~ 1, na.action="na.exclude") summary(fit) ## And here fit <- lm(y2 ~ 1, na.action="na.exclude") summary(fit) ## But fails if we use matrix of response variables fit <- lm(y ~ 1, na.action="na.exclude") summary(fit) Response y1 : Call: lm(formula = y1 ~ 1, na.action = "na.exclude") Residuals: Error in quantile.default(resid) : missing values and NaN's not allowed if 'na.rm' is FALSE [1]http://tolstoy.newcastle.edu.au/R/devel/06/07/6187.html [2]http://tolstoy.newcastle.edu.au/R/devel/06/07/6203.html --please do not edit the information below-- Version: platform = i686-pc-linux-gnu arch = i686 os = linux-gnu system = i686, linux-gnu status = Under development (unstable) major = 2 minor = 4.0 year = 2006 month = 08 day = 30 svn rev = 39022 language = R version.string = R version 2.4.0 Under development (unstable) (2006-08-30 r39022) Locale: LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C Search Path: .GlobalEnv, package:methods, package:stats, package:graphics, package:grDevices, package:utils, package:datasets, Autoloads, package:base -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Wish: keep names in mapply() result
Hello! I have noticed that mapply() drops names in R 2.3.1 as well as in r-devel. Here is a simple example: l <- list(a=1, b=2) k <- list(1) mapply(FUN="+", l, k) [1] 2 3 mapply(FUN="+", l, k, SIMPLIFY=FALSE) [[1]] [1] 2 [[2]] [1] 3 Help page does not indicate that this should happen. Argument USE.NAMES does not have any effect here as it used only in a bit special situation: "If the first ... argument is character and the result does not already have names, use it as the names." But result is always without names as shown above. Did I miss any peculiarities? This is not consistent with lapply, which keeps names i.e. lapply(l, "+", 1) $a [1] 2 $b [1] 3 I have attached and copied (at the end) patch proposal against SVN that adds names back to the result if x had it (only R as my C is ...). This way it would also be consistent with lapply. make check-all seems to be happy with changes. Now we get: mapply(FUN="+", l, k) a b 2 3 mapply(FUN="+", l, k, SIMPLIFY=FALSE) $a [1] 2 $b [1] 3 And if we had "character" (with some variations) for first ... then: l <- list(a="1", b="2") mapply(FUN="paste", l, k) a b "1 1" "2 1" l <- list("1", "2") mapply(FUN="paste", l, k) [1] "1 1" "2 1" l <- c("1", "2") mapply(FUN="paste", l, k) 1 2 "1 1" "2 1" Index: src/library/base/R/mapply.R === --- src/library/base/R/mapply.R (revision 39024) +++ src/library/base/R/mapply.R (working copy) @@ -3,8 +3,16 @@ FUN <- match.fun(FUN) dots <- list(...) +if(!is.null(names(dots[[1]]))) { +isNamed <- TRUE +namesX <- names(dots[[1]]) +} else { +isNamed <- FALSE +} + answer<-.Call("do_mapply", FUN, dots, MoreArgs, environment(), PACKAGE="base") +if(isNamed) names(answer) <- namesX if (USE.NAMES && length(dots) && is.character(dots[[1]]) && is.null(names(answer))) names(answer) <- dots[[1]] @@ -47,4 +55,4 @@ } formals(FUNV) <- formals(FUN) FUNV -} \ No newline at end of file +} -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. -- Index: src/library/base/R/mapply.R === --- src/library/base/R/mapply.R (revision 39024) +++ src/library/base/R/mapply.R (working copy) @@ -3,8 +3,16 @@ FUN <- match.fun(FUN) dots <- list(...) +if(!is.null(names(dots[[1]]))) { +isNamed <- TRUE +namesX <- names(dots[[1]]) +} else { +isNamed <- FALSE +} + answer<-.Call("do_mapply", FUN, dots, MoreArgs, environment(), PACKAGE="base") +if(isNamed) names(answer) <- namesX if (USE.NAMES && length(dots) && is.character(dots[[1]]) && is.null(names(answer))) names(answer) <- dots[[1]] @@ -47,4 +55,4 @@ } formals(FUNV) <- formals(FUN) FUNV -} \ No newline at end of file +} __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Wish: keep names in mapply() result
Hello, Charles Berry sent me (off-list) his proposal, which I find better (after slight modification) than mine. I would say that proposed changes make mapply even more consistent with (some) *apply* funcs in terms of names. Patches to mapply.R and mapply.Rd are attached. I have runned make check-all and it seems that there are no problems with this change. I hope R core will find this worth to apply. New behaviour without first ... as character: l <- list(a=1, b=2) k <- list(1) mapply(FUN="+", l, k) a b 2 3 mapply(FUN="+", l, k, USE.NAMES=FALSE) [1] 2 3 mapply(FUN="+", l, k, SIMPLIFY=FALSE) $a [1] 2 $b [1] 3 mapply(FUN="+", l, k, SIMPLIFY=FALSE, USE.NAMES=FALSE) [[1]] [1] 2 [[2]] [1] 3 New behaviour with first ... as character _with_ names: l <- c("1", "2") names(l) <- c("a", "b") mapply(FUN="paste", l, k) a b "1 1" "2 1" mapply(FUN="paste", l, k, USE.NAMES=FALSE) [1] "1 1" "2 1" mapply(FUN="paste", l, k, SIMPLIFY=FALSE) $a [1] "1 1" $b [1] "2 1" mapply(FUN="paste", l, k, SIMPLIFY=FALSE, USE.NAMES=FALSE) [[1]] [1] "1 1" [[2]] [1] "2 1" New behaviour with first ... as character _without_ names: l <- c("1", "2") mapply(FUN="paste", l, k) 1 2 "1 1" "2 1" mapply(FUN="paste", l, k, USE.NAMES=FALSE) [1] "1 1" "2 1" mapply(FUN="paste", l, k, SIMPLIFY=FALSE) $`1` [1] "1 1" $`2` [1] "2 1" mapply(FUN="paste", l, k, SIMPLIFY=FALSE, USE.NAMES=FALSE) [[1]] [1] "1 1" [[2]] [1] "2 1" Regards, Gregor Gregor Gorjanc wrote: > Hello! > > I have noticed that mapply() drops names in R 2.3.1 as well as in > r-devel. Here is a simple example: > > l <- list(a=1, b=2) > k <- list(1) > mapply(FUN="+", l, k) > [1] 2 3 > mapply(FUN="+", l, k, SIMPLIFY=FALSE) > [[1]] > [1] 2 > > [[2]] > [1] 3 > > Help page does not indicate that this should happen. Argument USE.NAMES > does not have any effect here as it used only in a bit special > situation: "If the first ... argument is character and the result does > not already have names, use it as the names." But result is always > without names as shown above. Did I miss any peculiarities? > > This is not consistent with lapply, which keeps names i.e. > > lapply(l, "+", 1) > $a > [1] 2 > > $b > [1] 3 > > I have attached and copied (at the end) patch proposal against SVN that > adds names back to the result if x had it (only R as my C is ...). This > way it would also be consistent with lapply. make check-all seems to be > happy with changes. Now we get: > > mapply(FUN="+", l, k) > a b > 2 3 > > mapply(FUN="+", l, k, SIMPLIFY=FALSE) > $a > [1] 2 > > $b > [1] 3 > > And if we had "character" (with some variations) for first ... then: > > l <- list(a="1", b="2") > mapply(FUN="paste", l, k) > a b > "1 1" "2 1" > > l <- list("1", "2") > mapply(FUN="paste", l, k) > [1] "1 1" "2 1" > > l <- c("1", "2") > mapply(FUN="paste", l, k) > 1 2 > "1 1" "2 1" > > Index: src/library/base/R/mapply.R > === > --- src/library/base/R/mapply.R (revision 39024) > +++ src/library/base/R/mapply.R (working copy) > @@ -3,8 +3,16 @@ > FUN <- match.fun(FUN) > dots <- list(...) > > +if(!is.null(names(dots[[1]]))) { > +isNamed <- TRUE > +namesX <- names(dots[[1]]) > +} else { > +isNamed <- FALSE > +} > + > answer<-.Call("do_mapply", FUN, dots, MoreArgs, environment(), >PACKAGE="base") > +if(isNamed) names(answer) <- namesX > > if (USE.NAMES && length(dots) && is.character(dots[[1]]) && > is.null(names(answer))) names(answer) <- dots[[1]] > @@ -47,4 +55,4 @@ > } > formals(FUNV) <- formals(FUN) > FUNV > -} > \ No newline at end of file > +} > > > > > > Index: src/library/base/R/mapply.R > === > --- src/library/base/R/mapply.R (revision 39024) > +++ src/library/base/R/mapply.R (working copy) > @@ -3,8 +3,16 @@ > FUN <- match.fun(FUN) > dots <- list(...) > > +if(!is.null(names(dots[[1]]))) { > +isNamed <- TRUE > +namesX <- names(dots[[1]]) > +} else { > +isNamed <- FALSE > +} > + > answer<-.Call("do_mapply", FUN, dots, MoreArgs, environment(), >PACKAGE="base") > +if(isNamed) names(answer) <- namesX > > if (USE.NAMES && length(dots) && is.character(dots[[1]]) && > is.null(names(answer))) names(answer) <- dots[[1]] > @@ -47,4 +55,4 @@ > } > formals(FUNV) <- formals(FUN) > FUNV > -} > \ No newline at end of file > +} mapply.R.patch.gz Description: GNU Zip compressed data mapply.Rd.patch.gz Description: GNU Zip compressed data __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] [<-.POSIXlt changes order of attributes (PR#9197)
This is a multi-part message in MIME format. --090203020600020104020707 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hello! I was doing some tests with identical() and found out that [<-.POSIXlt method changes order of attributes. This example shows that: x <- strptime("1900-1-1", format="%Y-%m-%d") x <- c(x) y <- c(x, x+1) x1 <- x y1 <- y attributes(x) $names [1] "sec" "min" "hour" "mday" "mon" "year" "wday" "yday" "isdst" $class [1] "POSIXt" "POSIXlt" $tzone [1] "" "CET" "CEST" identical(attributes(x), attributes(y)) TRUE x[1] <- NA attributes(x) $names [1] "sec" "min" "hour" "mday" "mon" "year" "wday" "yday" "isdst" $tzone [1] "" "CET" "CEST" $class [1] "POSIXt" "POSIXlt" y[1] <- NA attributes(y) $names [1] "sec" "min" "hour" "mday" "mon" "year" "wday" "yday" "isdst" $tzone [1] "" "CET" "CEST" $class [1] "POSIXt" "POSIXlt" identical(attributes(x), attributes(x1)) FALSE identical(attributes(y), attributes(y1)) FALSE This can be solved with either: Index: R/src/library/base/R/datetime.R === --- R/src/library/base/R/datetime.R (revision 39045) +++ R/src/library/base/R/datetime.R (working copy) @@ -713,10 +713,10 @@ { if(!as.logical(length(value))) return(x) value <- as.POSIXlt(value) -cl <- oldClass(x) +att <- attributes(x) class(x) <- class(value) <- NULL for(n in names(x)) x[[n]][i] <- value[[n]] -class(x) <- cl +attributes(x) <- att x } or in the same way as it is done in [.<-POSIXct method Index: R/src/library/base/R/datetime.R === --- R/src/library/base/R/datetime.R (revision 39045) +++ R/src/library/base/R/datetime.R (working copy) @@ -714,9 +714,11 @@ if(!as.logical(length(value))) return(x) value <- as.POSIXlt(value) cl <- oldClass(x) +tz <- attr(x, "tzone") class(x) <- class(value) <- NULL for(n in names(x)) x[[n]][i] <- value[[n]] class(x) <- cl +attr(x, "tzone") <- tz x } I have checked both versions in r-devel with make check-all and all went fine. Regards, Gregor -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. -- --090203020600020104020707 Content-Type: application/x-gzip; name="datetime.R.patchVer1.gz" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="datetime.R.patchVer1.gz" H4sICH7v90QCA2RhdGV0aW1lLlIucGF0Y2hWZXIxAKVOz0vDMBQ+m7/ieUvosmxMGYpCwdNg qFSEQekhTbMazBJJ0tkh/u+atE5vO/guyft+vW9lGtlfQ8G8E0yr2nF3YDX3khWs4UEGtZPT At3+fxCl9NSdM+zkXnllDSyuZheXBGVZdtr0bt2rMi0I+3YgKM+BLueLyXwG2fjmOYIPBHHU Fp9zP9W2VYJrrKVpwwvec91JQgg4GTpncE8GdcLhhsK35fHhabXRYdQiGnmhI2l1c6e599GW RZiHkEwhOFV3QfpjoBh1kR7+Q1zc75/X60G1tQ4bUAYM3yUzgb4sTVWVqorK5EnAT42/qccO v8fHNkN6j+ATAfoCTtG/r/sBAAA= --090203020600020104020707 Content-Type: application/x-gzip; name="datetime.R.patchVer2.gz" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="datetime.R.patchVer2.gz" H4sICCXw90QCA2RhdGV0aW1lLlIucGF0Y2hWZXIyAKWOwUoDMRCGz+Ypxp4S0jQuVqSisOCp UFRWBGHZQ7qbrsE0kSSt6YLvrtmIBxF6cC5J/vm+mSxNJ+MVVNy7lmu1dsId+Fp4ySveiSCD 2spZhW7+X4gxdmzPCXZyr7yyBs4XZ/MLgiilx6V3616V6aG1bweCyhLYZTGfLoCmoyigLBGk Uht8KvxM2161QmMtTR9e8F7onSSEgJNh5wyOJNNjDtcMvpSH+8flsw7fbO63OjWt7m618D5p NMVhGJ0QHI5TmITBGjn5UTKZiHzPA9P77mm1ytTGOmxAGTBiKxNOINa1aZpaNYkcnTH4a2r+ xe/9qReGzEcEHwjQJ/Ktnoj7AQAA --090203020600020104020707-- __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [<-.POSIXlt changes order of attributes (PR#9197)
Hello, Prof Brian Ripley wrote: > Please point us to the documentation that says attributes are ordered. > E.g. R-lang.texi says > > All objects except @code{NULL} can have one or more attributes attached > to them. Attributes are stored as a list where all elements are named. > > (although in fact they are stored in a pairlist). > > I know of tens of functions that change the order of attributes, and > did look at teaching identical() that they are not ordered. But > since they are stored as a pairlist, it would be quite expensive. I agree that there is no need for attributes to be always in the same order as this is tedious to achieve as you noted above, but identical() seems to care about this. > (Given that attributes seem to be growing in use, another internal storage > mechanism is becoming more appropriate.) Which internal storage mechanism are you talking about here? > BTW, all.equal() does not assume attributes are ordered. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [<-.POSIXlt changes order of attributes (PR#9197)
Hello, Prof Brian Ripley wrote: > There is a bug in identical(), though: > >> identical(pairlist(a=1, b=2), pairlist(a=1, aa=2)) > [1] TRUE >> identical(structure(pi, a=1, b=2), structure(pi,a=1, aa=2)) > [1] TRUE > > so identical() is not even looking at the names of the attributes but only > checking their values. Oops Aha, so this is the problem then. Thank you for tracking down the problem! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R Citation through time
Hello! I keep my local bib file and up to now I had entry @Manual{R:2003, title = {R: A Language and Environment for Statistical Computing}, author = {{R Development Core Team}}, organization = {R Foundation for Statistical Computing}, address = {Vienna, Austria}, year = {2005}, note = {{ISBN} 3-900051-00-3}, url = {http://www.R-project.org}, } With recent versions ISBN changed to 3-900051-07-0. Now I wonder if there is any canonical way to refer to R without the need to change R entry over and over. It would probably be the best just to add new entry for "new version" for R. Now the question is what is new version or when does ISBN number change? Thanks. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R Citation through time
Friedrich Leisch wrote: >>>>>> On Tue, 12 Sep 2006 07:53:52 +0200, >>>>>> Gregor Gorjanc (GG) wrote: > > > Hello! > > I keep my local bib file and up to now I had entry > > > @Manual{R:2003, > > title = {R: A Language and Environment for Statistical Computing}, > > author = {{R Development Core Team}}, > > organization = {R Foundation for Statistical Computing}, > > address = {Vienna, Austria}, > > year = {2005}, > > note = {{ISBN} 3-900051-00-3}, > > url = {http://www.R-project.org}, > > } > > > With recent versions ISBN changed to 3-900051-07-0. > > It changed with 2.0.0, which is not that recent ... > > > Now I wonder if there is any canonical way to refer to R without > > the need to change R entry over and over. It would probably be the > > best just to add new entry for "new version" for R. Now the > > question is what is new version or when does ISBN number change? > > The ISBN changes with every major version of R, i.e., it will change > next when 3.0.0 is released. We are already stretching the ISBN rules > to the limit (on the no-change-side) with that policy, and the > reason is exactly to make the reference more stable. But with a major > release we really need to assign a new ISBN. Thank you for this clarifications. As indicated ISBN is not changing very often and I can live with couple of BibTeX entries for R. Thanks! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R Citation through time
Ioannis Dimakos wrote: > Forgive me for being naive, > > but I have not seen any reference where the ISBN was required. The apa > style that I use does not require the ISBN. > > Best, > > Ioannis You can put that part in note field as it is done in output of citation() function. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Error: package/namespace load failed for 'fortunes'
Hello! I have the following R code in my .Rprofile file - just for fun. library(fortunes) fortune() detach("package:fortunes") This works nicely in R 2.3.1, but it throws the following error under latest R-devel: ... ... Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. Error in rbind(rval, read.table(file, header = TRUE, sep = ";", quote = "\"", : could not find function "read.table" Error: .onLoad failed in 'loadNamespace' for 'fortunes' Error: package/namespace load failed for 'fortunes' > If I start R-devel with empty .Rprofile I am able to issue above R code without problems. Is this caused by move of read.table() to utils package? -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] [Fwd: Byte size in human readable format]
Hello, I have looked once more into this issue and used options() approach with (yet another :() option - humanReadable. This is the behaviour in R-devel. > object.size(1000) [1] 32 > c(object.size(1000), object.size(1:1000), object.size(1:100)) [1] 324024 424 > options(humanReadable=TRUE) > object.size(1000) [1] 32 B > c(object.size(1000), object.size(1:1000), object.size(1:100)) [1] 32 B 4 kB 4 MB I am not very satisfied with the class approach I have taken as a lot of functions in R drop class attribute, say > sort(c(object.size(1:1000), object.size(1000)) ) [1] 32 4024 Is it possible to bypass this without writing special methods for "byte" class. I would appreciate any comments, suggestion. Thanks! Patches are available at: http://www.bfro.uni-lj.si/MR/ggorjan/tmp/object.size.R.patch http://www.bfro.uni-lj.si/MR/ggorjan/tmp/object.size.Rd.patch http://www.bfro.uni-lj.si/MR/ggorjan/tmp/NAMESPACE.patch http://www.bfro.uni-lj.si/MR/ggorjan/tmp/humanReadable.Rd Original Message Subject: Byte size in human readable format Date: Mon, 21 Aug 2006 14:14:52 +0200 From: Gregor Gorjanc <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] Organization: University of Ljubljana To: r-devel@r-project.org CC: Ales Korosec <[EMAIL PROTECTED]> Dear R-core, My friend and I have written a function to convert byte size into human readable format as can be done with -h argument in say ls, df or du shell commands. I have also tried to wrap it with print method with object.size. Is there any intereset to include such a function into say utils package? Any additional comments, suggestions are more than welcome. Function and its man page can be found at http://www.bfro.uni-lj.si/MR/ggorjan/tmp/object.size.R http://www.bfro.uni-lj.si/MR/ggorjan/tmp/humanReadable.Rd -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] R-devel: rownames of a data.frame
Hello! Data.frames have new rownames funcionality, however in use of colnames<- in R-devel "changes" this. Here is the example: > df1 <- data.frame(letters[1:5]) > attributes(df1) $names [1] "letters.1.5." $row.names [1] 1 2 3 4 5 $class [1] "data.frame" > colnames(df1) <- "bla" > attributes(df1) $names [1] "bla" $row.names [1] "1" "2" "3" "4" "5" $class [1] "data.frame" ?rownames/colnames help page (R-devel) says that value is coerced to character, but why are rownames coerced to character if I assign colnames to a data.frame? -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Using \u2030 in plot axis label -> stack smashing
Gavin Simpson ucl.ac.uk> writes: > > Dear List > > I just noticed the following behaviour in R 2.3.1 Patched (2006-06-13 > r38342) and confirmed similar behaviour in R 2.4.0 alpha (2006-09-18 > r39383) & R 2.5.0 (2006-09-18 r39383) - which may actually be the same > thing?, that trying to plot the unicode character \u2030 (which should > be in a ‰ [per mille] sign) in an axis label leads to the following > error: > > *** stack smashing detected ***: /home/gavin/R/R-devel/build/bin/exec/R > terminated > Aborted > > The simplest, reproducible example I have tried is: > > plot(1:10, ylab = "\u2030") > I can not reproduce this on my Debian GNU/Linux. I get something like "S for y label under 2.3.1 2006-06-01 and 2.5.0 2006-09-13 r39292 with the following locale [1] "LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8; LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8; LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C; LC_IDENTIFICATION=C" It does not change if I set everything into en_GB.UTF-8. Is this valid unicode code? Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Using \u2030 in plot axis label -> stack smashing
Gavin Simpson wrote: > On Mon, 2006-09-18 at 19:02 +0000, Gregor Gorjanc wrote: >> Gavin Simpson ucl.ac.uk> writes: >>> Dear List >>> >>> I just noticed the following behaviour in R 2.3.1 Patched (2006-06-13 >>> r38342) and confirmed similar behaviour in R 2.4.0 alpha (2006-09-18 >>> r39383) & R 2.5.0 (2006-09-18 r39383) - which may actually be the same >>> thing?, that trying to plot the unicode character \u2030 (which should >>> be in a ‰ [per mille] sign) in an axis label leads to the following >>> error: >>> >>> *** stack smashing detected ***: /home/gavin/R/R-devel/build/bin/exec/R >>> terminated >>> Aborted >>> >>> The simplest, reproducible example I have tried is: >>> >>> plot(1:10, ylab = "\u2030") >>> >> I can not reproduce this on my Debian GNU/Linux. I get something like "S >> for y label under 2.3.1 2006-06-01 and 2.5.0 2006-09-13 r39292 with the >> following locale >> >> [1] "LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8; >> LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8; >> LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C; >> LC_IDENTIFICATION=C" >> >> It does not change if I set everything into en_GB.UTF-8. Is this valid >> unicode code? >> >> Gregor > > Cheers for the follow up Gregor, > > I was following advice given by Prof. Ripley in a posting on R-Help > about how to get the per mille character: > > http://finzi.psych.upenn.edu/R/Rhelp02a/archive/48709.html > > It should look like a "%" character but with two circles at the bottom. Perhaps I do not have appropriate font for this character. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Help for methods
Hin-Tak Leung cimr.cam.ac.uk> writes: > > You are supposed to do: > > ?summary.lm > ?summary.data.frame > > for S3 methods. The former works, the latter doesn't - which is > probably considered a bug, but then the usage of some of the I do not follow this. When I type ?summary.data.frame I get a summary help page where I can also find info about S3 method for class 'data.frame'. If I am not wrong it is \alias{summary.data.frame} that takes care of this. > generics are probably considered obvious and fundamental enough > that summary.data.frame doesn't really behave in any substantially > different way compared to what is said in ?summary and ?Summary . > ... Regards, Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] na.encode in format for Date and POSIXt classes
Hello! na.encode does not have any effect on format of NA values of Date and POSIXct (POSIXlt?) "atomic" classes in a data.frame. Here is the example (the same in R 2.3.1 and 2.5.0 (2006-09-19 r39409)): testData <- data.frame(num=c(NA, 2.6), int=c(1, NA), fac=factor(c(NA, "abc")), cha=c("a", NA), dat=as.Date(c("1900-1-1", NA)), POS=as.POSIXct(strptime(c("1900-1-1 01:01:01", NA), format="%Y-%m-%d %H:%M:%S"))) testData$cha <- as.character(testData$cha) testData num int fac chadat POS 1 NA 1 a 1900-01-01 1900-01-01 01:01:01 2 2.6 NA abc format(testData) num int fac chadat POS 1 NA 1 NA a 1900-01-01 1900-01-01 01:01:01 2 2.6 NA abc NA format(testData, na.encode=FALSE) num int fac chadat POS 1 NA 1 a 1900-01-01 1900-01-01 01:01:01 2 2.6 NA abc format(testData, na.encode=TRUE) num int fac chadat POS 1 NA 1 NA a 1900-01-01 1900-01-01 01:01:01 2 2.6 NA abc NA After a brief look into format.data.frame, format.POSIXct and format.POSIXlt I notice that na.encode is not used at all in (last line of format.POSIXlt) .Internal(format.POSIXlt(x, format, usetz)) but I get lost from this point forward. I guess that the same applies to format.Date as this coerces Date to POSIXlt before formatting. Additionally, I would suggest change in format help page for argument na.encode. It says now na.encode: logical: should 'NA' strings be encoded? If I am not wrong, this applies only to non-numeric columns. Something like the following might be more accurate: na.encode: logical: should 'NA' strings be encoded (applies only to non-numeric)? -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Wish: change behaviour of header in read.fwf (PR#9252)
Hello! In my opinion read.fwf()'s behaviour of header is not really useful. Say I have the following data: col1 col2 col3 123 123 123 a b 123412 1234 65.4 4.5 Now if I want to read this data into R I can not use read.table due to missing fields. read.table(file="test.txt") Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : line 3 did not have 3 elements However, read.fwf() can help me. read.fwf(file="test.txt", widths=c(5, 6, 5)) V1 V2V3 1 col1 col2 col3 2 123123123 3a b 4 1234 12 1234 565.44.5 Upps, I need to specify header and help page says that header fields must be separated by sep. sep part of help page says sep: character; the separator used internally; should be a character that does not occur in the file (except in the header). This is quite limiting because I never know in advance which characters do not occur in a datafile and if I do, I have to properly modify header in the file before import. Naive use of read.fwf returns an error read.fwf(file="test.txt", widths=c(5, 6, 5), header=TRUE, sep=" ") Error in read.table(file = FILE, header = header, sep = sep, as.is = as.is, : more columns than column names read.fwf(file="test.txt", widths=c(5, 6, 5), header=TRUE, sep=" ") Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, : invalid 'sep' value: must be one byte I get lost in reading source of read.fwf, but I think that the following idea should be easy to implement and it would be also similar to read.table behaviour. if(header) { ## sep is from read.fwf call header <- unlist(strsplit(readLines(con=file, n=1), split=sep)) } ... ## tweaks related to issues with length(header), row.names, ncol(), ... read.table(..., col.names=header, ...) I know that FWF is not used much these days, but I would find proposed change really useful. -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] [R] read.fwf and header
Marc Schwartz wrote: > On Mon, 2006-10-30 at 19:51 +0100, Gregor Gorjanc wrote: >> Hi! >> >> I have data (also in attached file) in the following form: >> >> num1 num2 num3 int1 fac1 fac2 cha1 cha2 Date POSIXt >> 11 f q 1900-01-01 1900-01-01 01:01:01 >> 2 1.0 131.5 2 a g r z1900-01-01 01:01:01 >> 3 1.5 1188830.5 3 b h s y 1900-01-01 1900-01-01 01:01:01 >> 4 2.0 1271846.3 4 c i t x 1900-01-01 1900-01-01 01:01:01 >> 5 2.5 829737.4d j u w 1900-01-01 >> 6 3.0 1240967.3 5 e k v v 1900-01-01 1900-01-01 01:01:01 >> 7 3.5 919684.4 6 f l w u 1900-01-01 1900-01-01 01:01:01 >> 8 4.0 968214.6 7 g m x t 1900-01-01 1900-01-01 01:01:01 >> 9 4.5 1232076.4 8 h n y s 1900-01-01 1900-01-01 01:01:01 >> 10 5.0 1141273.4 9 i o z r 1900-01-01 1900-01-01 01:01:01 >>5.5 988481.4 10 j q 1900-01-01 1900-01-01 01:01:01 >> >> This is a FWF (fixed width format) file. I can not use read.table here, >> because of missing values. I have tried with the following >> >>> read.fwf(file="test.txt", widths=c(3, 4, 10, 3, 2, 2, 2, 2, 11, 20), >> header=TRUE) >> >> Error in read.table(file = FILE, header = header, sep = sep, as.is = >> as.is, : >> more columns than column names >> >> I could use: >> >>> read.fwf(file="test.txt", widths=c(3, 4, 10, 3, 2, 2, 2, 2, 11, 20), >> header=FALSE, skip=1) >>V1 V2V3 V4 V5 V6 V7 V8 V9 V10 >> 1 1 NANA 1f q 1900-01-01 1900-01-01 01:01:01 >> 2 2 1.0 131.5 2 a g r z 1900-01-01 01:01:01 >> 3 3 1.5 1188830.5 3 b h s y 1900-01-01 1900-01-01 01:01:01 >> 4 4 2.0 1271846.3 4 c i t x 1900-01-01 1900-01-01 01:01:01 >> 5 5 2.5 829737.4 NA d j u w 1900-01-01 >> 6 6 3.0 1240967.3 5 e k v v 1900-01-01 1900-01-01 01:01:01 >> 7 7 3.5 919684.4 6 f l w u 1900-01-01 1900-01-01 01:01:01 >> 8 8 4.0 968214.6 7 g m x t 1900-01-01 1900-01-01 01:01:01 >> 9 9 4.5 1232076.4 8 h n y s 1900-01-01 1900-01-01 01:01:01 >> 10 10 5.0 1141273.4 9 i o z r 1900-01-01 1900-01-01 01:01:01 >> 11 NA 5.5 988481.4 10 jq 1900-01-01 1900-01-01 01:01:01 >> >> Does anyone have a clue, how to get above result with header? >> >> Thanks! > > The attachment did not come through. Perhaps it was too large? > > Not sure if this is the most efficient way, but how about this: > > DF <- read.fwf("test.txt", > widths=c(3, 4, 10, 3, 2, 2, 2, 2, 11, 20), > skip = 1, strip.white = TRUE, > col.names = read.table("test.txt", >nrow = 1, as.is = TRUE)[1, ]) > Argh, my fault as I forgot to attach it :( > Not sure if this is the most efficient way, but how about this: > > DF <- read.fwf("test.txt", > widths=c(3, 4, 10, 3, 2, 2, 2, 2, 11, 20), > skip = 1, strip.white = TRUE, > col.names = read.table("test.txt", >nrow = 1, as.is = TRUE)[1, ]) > That is a very nice compromise! No need for [1, ], due to nrow=1. > Of course, with the limited number of columns, you can always just set > > colnames(DF) <- c("num1", "num2", "num3", "int1", "fac1", > "fac2", "cha1", "cha2", "Date", "POSIXt") > I fully agree here, but I kind of lack this directly in read.fwf. I hope that someone from R-core is also listening to this ;) Thank you! Gregor num1 num2 num3 int1 fac1 fac2 cha1 cha2 Date POSIXt 11 f q 1900-01-01 1900-01-01 01:01:01 2 1.0 131.5 2 a g r z1900-01-01 01:01:01 3 1.5 1188830.5 3 b h s y 1900-01-01 1900-01-01 01:01:01 4 2.0 1271846.3 4 c i t x 1900-01-01 1900-01-01 01:01:01 5 2.5 829737.4d j u w 1900-01-01 6 3.0 1240967.3 5 e k v v 1900-01-01 1900-01-01 01:01:01 7 3.5 919684.4 6 f l w u 1900-01-01 1900-01-01 01:01:01 8 4.0 968214.6 7 g m x t 1900-01-01 1900-01-01 01:01:01 9 4.5 1232076.4 8 h n y s 1900-01-01 1900-01-01 01:01:01 10 5.0 1141273.4 9 i o z r 1900-01-01 1900-01-01 01:01:01 5.5 988481.4 10 j q 1900-01-01 1900-01-01 01:01:01 __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] How to put my class into data.frame
Hello! I am developing a composition class, which represents a composition of mixture of levels, say soil has three components and each component accounts for 1/3 of the unit. I have tried with S4 class system and I would appreciate any help here. I was hoping that I would be able to include instance of my class into a data.frame. However, I encounter problems. Simple definition of class could be setClass(Class="composition", representation=representation(ratios="matrix")) n <- 2 k <- 3 x <- new(Class="composition", ratios=matrix(data=rep(x=1/3, times=n*k), nrow=n, ncol=k)) x An object of class "composition" Slot "ratios": [,1] [,2] [,3] [1,] 0.333 0.333 0.333 [2,] 0.333 0.333 0.333 tmp <- data.frame(id=1:2) tmp$comp <- x Error: object is not subsettable As I understand this, my problem is that x is of length 1 as the following works tmp$comp <- c(x, x) although I am not able to print tmp now tmp Error in unlist(x, recursive, use.names) : argument not a list but this is expected as I (probably) need show/print method for this. How can I put my class into data.frame or how can I make my class behave as a vector? Thanks! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] How to put my class into data.frame
Ferdinand Alimadhi wrote: > tmp$comp <- [EMAIL PROTECTED] ?! I "lose" class here and that is not what I want. Perhaps I should stick with list instead of data.frame. > Gregor Gorjanc wrote: > >> Hello! >> >> I am developing a composition class, which represents a composition of >> mixture of levels, say soil has three components and each component >> accounts for 1/3 of the unit. I have tried with S4 class system and I >> would appreciate any help here. I was hoping that I would be able to >> include instance of my class into a data.frame. However, I encounter >> problems. >> >> Simple definition of class could be >> >> setClass(Class="composition", >> representation=representation(ratios="matrix")) >> >> n <- 2 >> k <- 3 >> >> x <- new(Class="composition", ratios=matrix(data=rep(x=1/3, times=n*k), >> nrow=n, ncol=k)) >> >> x >> An object of class "composition" >> Slot "ratios": >> [,1] [,2] [,3] >> [1,] 0.333 0.333 0.333 >> [2,] 0.333 0.333 0.333 >> >> tmp <- data.frame(id=1:2) >> tmp$comp <- x >> Error: object is not subsettable >> >> As I understand this, my problem is that x is of length 1 as the >> following works >> >> tmp$comp <- c(x, x) >> >> although I am not able to print tmp now >> >> tmp >> Error in unlist(x, recursive, use.names) : >> argument not a list >> >> but this is expected as I (probably) need show/print method for this. >> How can I put my class into data.frame or how can I make my class behave >> as a vector? >> >> Thanks! -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] How to put my S4 class into data.frame
Hi, Martin Maechler wrote: >>>>>> "Gregor" == Gregor Gorjanc <[EMAIL PROTECTED]> >>>>>> on Sat, 04 Nov 2006 02:09:13 +0100 writes: > > Gregor> Ferdinand Alimadhi wrote: > > >> tmp$comp <- [EMAIL PROTECTED] ?! > > Gregor> I "lose" class here and that is not what I > Gregor> want. Perhaps I should stick with list instead of > Gregor> data.frame. > > Yes, I probably would, at least for the time being. OK. Why do you say "at least for the time being"? Are there any plans to generalize putting S4 classes that are not atomic into data.frame? > OTOH, it's interesting that some methods to "stick some S4 > objects into a data frame do work fine , at least for the > following case (R-script below) -- and I wonder if we (R developers) > shouldn't think about more explicitly supporting this, > e.g., by stating something like > > >> If an S4 object simply *contains* an atomic class that can be > >> used as data.frame column, then that S4 object can also be used > >> as data.frame column > Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] How to put my S4 class into data.frame
John Chambers wrote: > Designing a "better data frame" is something many people have likely > thought about; I certainly have. > > But data frames are so widely used and so central to models and other > software that a major change needs to be done by the user community, or > at least with maximum feedback, IMO. > > Also, my prior feeling would be that it's better to think of an S4 class > to play the role of data.frame, rather than tinkering with the S3 class > to allow S4 columns. Having formal classes (particularly using class > unions to abstract notions about variables in the data frame) lets one > create a more precise and reliable definition. > > It's true, though, that one then has to work out the details of > interfacing the S4 data frame class to current software that works with > the S3 data.frame class. AFAICS that is not too hard, but of course the > details would be important. > > I've played around with some of these ideas, more as educational aids in > discussing classes and methods than as a serious proposal. Last time I > looked, the writeup was not at a level I would feel happy circulating > :-} But perhaps a group of interested people could exchange some ideas. As far as I see this (at the risk of uterly simplifying the issue) new data.frame (perhaps dataFrame) could just be a list? of classes that have the same length i.e. length() should have the same value. Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] c() for factors
Dear R-core! I have written a function mapLevels() to map levels of a factor. It can produce a map (internally a list) of factor levels and internal integer codes. I call this integer levelsMap. There is also character levelsMap, but not of importance at this moment. I found out that it was quite straightforward to write c() method for factors with use of mapLevels() and Iam asking here if there is any interest to include this into base R. In base R c() on two factors coerces to internal integer codes > f1 <- factor(c("A", "B")) > f2 <- factor(c("A", "C")) > f1 [1] A B Levels: A B > f2 [1] A C Levels: A C > c(f1, f2) [1] 1 2 1 2 or character vector if one of arguments is character c(as.character(f1), f2) [1] "A" "B" "1" "2" this is OK, but not really wanted by the user. Code bellow show my implementation of c.factor(). For the moment mapLevels() and c.factor() live in gdata package (from version 2.3.1) - it has ben submitted to CRAN last night. > install.packages("gdata") > library(gdata) ## c.factor is not exported > gdata:::c.factor(f1, f2) [1] A B A C Levels: A B C > gdata:::c.factor(as.character(f1), f2) [1] A B A C Levels: A B C > gdata:::c.factor(f1, as.character(f2)) [1] A B A C Levels: A B C > gdata:::c.factor(as.integer(f1), f2) Error in mapLevels.default(X[[1]], ...) : mapLevels can only be used on “factor” and “character” atomic 'x' As can be seen characters are handled in the same way as factors. Does anyone see any value in this? -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Typo in save help page
Hi, Save help page, section Warnings, last paragraph, 3rd row, 1st word in a row: conpatible ^ should be compatible Regards, Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Wish: add link to Date in date help page
Hello! Could someone add Date to see also links in date help page i.e. the following code in ./src/library/base/man/date.Rd \seealso{ \code{\link{Sys.time}} and \code{\link{Date}} } I always fire ?date instead of ?Date and I guess a lot of useRs also get lost in search for the right help pages about date-time classes. Btw. Perhaps article from RNews about datetime classes by Gabor and Thomas could also be added to "all?" date-time help pages. That article really rocks and I guess it would help a lot to provide link from help pages. This is not the first wish about this issue. I can provide patches if this wish is accepted! Thanks! Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R 2.4.1 scheduled for December 18
Hi! If I am not wrong issue described at http://thread.gmane.org/gmane.comp.lang.r.devel/9667/focus=9667 did not get any attention. Thought it is true that using names() instead of colnames() does not change mode of data.frame rownames. This issues are also "alive": http://thread.gmane.org/gmane.comp.lang.r.devel/9837/focus=9837 http://thread.gmane.org/gmane.comp.lang.r.devel/7540/focus=7540 http://thread.gmane.org/gmane.comp.lang.r.devel/8513/focus=8518 Thanks, Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R 2.4.1 scheduled for December 18
Gregor Gorjanc bfro.uni-lj.si> writes: > > Hi! > > If I am not wrong issue described at > > http://thread.gmane.org/gmane.comp.lang.r.devel/9667/focus=9667 > > did not get any attention. Thought it is true that using names() instead of > colnames() does not change mode of data.frame rownames. > > This issues are also "alive": > > http://thread.gmane.org/gmane.comp.lang.r.devel/9837/focus=9837 > http://thread.gmane.org/gmane.comp.lang.r.devel/7540/focus=7540 > http://thread.gmane.org/gmane.comp.lang.r.devel/8513/focus=8518 This one also: http://thread.gmane.org/gmane.comp.lang.r.devel/10723/focus=10723 Thanks! Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R 2.4.1 scheduled for December 18
And small typo in postscript man page Index: src/library/grDevices/man/postscript.Rd === --- src/library/grDevices/man/postscript.Rd (revision 40125) +++ src/library/grDevices/man/postscript.Rd (working copy) @@ -195,7 +195,7 @@ using the \code{encoding} argument the glyphs can be matched to encoding in use. This suffices for European and Cyrillic languages, but not for CJK languages. For the latter, composite CID fonts are - used. These fonts are be useful for other languages: for example they + used. These fonts are useful for other languages: for example they may contain Greek glyphs. (The rest of this section applies only when CID fonts are not used.) I will stop now;) Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] R-devel: rownames of a data.frame
Martin Maechler r-project.org> writes: ... > because colnames() and rownames() work via dimnames(), and so do > "colnames<-" and "rownames<-" --- > I think it would be unwise to change this, since it's well documented > property of these functions. > > As you noted yourself, using names() and "names<-" > i.e., > names(df1) <- "bla" > in the example above, is the recommended way for data frames and does not > change the rownames to character. Thank you for this followup! It seems that I should have read the documentation more carefully. May I just suggest to add names in see also for row.names help page. Regards, Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Enhances, require() and quality control
Hello! I am working on a package where Enhances field seems to be a plausible option. When I add package, say coda, to this field, I get the following warning with recent R-devel: * checking for working latex ... OK * using log directory '/home/ggorjan/programs/R/devel/test.Rcheck' * using R version 2.5.0 Under development (unstable) (2006-12-06 r40129) * checking for file 'test/DESCRIPTION' ... OK * this is package 'test' version '0.1' * checking package dependencies ... WARNING 'library' or 'require' calls not declared from: coda See the information on DESCRIPTION files in the chapter 'Creating R packages' of the 'Writing R Extensions' manual. I have require(code) somewhere in the code. Is this OK or is R CMD check to stringent in case of enhances field - I get no warning if that package is in depends or suggests fields? After a short look into src/library/tools/R/QC.R I think that the following might be the solution. I did not do any other testing than with my package, where R CMD check (R with proposed change) passed without warnings. Index: src/library/tools/R/QC.R === --- src/library/tools/R/QC.R(revision 40129) +++ src/library/tools/R/QC.R(working copy) @@ -3659,8 +3659,8 @@ standard_package_names <- .get_standard_package_names()$base %w/o% c("methods", "stats4") depends_suggests <- c(depends, suggests, pkg_name, contains, - standard_package_names) -imports <- c(imports, depends_suggests, enhances) + standard_package_names, enhances) +imports <- c(imports, depends_suggests) ## the first argument could be named, or could be a variable name. ## we just have a stop list here. common_names <- c("pkg", "pkgName", "package", "pos") -- Lep pozdrav / With regards, Gregor Gorjanc -- University of Ljubljana PhD student Biotechnical Faculty Zootechnical Department URI: http://www.bfro.uni-lj.si/MR/ggorjan Groblje 3 mail: gregor.gorjanc bfro.uni-lj.si SI-1230 Domzale tel: +386 (0)1 72 17 861 Slovenia, Europefax: +386 (0)1 72 17 888 -- "One must learn by doing the thing; for though you think you know it, you have no certainty until you try." Sophocles ~ 450 B.C. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] Matplot does not work with x being POSIXt class (PR#9412)
Hi, Matplot works with x being Date class but not POSIXt. Here is the example with R version 2.5.0 Under development (unstable) (2006-12-06 r40129) Example: x <- Sys.Date() - c(1:10) y <- cbind(1:10, 10:1) class(x) ## [1] "Date" matplot(x, y) x <- strptime(as.character(x), format="%Y-%m-%d") ## [1] "POSIXt" "POSIXlt" matplot(x, y) Error in matplot(x, y) : 'x' and 'y' must have only 1 or the same number of columns Additionally, matplot with x being Date class does not use apropriate annotation for x axis. Thank you! Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Matplot does not work with x being POSIXt class (PR#9412)
Hi, Don MacQueen wrote: ... > At 1:56 PM +0100 12/7/06, [EMAIL PROTECTED] wrote: >> Hi, >> >> Matplot works with x being Date class but not POSIXt. Here is the >> example with R version 2.5.0 Under development (unstable) (2006-12-06 >> r40129) >> >> Example: >> >> x <- Sys.Date() - c(1:10) >> y <- cbind(1:10, 10:1) >> class(x) >> ## [1] "Date" >> matplot(x, y) >> >> x <- strptime(as.character(x), format="%Y-%m-%d") >> ## [1] "POSIXt" "POSIXlt" >> matplot(x, y) >> Error in matplot(x, y) : 'x' and 'y' must have only 1 or the same number >> of columns >> >> Additionally, matplot with x being Date class does not use apropriate >> annotation for x axis. > > This is very easy to obtain: > > # x is a Date object > matplot(x,y,xaxt='n') > axis.Date(1,x) > > or > > # x is a POSIXlt object > matplot( as.POSIXct(x), y,xaxt='n') > axis.POSIXct(1,x) > > So easy, in fact, that I personally would not expect R core to spend > time on it. One of the virtues of R is that the language is so rich that > little tweaks like this are often very easy. Thank you Peter and Don for these insights. I see that changes would be far from trivial/tricky and as Don pointed out simple tweaks by the user can solve this. Thank you and sorry for inconvenience! Best wishes, Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] Enhances, require() and quality control
Kurt Hornik wrote: >>>>>> Gregor Gorjanc writes: > >> Hello! > >> I am working on a package where Enhances field seems to be a plausible >> option. When I add package, say coda, to this field, I get the >> following warning with recent R-devel: > >> > >> * checking for working latex ... OK >> * using log directory '/home/ggorjan/programs/R/devel/test.Rcheck' >> * using R version 2.5.0 Under development (unstable) (2006-12-06 r40129) >> * checking for file 'test/DESCRIPTION' ... OK >> * this is package 'test' version '0.1' >> * checking package dependencies ... WARNING >> 'library' or 'require' calls not declared from: >> coda > >> See the information on DESCRIPTION files in the chapter 'Creating R >> packages' of the 'Writing R Extensions' manual. > > Why would you think that Enhances: is right here? > > If you use library or require on a package, you do more than enhance it, > and the package should be listed in Depends or Suggests. I might have understood Enhances field wrongly but imagine this situation. I have a package A and if I can use package B I would like to use it otherwise try with "my own" solution. I thought that Enhances fields is exactly for such situation. How should I check if package B is available? I used if(require(B)) { someSuperDuperFuncFromPkgB() } else { myOwnStuff() } But R CMD check complains. I have encountered this with R2WinBUGS. This package helps calling WinBUGS from R. It can also use OpenBUGS via BRugs, but BRugs is available only for Windows. Therefore, one can not do any QC under Linux. I thought to provide ability to call OpenBUGS via the same way WinBUGS is called and then to put BRugs in Enhances field. But R CMD check complained about use of require() for a package that is in Enhanced field. Thanks! Gregor __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel