Re: [R] Plotting directly to memory?
On Sun, May 28, 2023 at 1:46 PM Duncan Murdoch wrote: > > Is there a way to open a graphics device that plots entirely to an array > or raster in memory? I'd prefer it to use base graphics, but grid would > be fine if it makes a difference. > > For an explicit example, I'd like to do the equivalent of this: > >filename <- tempfile(fileext = ".png") >png(filename) >plot(1:10, 1:10) >dev.off() > >library(png) >img <- readPNG(filename) > >unlink(filename) > The magick package has this capability too: library(magick) img <- magick::image_device() plot(1:10, 1:10) dev.off() image_data(img) __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rstudio does not run on ubuntu 20
On Mon, Jun 15, 2020 at 2:47 PM Luigi Marongiu wrote: > > Hello, > all of a sudden rstudio stopped working on ubuntu 20.04. I > re-installed from `rstudio-1.3.959-amd64.deb` but it does not launch > even if there is an icon. On terminal I got: > ``` > $ rstudio > rstudio: error while loading shared libraries: libssl.so.1.0.0: cannot > open shared object file: No such file or directory > $ sudo apt-get install libssl1.0.0 libssl-dev > Reading package lists... Done > Building dependency tree > Reading state information... Done > Package libssl1.0.0 is not available, but is referred to by another package. > This may mean that the package is missing, has been obsoleted, or > is only available from another source > > E: Package 'libssl1.0.0' has no installation candidate This happens when you install the wrong rstudio binary for your version of debian/ubuntu. Go to https://rstudio.com/products/rstudio/download-server/debian-ubuntu/ and scroll down to "Install for Debian 10 / Ubuntu 18" and try that one. I think you had downloaded the binary for Ubuntu 16, which depends on an old version of openssl. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Rtools required
On Wed, Apr 29, 2020 at 11:37 PM Steven wrote: > > Hello John, > > Perhaps you can help me. I am an idiot. I visited the Rtools web page > and learn to run the following lines in R: Still I am getting the same > warning message. > > > writeLines('PATH="${RTOOLS40_HOME}\\usr\\bin;${PATH}"', con = > "~/.Renviron") > > Sys.which("make") >make > "C:\\rtools40\\usr\\bin\\make.exe" That looks OK. Did you restart rstudio? How exactly are getting this error? Are you using install.packages() in R? Or using the pkgbuild package? Also are you running the latest version of rstudio? I think old versions may have had difficulty finding rtools40. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Can't rsync extsoft/3.6 when compiling R 3.6
On Thu, May 2, 2019 at 9:36 AM Martin Maechler wrote: > > > Shuguang Sun > > on Thu, 2 May 2019 12:57:37 +0800 writes: > > > Hi all, > > When I try to compile R 3.6 in windows 10 in Rtools35, it raised the > error message: > > --8<---cut here---start->8--- > > make rsync-extsoft > > (mkdir -p ../../extsoft; \ > > cd ../../extsoft; \ > > rsync --timeout=60 -rcvp --delete > cran.r-project.org::CRAN/bin/windows/extsoft/3.6/ . ) > > receiving incremental file list > > rsync: change_dir "/bin/windows/extsoft/3.6" (in CRAN) failed: No such > file or directory (2) > > --8<---cut here---end--->8--- > > > There is no "windows/extsoft/3.6/" and only up to 3.5. > > > Best Regards, > > Shuguang Sun > > Indeed. > If you look at this FTP directory in a capabable browser (such > as Emacs), you see > > Dec 22 2014 3.2 > Jun 16 2016 3.3 > Jul 6 2016 3.4 -> 3.3 > May 8 2017 3.5 -> 3.3 > > So it seems the CRAN team (or the R Core release master?) forgot > to make that symbolic link there. I think that might be my responsibility (not entirely sure honestly). I'll add that directory and include the current versions of the libs we use to build the official r-base on Windows. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Problem installing libxml2 under Homebrew
You probably have a malconfigured homebrew installation of R. On MacOS it is recommended to use the CRAN version of R https://cran.r-project.org/bin/macosx/. The homebrew version depends on gcc compilers and does not support cran binary packages. If you really want to use the homebrew R try ruling out the following problems: - Check for conflicting compilers in your path (gcc, ccache, clang4). Unless you have good reasons not to, you should use the native xcode compilers to build R packages. - Comment out custom compilers/flags that you may have in your ~/.R/Makevars file. Use the following script to check why the configuration is failing: CPP=$(R CMD config CPP) CFLAGS=$(xml2-config --cflags) echo '#include ' | $CPP $CFLAGS -E -xc - > /dev/null On Sat, Feb 17, 2018 at 8:53 AM, Peter Meilstrup wrote: > i am trying to install xml2 from CRAN, and it is throwing an error > that it cannot find the libxml2 library configuration. > > The thing is that pkg-config seems to be set up correctly: > > $ echo $PKG_CONFIG_PATH > :/usr/local/opt/libxml2/lib/pkgconfig:/usr/local/opt/libxml2/lib/pkgconfig > > $ pkg-config --cflags --libs libxml-2.0 > -I/usr/local/Cellar/libxml2/2.9.7/include/libxml2 > -L/usr/local/Cellar/libxml2/2.9.7/lib -lx > > Output of install.packages: > >> install.packages("xml2") > --- Please select a CRAN mirror for use in this session --- > trying URL 'https://cloud.r-project.org/src/contrib/xml2_1.2.0.tar.gz' > Content type 'application/x-gzip' length 251614 bytes (245 KB) > == > downloaded 245 KB > > * installing *source* package ‘xml2’ ... > ** package ‘xml2’ successfully unpacked and MD5 sums checked > Found pkg-config cflags and libs! > Using PKG_CFLAGS=-I/usr/include/libxml2 > Using PKG_LIBS=-L/usr/lib -lxml2 -lz -lpthread -licucore -lm > - ANTICONF ERROR --- > Configuration failed because libxml-2.0 was not found. Try installing: > * deb: libxml2-dev (Debian, Ubuntu, etc) > * rpm: libxml2-devel (Fedora, CentOS, RHEL) > * csw: libxml2_dev (Solaris) > If libxml-2.0 is already installed, check that 'pkg-config' is in your > PATH and PKG_CONFIG_PATH contains a libxml-2.0.pc file. If pkg-config > is unavailable you can set INCLUDE_DIR and LIB_DIR manually via: > R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...' > > ERROR: configuration failed for package ‘xml2’ > > Homebrew package info: > > dekkera:pkgconfig peter$ brew info libxml2 R > libxml2: stable 2.9.7 (bottled), HEAD [keg-only] > GNOME XML library > http://xmlsoft.org > /usr/local/Cellar/libxml2/2.9.7 (281 files, 10.4MB) > Poured from bottle on 2018-02-16 at 22:42:54 > From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/libxml2.rb > ==> Options > --HEAD > Install HEAD version > ==> Caveats > This formula is keg-only, which means it was not symlinked into /usr/local, > because macOS already provides this software and installing another version in > parallel can cause all kinds of trouble. > > If you need to have this software first in your PATH run: > echo 'export PATH="/usr/local/opt/libxml2/bin:$PATH"' >> ~/.bash_profile > > For compilers to find this software you may need to set: > LDFLAGS: -L/usr/local/opt/libxml2/lib > CPPFLAGS: -I/usr/local/opt/libxml2/include > For pkg-config to find this software you may need to set: > PKG_CONFIG_PATH: /usr/local/opt/libxml2/lib/pkgconfig > > If you need Python to find bindings for this keg-only formula, run: > echo /usr/local/opt/libxml2/lib/python2.7/site-packages >> > /usr/local/lib/python2.7/site-packages/libxml2.pth > mkdir -p /Users/peter/Library/Python/2.7/lib/python/site-packages > echo 'import site; > site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> > /Users/peter/Library/Python/2.7/lib/python/site-packages/homebrew.pth > > R: stable 3.4.3 (bottled) > Software environment for statistical computing > https://www.r-project.org/ > /usr/local/Cellar/R/3.4.0_1 (2,246 files, 59.1MB) > Poured from bottle on 2017-05-20 at 17:10:29 > /usr/local/Cellar/R/3.4.1_2 (2,114 files, 55.3MB) > Poured from bottle on 2017-09-19 at 03:23:33 > /usr/local/Cellar/R/3.4.2 (2,111 files, 55.1MB) > Poured from bottle on 2017-11-13 at 22:23:36 > /usr/local/Cellar/R/3.4.3 (2,110 files, 55.1MB) > Poured from bottle on 2017-12-02 at 23:20:16 > /usr/local/Cellar/R/3.4.3_1 (3,773 files, 115.4MB) > Built from source on 2018-02-08 at 22:01:49 with: --with-x11 > --with-cairo --with-java > From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/r.rb > ==> Dependencies > Build: pkg-config ✔ > Required: gcc ✔, gettext ✔, jpeg ✔, libpng ✔, pcre ✔, readline ✔, xz ✔ > Optional: openblas ✔ > ==> Requirements > Optional: java ✔ > ==> Options > --with-java > Build with java support > --with-openblas > Build with openblas support > >
Re: [R] JSONlite import problem
On Sat, Oct 24, 2015 at 1:35 PM, Duncan Murdoch wrote: > > > However, editing the file with a text editor to create "proper" EOF > > doesn't help. > > The problem is that you have valid-looking JSON objects on each odd > numbered line, separated by single blank lines. The parser expects an > EOF at the end of the first object, but instead it found a blank line > and another object. Actually this is a common json streaming format called ndjson a.k.a. jsonlines. Usually you can stream-import the data directly in jsonlite using the stream_in function. See ?stream_in for examples. However in this case there are white lines in between the json lines which makes it a bit more tricky. I will add a feature to skip over those lines. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Installing pre-compiled R in Linux
> On Tue, Oct 6, 2015 at 9:42 PM, Sasikumar Kandhasamy > wrote: >> Thanks a lot Mike. The Linux distribution we use is "Red Hat Enterprise >> Linux Server release 6.2". On RHEL and CentOS the easiest and most reliable way to get R and R packages is via EPEL. Simply add the EPEL repositories and from there on you can install R and R packages as you would do on Fedora. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] How to access https page
On Mon, Mar 9, 2015 at 3:39 PM, Hui Du wrote: > > readLines(url) > Error in file(con, "r") : cannot open the connection > In addition: Warning message: > In file(con, "r") : unsupported URL scheme > Try: library(curl) readLines(curl(url)) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Failure to execute R CMD SHLIB successfully
On Sat, Jan 31, 2015 at 1:36 PM, Fisher Dennis wrote: > followed by a series of errors: > > gcc -m32 -shared -s -static-libgcc -o ../compiled/Windows32.so tmp.def > ConvertSAS.o CKHashTable.o readstat_convert.o readstat_bits.o readstat_io.o > readstat_sas.o -Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386 > -Ld:/RCompile/CRANpkg/extralibs64/local/lib > -LC:/PROGRA~1/R/R-31~1.2/bin/i386 -lR > > readstat_convert.o:readstat_convert.c:(.text+0x42): undefined reference > to `_imp__libiconv' > > readstat_sas.o:readstat_sas.c:(.text+0x10b5): undefined reference to > `_imp__libiconv_close' > > readstat_sas.o:readstat_sas.c:(.text+0x1126): undefined reference to > `_imp__libiconv_open' > > readstat_sas.o:readstat_sas.c:(.text+0x1808): undefined reference to > `dprintf' > > readstat_sas.o:readstat_sas.c:(.text+0x1da1): undefined reference to > `_imp__libiconv_open' > > readstat_sas.o:readstat_sas.c:(.text+0x1de4): undefined reference to > `_imp__libiconv_close' > > collect2: ld returned 1 exit status > The windows build of R includes a special version of iconv (Riconv.dll in the same dir as R.exe). Therefore if you include iconv.h somewhere, you also need to link to Riconv.dll in your Makevars.win: PKG_LIBS= -lRiconv [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Install R on linux Mint
On Wed, Jan 14, 2015 at 7:40 PM, Jeroen Ooms wrote: > Try 'precise' instead of 'utopic' I meant 'trusty'. The version should match the underlying ubuntu: http://www.linuxmint.com/oldreleases.php __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Install R on linux Mint
Try 'precise' instead of 'utopic' On Wed, Jan 14, 2015 at 7:31 PM, John Sorkin wrote: > I am trying to install R on Linux mint 17.1. I followed the instructions > found on CRAN and got a messages about unmet dependencies. I detail below the > steps I took: > > I added deb http://lib.stat.cmu.edu/R/CRAN/bin/linux/ubuntu utopic/ > to /etc/apt/sources.list > As can be seen below: > > john-OptiPlex-GX270 apt # more sources.list > #deb cdrom:[Linux Mint 17.1 _Rebecca_ - Release i386 20141126]/ trusty > contrib main non-free > deb http://lib.stat.cmu.edu/R/CRAN/bin/linux/ubuntu utopic/ > > And then followed the instructions on CRAN: > > sudo apt-get update > AND RECEIVED THE FOLLOWING MESSAGE: > > Fetched 316 kB in 8s (39.5 kB/s) > Reading package lists... Done > W: GPG error: http://lib.stat.cmu.edu utopic/ Release: The following > signatures couldn't be verified because the public key is not available: > NO_PUBKEY 51716619E084DAB9 > > sudo apt-get install r-base > AND RECEIVED THE FOLLOWING MESSAGE: > > The following packages have unmet dependencies: > r-base : Depends: r-base-core (>= 3.1.2-1utopic0) but 3.0.2-1ubuntu1 is to > be installed > Depends: r-recommended (= 3.1.2-1utopic0) but it is not going to be > installed > E: Unable to correct problems, you have held broken packages. > > John David Sorkin M.D., Ph.D. > Professor of Medicine > Chief, Biostatistics and Informatics > University of Maryland School of Medicine Division of Gerontology and > Geriatric Medicine > Baltimore VA Medical Center > 10 North Greene Street > GRECC (BT/18/GR) > Baltimore, MD 21201-1524 > (Phone) 410-605-7119 > (Fax) 410-605-7913 (Please call phone number above prior to faxing) > > Confidentiality Statement: > This email message, including any attachments, is for ...{{dropped:12}} __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Updates from the useR! 2014 organizing committee
Hi all, We are exactly one month away from the useR! 2014 conference [1]. Time for an update from the organizing committee. This weekend, registrations passed the 500 mark, which is a new record for useR! according to data collected by Gergely Daróczi [2]. Yet, there is plenty of additional capacity, both for the conference itself, as well as the beautiful on-campus housing at UCLA. We hope to see many more registrations over the upcoming weeks and appreciate all help in spreading the word to friends and colleagues that (should) use R, but might not be actively following the blogs or mailing lists. To those who are unsure whether to attend, we want to emphasize that useR! is not just for seasoned professionals, but has lots to offer to any R user. Abstracts and (free) tutorials cover a great diversity of topics in both research and industry applications, ranging from introductory to very advanced. The conference provides a great opportunity to learn and mingle with the community, and is interesting for beginner as well as experienced R users. Tutorials this year are included with the conference ticket and no separate registration is required. All registrants will receive an email survey asking which tutorial they would like to attend, if any. This information will be used for scheduling purposes and to facilitate communication between presenters and participants (e.g. distribution of preparation material). Finally, we urge international guests to verify that their visa or visa-waiver documents are valid to enter the United States. Citizens from visa-waiver countries [3] that do not already have a US visa, must apply online for an ESTA travel authorization at least 72 hours prior to departure. Once approved, the ESTA is generally valid for a period of 2 years, so now would be a good time to complete this process. We look forward to seeing all of you in California! Please keep an eye on the conference website, which is continuously updated with most recent news and information as it becomes available. Best, Jeroen, on behalf of the organizing committee [1] http://user2014.stat.ucla.edu/ [2] http://rapporter.net/custom/R-activity/data/Rstats.csv [3] http://www.esta.us/visa_waiver_countries.html ___ r-annou...@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-announce __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Call for abstracts to present at useR! 2014
We are happy to inform you that abstract submission for useR! 2014 is now available online, see http://user2014.stat.ucla.edu/ The R User Conference, useR! 2014 is scheduled for July 1-3, 2014 at the University of California, Los Angeles. Before the official program, half-day tutorials will be offered on Monday, June 30. Participants are encouraged to submit a one-page abstract for oral or poster presentation at the conference. For regular talks and posters, please use the recently updated LaTeX or Microsoft Word/LibreOffice Writer abstract templates available at the conference website: http://user2014.stat.ucla.edu/ The deadline for abstract submission is March 30, 2014. The preferred method of abstract and tutorial proposal submission is via the web form at the conference website: http://user2014.stat.ucla.edu/abstract-submission.html We look forward to seeing you at useR! 2014 in California! -- Jeroen, on behalf of the useR! 2014 local organizing committee __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] flatten lists
Alright, but I need something recursive for lists with arbitrary deepness. On Tue, Jun 26, 2012 at 3:37 PM, arun wrote: > Hi, > > Try: > > do.call("c",do.call("c",x)) > > x1<-do.call("c",do.call("c",x)) > x2<-flatlist(x) > identical(x1,x2) > [1] TRUE > > > > A.K. > > > > - Original Message - > From: Jeroen Ooms > To: Neal Fultz > Cc: r-help@r-project.org > Sent: Tuesday, June 26, 2012 6:23 PM > Subject: Re: [R] flatten lists > > Hmm that doesn't seem to work if the original list is nested more than > 2 levels deep. I should have probably given a better example: > > x <- list(name="Jeroen", age=27, married=FALSE, > home=list(country=list(name="Netherlands", short="NL"), city="Utrecht")) > > > > > On Tue, Jun 26, 2012 at 3:04 PM, Neal Fultz wrote: >> do.call("c", x) >> >> maybe? >> >> On Tue, Jun 26, 2012 at 02:25:40PM -0700, Jeroen Ooms wrote: >>> I am looking for a function to flatten a list to a list of only 1 >>> level deep. Very similar to unlist, however I don't want to turn it >>> into a vector because then everything will be casted to character >>> vectors: >>> >>> x <- list(name="Jeroen", age=27, married=FALSE, >>> home=list(country="Netherlands", city="Utrecht")) >>> unlist(x) >>> >>> This function sort of does it: >>> >>> flatlist <- function(mylist){ >>> lapply(rapply(mylist, enquote, how="unlist"), eval) >>> } >>> >>> flatlist(x) >>> >>> However it is a bit slow. Is there a more native way? >>> >>> __ >>> R-help@r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-help >>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >>> and provide commented, minimal, self-contained, reproducible code. > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] flatten lists
Hmm that doesn't seem to work if the original list is nested more than 2 levels deep. I should have probably given a better example: x <- list(name="Jeroen", age=27, married=FALSE, home=list(country=list(name="Netherlands", short="NL"), city="Utrecht")) On Tue, Jun 26, 2012 at 3:04 PM, Neal Fultz wrote: > do.call("c", x) > > maybe? > > On Tue, Jun 26, 2012 at 02:25:40PM -0700, Jeroen Ooms wrote: >> I am looking for a function to flatten a list to a list of only 1 >> level deep. Very similar to unlist, however I don't want to turn it >> into a vector because then everything will be casted to character >> vectors: >> >> x <- list(name="Jeroen", age=27, married=FALSE, >> home=list(country="Netherlands", city="Utrecht")) >> unlist(x) >> >> This function sort of does it: >> >> flatlist <- function(mylist){ >> lapply(rapply(mylist, enquote, how="unlist"), eval) >> } >> >> flatlist(x) >> >> However it is a bit slow. Is there a more native way? >> >> __ >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] flatten lists
I am looking for a function to flatten a list to a list of only 1 level deep. Very similar to unlist, however I don't want to turn it into a vector because then everything will be casted to character vectors: x <- list(name="Jeroen", age=27, married=FALSE, home=list(country="Netherlands", city="Utrecht")) unlist(x) This function sort of does it: flatlist <- function(mylist){ lapply(rapply(mylist, enquote, how="unlist"), eval) } flatlist(x) However it is a bit slow. Is there a more native way? __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] issues with read.spss
Someone supplied me with an SPSS datafile that caused a buffer overflow and then a crash when reading it in R. Unfortunately I can't supply the dataset at hand and I have a hard time reproducing it with a toy example. But I found at least 2 issues that might be related. I would like to know which of these are expected behavior, and which are bugs. I reproduced it on R 2.14.1 both on Ubuntu Linux and Windows 7... Below some code. The files that are referenced in the code are available for download on http://www.stat.ucla.edu/~jeroen/spss/ #load library library(foreign) #problem one: long string variable is converted to multiple variables. x <- read.spss("longstring.sav"); summary(x); #4 variables?? #problem two: use.labels does not deal correctly with duplicate labels and generates a bad factor. x <- read.spss("duplicate_labels.sav", use.value.labels=T); __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Standardized beta-coefficients in regression
Unfortunately I found myself in the same position as outlined above, where I was requested to reproduce 'standardized regression coefficients' as reported by SPSS. Below an example that produces something very similar to the results table from an SPSS "Linear Regression" procedure, including the standardized regression coefficients: mylm <- lm(Sepal.Width ~ ., data=iris, x=TRUE, y=TRUE) sd.x <- sd(mylm$x); sd.y <- sd(mylm$y); std.coef <- coef(mylm) * (sd.x / sd.y); coef.table <- as.data.frame(summary(mylm)$coefficients); coef.table <- cbind(coef.table, std.coef); print(coef.table); I do agree with B.R. but unfortunately the life of an applied statistician is complex sometimes :-) -- View this message in context: http://r.789695.n4.nabble.com/Standardized-beta-coefficients-in-regression-tp791616p3842631.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Save generic plot to file (before rendering to device)
Bumping this one up because the 'before.plot.new' solution turned out to be sub-optimal after all. >> It should be possible to do this with a before.plot.new hook, right? > > Yes, sure, if you treat the first and last plot separately. It turns out that the before.plot.new hook does not is not triggered at the right moments. I'm not sure if this is intended behavior or incorrect implementation. What I was expecting is a hook/event that is triggered every time before a new graphics frame is opened. E.g. if there is an open PDF device and some plots are printed, the number of times the hook is called should be exactly equal to the number of pages in the resulting PDF document. Sometimes this works as expected, sometimes it doesn't. At the end of this message some example code. In the first example, the hook works as expected is called 4 times, as there are 4 plots. In all the other examples the event is either triggered too often or not triggered at all. I guess the hook is called when the plot.new() function is explicitly called, which might not always happen. My question would be if (1) this is the intended behavior for 'before.plot.new', and (2) if yes, would it be possible to define an additional event that always triggers, and only triggers, if a completely new graphics device is opened. I.e. whenever a pdf device would start a new page. Thank you. #set the hook (event listener) setHook("before.plot.new", NULL); setHook("before.plot.new", function(){ message("Yay! A new plot!")}); #works as expected: plot(lm(speed~dist, cars), ask=F); #triggered way too often, once for every partition of the plot plot(mtcars); #not triggered at all by lattice library(lattice); dotplot(speed~dist, cars); #not triggered at all by ggplot2 library(ggplot2); qplot(speed, dist, data=cars); __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Save generic plot to file (before rendering to device)
Thanks I didn't know about that. I ended up with something like this. Is there a more elegant way to do it? myplots <<- list(); hasplots <<- FALSE; setHook("before.plot.new", function(...) { if(hasplots == FALSE){ hasplots <<- TRUE; } else { myplots[[length(myplots)+1]] <<- recordPlot(); } }); myfn <- function(mylm){ plot(mylm, ask=F) } mylm <- lm(dist~speed, data=cars); pdf(tempfile()) dev.control(displaylist="enable") myfn(mylm); if(hasplots){ myplots[[length(myplots)+1]] <- recordPlot(); } dev.off() On Sat, Jul 16, 2011 at 8:17 PM, Hadley Wickham wrote: > > >> Thank you, this is very helpful. One final question regarding this method: > >> suppose a function prints multiple plots, i.e. multiple pages to a PDF. Is > >> it possible to record all of these plots at once? The code below only > >> records the final plot. I would like to record all of them, without > >> modifying myfn: > > > > You cannot, since this takes a snapshot from the current device. You will > > have to recordPlot() after each plot, actually. > > It should be possible to do this with a before.plot.new hook, right? > > Hadley > > -- > Assistant Professor / Dobelman Family Junior Chair > Department of Statistics / Rice University > http://had.co.nz/ __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Save generic plot to file (before rendering to device)
> > That warning is necessarily rather pessimistic. We haven't changed the > format for several years. But we might, without notice. > Thank you, this is very helpful. One final question regarding this method: suppose a function prints multiple plots, i.e. multiple pages to a PDF. Is it possible to record all of these plots at once? The code below only records the final plot. I would like to record all of them, without modifying myfn: myfn <- function(mylm){ plot(mylm, ask=F) } mylm <- lm(dist~speed, data=cars); pdf(tempfile()) dev.control(displaylist="enable") myfn(mylm); myplots <- recordPlot() dev.off() save(myplot, file="myplot.RData") > > > >> Another approach (or the start to one that you could build on) is the >> plot2script function in the TeachingDemos package (which uses recordPlot >> internally). >> >> But it is probably best to save the resulting data from the long process, >> that could then be quickly plotted as others have mentioned. >> >> -- >> Gregory (Greg) L. Snow Ph.D. >> Statistical Data Center >> Intermountain Healthcare >> greg.s...@imail.org >> 801.408.8111 >> >> >> -Original Message- >>> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r- >>> project.org] On Behalf Of Jeroen Ooms >>> Sent: Monday, July 11, 2011 12:22 PM >>> To: David Winsemius >>> Cc: r-help@r-project.org >>> Subject: Re: [R] Save generic plot to file (before rendering to device) >>> >>> >>>> You can also save a data (or function) object to an .Rdata file with >>>> save(objname, file="filename.Rdata") and your colleagues could then >>>> load("filename.Rdata") in R. >>>> >>>> >>> Thanks for the responses. I found an old post by Gabor Grothendieck >>> that >>> shows what I want. Basically the trick is to save the displaylist to an >>> object: >>> >>> dev.control(displaylist="**enable") # enable display list >>> plot(1:10) >>> myplot <- recordPlot() # load displaylist into variable >>> >>> You can now store myplot and later fetch it and play it back via >>> >>> print(myplot) >>> >>>[[alternative HTML version deleted]] >>> >>> __** >>> R-help@r-project.org mailing list >>> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> >>> PLEASE do read the posting guide >>> http://www.R-project.org/**posting-<http://www.R-project.org/posting-> >>> guide.html >>> and provide commented, minimal, self-contained, reproducible code. >>> >> >> __** >> R-help@r-project.org mailing list >> https://stat.ethz.ch/mailman/**listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help> >> PLEASE do read the posting guide http://www.R-project.org/** >> posting-guide.html <http://www.R-project.org/posting-guide.html> >> and provide commented, minimal, self-contained, reproducible code. >> >> > -- > Brian D. Ripley, rip...@stats.ox.ac.uk > Professor of Applied Statistics, > http://www.stats.ox.ac.uk/~**ripley/<http://www.stats.ox.ac.uk/~ripley/> > University of Oxford, Tel: +44 1865 272861 (self) > 1 South Parks Road, +44 1865 272866 (PA) > Oxford OX1 3TG, UKFax: +44 1865 272595 > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Save generic plot to file (before rendering to device)
> > You can also save a data (or function) object to an .Rdata file with > save(objname, file="filename.Rdata") and your colleagues could then > load("filename.Rdata") in R. > Thanks for the responses. I found an old post by Gabor Grothendieck that shows what I want. Basically the trick is to save the displaylist to an object: dev.control(displaylist="enable") # enable display list plot(1:10) myplot <- recordPlot() # load displaylist into variable You can now store myplot and later fetch it and play it back via print(myplot) [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] unwanted coercion using apply
> > apply() operates on arrays and a data frame will be coerced to a matrix > (which requires all elements to be of the same type). This is documented in > ?apply. > Thanks, I was not aware of that. I implicitly assumed there would be a specific apply.data.frame. > This may not be elegant, but why not just use a loop: > The thing is that were are going to use this operation on a (very) large scale in a production environment, on datasets for which nrow >> ncol. So I would like the most efficient solution and if possibly, avoid looping over the rows. Thanks Jeroen [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] unwanted coercion using apply
I need to convert a dataframe to a record-structure, to be able to encode it later in JSON. Suppose this is the data: mydata <- data.frame(foo=1:3, bar=c("M","M","F")); I would like to convert this to a unnamed list (json array) of key-value pairs. For example like this: apply(data.frame(foo=1:3, bar=c("M","M","F")),1,as.list) However, when I do this, all the numeric values are converted to strings. I don't understand why this is, because when I try to convert one record simulataniously, this does not happen: as.list(mydata[1,]); I am not sure if this is indended behaviour or not, but is there an elegant way to apply 'as.list' to all of the dataframe rows without coercing everything to strings? -- View this message in context: http://r.789695.n4.nabble.com/unwanted-coercion-using-apply-tp3541637p3541637.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] regressing on variable with heavy tails
I have a dependent variable with is very peaked and has heavy tails, something I haven't encountered before. (histogram: http://postimage.org/image/2sw9bn8pw/). What could be an appropriate family or transformation to do regress on this?-- View this message in context: http://r.789695.n4.nabble.com/regressing-on-variable-with-heavy-tails-tp3486973p3486973.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Read function that detects format automatically
I was wondering if there exists a function that automatically tries to detect the format of a datafile. E.g. if it is an ascii datafile, that it can detect appropriate defaults for the read.table() parameters. One could for example read the first 10 lines of the file and analyze the format of the first line in comparison with the others, count the number of dots, colons and semicolons, etc. More generally, one could use the file extension or if available the unix 'file' command to evaluate the filetype if it is non ascii. I think it should not be very complicated to get a very high accuracy for detecting formats. For most datafiles it is for a human statistican easy to see the format of the file by looking at a fragment, so it should be possible to capture these rules in some code. It would be nice to have something like a read.magic() function that reads a datafile using the appropriate command, regardless of whether the user supplied an csv1, csv2, tab delimited, excel, spss, stata, etc file. I actually started to code something like this, but then I figured that maybe someone else has had the exact same idea. -- View this message in context: http://r.789695.n4.nabble.com/Read-function-that-detects-format-automatically-tp3479958p3479958.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] matrix of higher order differences
Is there an easy way to turn a vector of length n into an n by n matrix, in which the diagonal equals the vector, the first off diagonal equals the first order differences, the second... etc. I.e. to do this more efficiently: diffmatrix <- function(x){ n <- length(x); M <- diag(x); for(i in 1:(n-1)){ differences <- diff(x, dif=i); for(j in 1:length(differences)){ M[j,i+j] <- differences[j] } } M[lower.tri(M)] <- t(M)[lower.tri(M)]; return(M); } x <- c(1,2,3,5,7,11,13,17,19); diffmatrix(x); -- View this message in context: http://r.789695.n4.nabble.com/matrix-of-higher-order-differences-tp3477339p3477339.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] detect filetype (as in unix 'file')
> No, but what is wrong with using system()? The application is running in a very sandboxed environment and might not have permission to execute 'file'. > 'file' is large and complex because it tries to be comprehensive (but it > still does not know about some common systems, e.g. 64-bit Windows > binaries). There simply is no point in replicating that in R: which is why > we chose rather to port 'file' to Windows and provide in in Rools. Alright that makes sense, thanks. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] detect filetype (as in unix 'file')
Is there a way in R (in Linux) to detect the type of a file without invoking a shell? E.g to do this: > system("file density.plot") density.plot: PDF document, version 1.4 but without using system()? I tried file() and file.info(), but both do display the information I am looking for. -- View this message in context: http://r.789695.n4.nabble.com/detect-filetype-as-in-unix-file-tp3424562p3424562.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] svg malformed on CentOS (epel R)
The problem has been resolved thanks to Tom Callaway from Redhat: Tom Callaway wrote: > > Looking at the R source code, it uses Cairo to do the SVG creation, and > the Cairo in RHEL-5 is very (very) old (1.2.4). > > Digging through Cairo's changelogs post 1.2.4, I came across this: > > "SVG: Fix bug preventing text from appearing in many viewers" > > http://cairographics.org/news/cairo-1.4.0/ > > Sure enough, I dug out an old cairo 1.4 series package from Fedora 7 > (1.4.4, to be specific), rebuilt it on RHEL-5 and it generates a "good" > svg that views properly in Firefox. > > Looking at the code to see how they fixed that bug, it is pretty much > what I suspected, they add the overflow="visible" field when outputting > the glyphs. This was trivial to backport and the patch is attached. > > In addition, since I had to make the packages to test, I have uploaded > them here: > > http://spot.fedorapeople.org/cairo-invisible-text-fix-el5/ > > Last but not least, I have opened a bug against RHEL 5 on this issue. I > do not know if they will push a cairo update for this, but at least, it > is now on their radar: > > https://bugzilla.redhat.com/show_bug.cgi?id=691844 > So to fix the problem, grab the updated Cairo binary from the link he gives and do a: rpm -Uvh cairo-1.2.4-5.spot.i386.rpm -- View this message in context: http://r.789695.n4.nabble.com/svg-malformed-on-CentOS-epel-R-tp3352949p3420081.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] recursive do.call
I see what you are saying. The application I am working with is making convenient single-call (user) interfaces for R functions, and I don't want to write a wrapper for every possible combination (like Gene suggested below). If we don't consider the ... arguments for a second, and only consider first class arguments of all the functions. Maybe we could do something like this: rec.do.call <- function(fnnames, fnargs, object=NULL){ if(length(fnnames) == 1){ cat(fnnames, "(", paste(names(fnargs), collapse=","), ").\n\n", sep=""); return(do.call(fnnames, c(object, fnargs))); } thisfn <- head(fnnames, 1); if(is.null(getS3method(thisfn, class(object[[1]]), T))){ fnformals <- formals(thisfn); } else { fnformals <- formals(getS3method(thisfn, class(object[[1]]))); } matchindex <- na.omit(pmatch(names(fnformals), names(fnargs))); cat("Matched: ", thisfn, "(", paste(names(fnargs[matchindex]), collapse=","), "). ", sep=""); myobj <- do.call(thisfn, c(object, fnargs[matchindex])); if(length(matchindex)==0){ remaining.fnargs <- fnargs; } else { remaining.fnargs <- fnargs[-matchindex]; } cat("Remaining:", "(", paste(names(remaining.fnargs), collapse=","), "). \n", sep=""); rec.do.call(tail(fnnames, -1), remaining.fnargs, list(myobj)); } #two examples: rec.do.call(c("glm","anova","print"), list(formula="dist~speed", data=cars, test="Chisq", digits=1, signif.stars=F)) rec.do.call(c("glm","coef","round"), list(formula="dist~speed", data=cars, digits=1)) This seems to work for the examples above. Would this generally hold, or is this asking for trouble? > > -thomas > > > > > > > On Mon, Mar 14, 2011 at 3:34 AM, Felix Andrews wrote: > > > >> It is complicated if the argument list is all mixed in together as in > >> your example. You would have to look up argument lists for possible S3 > >> methods (e.g. 'digits' is an argument to print.default), and then > >> there is S4 to think about. Also, can arguments be matched by partial > >> names? Can they be given in the argument list without a name? > >> > >> My point is that you had better have a good reason to want to do it this > >> way... > >> > >> Cheers > >> Felix > >> > >> > >> On 14 March 2011 14:24, Jeroen Ooms wrote: > >> > I would like to define a recursive equivalent to call or do.call, which > >> takes > >> > a vector of multiple function names and 'chains' them, by greedy matching > >> of > >> > arguments down the chain. For example, I would like to be able to do: > >> > > >> > rec.do.call(c("glm","coef","print), list(formula=dist~speed, digits=3, > >> > data=cars)); > >> > > >> > which would then be equivalent to: > >> > > >> > print(coef(glm(formula=dist~speed, data=cars)), digits=3); > >> > > >> > I've been playing around with a recursive function with ellipses, but I > >> > can't wrap my head around it. > >> > > >> > -- > >> > View this message in context: > >> http://r.789695.n4.nabble.com/recursive-do-call-tp3353074p3353074.html > >> > Sent from the R help mailing list archive at Nabble.com. > >> > > >> > __ > >> > R-help@r-project.org mailing list > >> > https://stat.ethz.ch/mailman/listinfo/r-help > >> > PLEASE do read the posting guide > >> http://www.R-project.org/posting-guide.html > >> > and provide commented, minimal, self-contained, reproducible code. > >> > > >> > >> > >> > >> -- > >> Felix Andrews / 安福立 > >> http://www.neurofractal.org/felix/ > >> > > > > [[alternative HTML version deleted]] > > > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > > > > -- > Thomas Lumley > Professor of Biostatistics > University of Auckland __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] recursive do.call
Hmmm I was hoping there would be a more natural way to do it. For example, if you actually try to call the first function with all arguments: lm(formula=dist~speed, digits=3, data=cars) R will match whatever it can, and give you a warning with the names of remaining unmatched arguments. The only thing I really need is instead of a warning take these arguments and pass them on to the next function. On Mon, Mar 14, 2011 at 3:34 AM, Felix Andrews wrote: > It is complicated if the argument list is all mixed in together as in > your example. You would have to look up argument lists for possible S3 > methods (e.g. 'digits' is an argument to print.default), and then > there is S4 to think about. Also, can arguments be matched by partial > names? Can they be given in the argument list without a name? > > My point is that you had better have a good reason to want to do it this > way... > > Cheers > Felix > > > On 14 March 2011 14:24, Jeroen Ooms wrote: > > I would like to define a recursive equivalent to call or do.call, which > takes > > a vector of multiple function names and 'chains' them, by greedy matching > of > > arguments down the chain. For example, I would like to be able to do: > > > > rec.do.call(c("glm","coef","print), list(formula=dist~speed, digits=3, > > data=cars)); > > > > which would then be equivalent to: > > > > print(coef(glm(formula=dist~speed, data=cars)), digits=3); > > > > I've been playing around with a recursive function with ellipses, but I > > can't wrap my head around it. > > > > -- > > View this message in context: > http://r.789695.n4.nabble.com/recursive-do-call-tp3353074p3353074.html > > Sent from the R help mailing list archive at Nabble.com. > > > > __ > > R-help@r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-help > > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > > and provide commented, minimal, self-contained, reproducible code. > > > > > > -- > Felix Andrews / å®ç¦ç« > http://www.neurofractal.org/felix/ > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] recursive do.call
I would like to define a recursive equivalent to call or do.call, which takes a vector of multiple function names and 'chains' them, by greedy matching of arguments down the chain. For example, I would like to be able to do: rec.do.call(c("glm","coef","print), list(formula=dist~speed, digits=3, data=cars)); which would then be equivalent to: print(coef(glm(formula=dist~speed, data=cars)), digits=3); I've been playing around with a recursive function with ellipses, but I can't wrap my head around it. -- View this message in context: http://r.789695.n4.nabble.com/recursive-do-call-tp3353074p3353074.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] svg malformed on CentOS (epel R)
There is an issue with the default svg device on a centos workstation that I am using. It does not result in an error, but it produces malformed svg images. Exactly the same script works just fine on an ubuntu box. On Ubuntu I am using R binary that comes with maverick, on centos I am using the latest R binary from EPEL. Other than that both boxes are pretty clean, with only the dependencies installed that are automatically installed when installing R. For example a testscript like this svg("plot.svg"); plot(cars); dev.off(); should produce this: http://www.stat.ucla.edu/~jeroen/files/plot_good.svg (ubuntu), but on centos it produces this: http://www.stat.ucla.edu/~jeroen/files/plot_bad.svg. It looks very much as if there is something wrong with the fronts; maybe I am missing some library. However, as this is a production server, I don't want to go install random packages to see if this fixes the problem. Some questions: - How could I fix it? - Why is R not throwing an error instead of producing a malformed plot? - Maybe we could notify the R binary maintainers from fedora to add a formal dependency so that it works 'out of the box'? Jeroen -- View this message in context: http://r.789695.n4.nabble.com/svg-malformed-on-CentOS-epel-R-tp3352949p3352949.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] getting attributes of list without the "names".
Thank you, this is very helpful. I am a little confused now about the structure of a list though. If the names of the list-elements is truly an attribute that is stored in another list this would lead to an infintely recursing object? How could I iterate over the full object tree, without getting into infinite recursion if every list's attributes is another list with at least a 'names' attribute? On Tue, Mar 1, 2011 at 2:30 AM, Duncan Murdoch wrote: > On 11-02-28 11:17 PM, Jeroen Ooms wrote: > >> I am trying to encode arbitrary S3 objects by recursively looping over the >> object and all its attributes. However, there is an unfortunate feature of >> the attributes() function that is causing trouble. From the manual for >> ?attributes: >> >> The names of a pairlist are not stored as attributes, but are reported as >> if >> they were (and can be set by the replacement method for attributes). >> >> Now because of this, my program ends up in infinite recursion, because it >> will try to encode >> attributes(attributes(attributes(attributes(list(foo=123 etc. I can't >> remove the 'names' attribute, because this will actually affect the list >> structure. And even when I do: >> >> attributes(attributes(obj)[names(attributes(obj)) != "names"]) >> >> This will keep giving me a named list. Is there any way I can get the >> attributes() of a list without it reporting the names of a list as >> attributes? I.e it should hold that: >> >> atr1<- attributes(list(foo="bar")); >> atr2<- attributes(list()); >> identical(atr1,atr2); >> > > The names of a list (a generic vector) are attributes, just like the names > of other vectors. The documentation is talking about pairlists, a mostly > internal structure, used for example to store parts of expressions. So your > premise might be wrong about the cause of the recursion... > > But assuming you really want to see all attributes except names. Then just > write your own version: > > nonameattributes <- function(obj) { > result <- attributes(obj) > if (!is.null(result$names)) >result$names <- NULL > > # This removes the empty names of the result if there were no other > # attributes. It's optional, but you said you wanted > # identical(atr1, atr2) > > if (!length(result)) >names(result) <- NULL > > result > } > > You can make the conditional more complicated, only making the change for > pairlists, etc., using tests on typeof(obj) or other tests. > > Duncan Murdoch > > > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] getting attributes of list without the "names".
I am trying to encode arbitrary S3 objects by recursively looping over the object and all its attributes. However, there is an unfortunate feature of the attributes() function that is causing trouble. From the manual for ?attributes: The names of a pairlist are not stored as attributes, but are reported as if they were (and can be set by the replacement method for attributes). Now because of this, my program ends up in infinite recursion, because it will try to encode attributes(attributes(attributes(attributes(list(foo=123 etc. I can't remove the 'names' attribute, because this will actually affect the list structure. And even when I do: attributes(attributes(obj)[names(attributes(obj)) != "names"]) This will keep giving me a named list. Is there any way I can get the attributes() of a list without it reporting the names of a list as attributes? I.e it should hold that: atr1 <- attributes(list(foo="bar")); atr2 <- attributes(list()); identical(atr1,atr2); -- View this message in context: http://r.789695.n4.nabble.com/getting-attributes-of-list-without-the-names-tp3329209p3329209.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Parsing JSON records to a dataframe
What is the most efficient method of parsing a dataframe-like structure that has been json encoded in record-based format rather than vector based. For example a structure like this: [ {"name":"joe", "gender":"male", "age":41}, {"name":"anna", "gender":"female", "age":23} ] RJSONIO parses this as a list of lists, which I would then have to apply as.data.frame to and append them to an existing dataframe, which is terribly slow. -- View this message in context: http://r.789695.n4.nabble.com/Parsing-JSON-records-to-a-dataframe-tp3178646p3178646.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Chrooted R + Rserve
I am trying to reproduce this setting, but it does not seem to work anymore. I keep getting the error: execve failed: No such file or directory. One of the reasons is that /usr/local/bin/Rserve is no longer a standalone executable, and is now initiated using R CMD Rserve. However, after making the appropriate changes to the .ini, I still get the same error. Anyone successfully reproduced this setting with a recent R/Rserve/Jailkit? -- View this message in context: http://r.789695.n4.nabble.com/Chrooted-R-Rserve-tp845917p3020014.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Setting R_Interactive
We're using Rserve as a back-end in our application. A problem that we experienced is that the Rserve connection gets stuck when R is asking for some kind of user interaction. For example, when executing an 'install.packages' command for the first time without specifying the repos argument, R will prompt a list to specify a mirror, and does not return. To solve this, we need to set R to non-interactive (see ?interactive), but it's hard to find out how. Jeffrey Horner has been so kind to write a little piece of c code that sets the C level global variable R_Interactive (see package 'interactivity' on cran), but I was wondering if there is an easier way to start R in non interactive mode. -- View this message in context: http://r.789695.n4.nabble.com/Setting-R-Interactive-tp2322621p2322621.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] read.table behavior for Dates.
Ah Phil Spector is right, nothing is converted. I'm almost too embarrassed to admit it, but actually, it was Excel that tricked me. It displays date fields differently than they are stored in the csv file, and once you press 'save', it saves everything to a different format, completely unasked. Nevertheless I got some valuable insight in the topic. What I'm trying to do here is make it easier for people to upload files that might contain dates to my webapp at yeroon.net/ggplot2. Currently, dates are imported as factors. I would like to implement something that Henrique described, to automatically convert variables to Date that are obviously dates. -- View this message in context: http://n4.nabble.com/read-table-behavior-for-Dates-tp2013442p2013563.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] read.table behavior for Dates.
Yes I know I can manually do it, but I am using it for scripts in which users upload files. Hence, I don't know what's going to come; I don't know on before hand whether data will contain Dates, and in which columns they appear. This is why I was surprised that read.table has some (undocumented) behavior of converting columns that look like Dates to a different format. I would like to control this default behavior of the read.table function, rather than set a type for a specific column of a specific file. -- View this message in context: http://n4.nabble.com/read-table-behavior-for-Dates-tp2013442p2013489.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] read.table behavior for Dates.
When read.table imports a table that includes a header called 'Date', it tries to recognize the date format. For example, if one imports this data from Yahoo finance, the Date column is automatically transformed to Y-m-d, whereis in the data it appears as m/d/Y: myData <- read.csv("http://ichart.finance.yahoo.com/table.csv?s=GOOG&a=07&b=19&c=2004&d=03&e=16&f=2010&g=d&ignore=.csv";) However, it does not actually convert the variable to Date format. MyData$Date is still a factor. This combination of converting the format but not attributing the 'Date' class is for me extremely unfortunate behavior. My scripts still don't recognize the variable as being a date, but it also becomes harder to manually convert it using as.Date() because it is no longer in the original format. Is there a way to either automatically convert to as.Date() when a date format has been detected, or otherwise disable this transformation at all? -- View this message in context: http://n4.nabble.com/read-table-behavior-for-Dates-tp2013442p2013442.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [announce] yeroon.net/ggplot2 web application v0.2
A new version of the ggplot2 web interface has been released. Info and a demo video are available here: http://www.stat.ucla.edu/~jeroen/ggplot2/. The new version has a lot of new features, like advanced data import, integration with Google docs, converting variables from numeric to factor to dates and vice versa, and a lot of new geom's. For those that missed it: http://yeroon.net/ggplot2 is a web interface for Hadley Wickham's R package ggplot2. It is used as a tool for rapid prototyping, exploratory graphical analysis and education of statistics and R. The interface is written completely in javascript, therefore there is no need to install anything on the client side: a standard browser will do. All major browsers are supported but a recent and standards-compliant browser is highly recommended. Best performance is achieved by using Google Chrome. The easiest way to learn how to use the application is by taking 5 minutes to watch the introductory demo video. -- View this message in context: http://n4.nabble.com/announce-yeroon-net-ggplot2-web-application-v0-2-tp1890003p1890003.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] yeroon.net/ggplot2 web application v0.11
Hi Felipe, my apps are completely webbased, so you cannot use them offline, unless you are hosting a mirror locally or in your LAN (which can be arranged if you are interested). Jeroen 2009/12/7 Felipe Carrillo : > Hi Jeroen: > This is great for someone who is point and click oriented. Can this program > be downloaded to be used offline or its just web based? My field crew usually > take toughbooks to the field and since they don't know how to program it will > be nice to make the graphics just by pointing and clicking. Thanks > > > Felipe D. Carrillo > Supervisory Fishery Biologist > Department of the Interior > US Fish & Wildlife Service > California, USA > > > --- On Sun, 12/6/09, Jeroen Ooms wrote: > >> From: Jeroen Ooms >> Subject: [R] yeroon.net/ggplot2 web application v0.11 >> To: r-help@r-project.org >> Date: Sunday, December 6, 2009, 5:07 PM >> A new version of the ggplot2 web >> application is available at >> http://www.yeroon.net/ggplot2. New features include 1D >> geom’s >> (histogram, density, freqpoly), syntax mode (by clicking >> the tiny >> arrow at the bottom), and some additional facet options. >> Furthermore >> some minor improvements and fixes, most notably for >> Internet Explorer. >> >> As usual, a little demo video that shows how to use the new >> features: >> http://www.youtube.com/watch?v=7XGN6OSCq6E&hd=1 (watch >> in full >> screen). The datafile from the demo is available at >> http://www.yeroon.net/ggplot2/myMovies.csv. >> >> The data upload has not been improved yet, I am working on >> that. For >> now, it supports .csv, .sav (spss), and tab delimited data. >> Please >> make sure your filename has the appropriate extension and >> every column >> has a header in your data. If you export a dataframe from >> R, use: >> write.csv(mydf, ”mydf.csv” , row.names=F). If you >> upload an spss >> datafile, none of this should be a concern. >> >> Supported browsers are IE6-8, FF, Safari, and Chrome, but a >> recent >> browser is highly recommended. As always, feedback is more >> than >> welcome. >> >> Jeroen >> >> __ >> R-help@r-project.org >> mailing list >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, >> reproducible code. >> > > > > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] yeroon.net/ggplot2 web application v0.11
A new version of the ggplot2 web application is available at http://www.yeroon.net/ggplot2. New features include 1D geom’s (histogram, density, freqpoly), syntax mode (by clicking the tiny arrow at the bottom), and some additional facet options. Furthermore some minor improvements and fixes, most notably for Internet Explorer. As usual, a little demo video that shows how to use the new features: http://www.youtube.com/watch?v=7XGN6OSCq6E&hd=1 (watch in full screen). The datafile from the demo is available at http://www.yeroon.net/ggplot2/myMovies.csv. The data upload has not been improved yet, I am working on that. For now, it supports .csv, .sav (spss), and tab delimited data. Please make sure your filename has the appropriate extension and every column has a header in your data. If you export a dataframe from R, use: write.csv(mydf, ”mydf.csv” , row.names=F). If you upload an spss datafile, none of this should be a concern. Supported browsers are IE6-8, FF, Safari, and Chrome, but a recent browser is highly recommended. As always, feedback is more than welcome. Jeroen __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] multivariate numerical integration.
I am currently using the package 'adapt' for multivariate integration. However this package seems to be removed from CRAN (It is still referred to in the help file for integrate(stats) though). I assume it has been deprecated for a reason? Is there an alternative for multivariate numerical integration? ----- Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://old.nabble.com/multivariate-numerical-integration.-tp26164395p26164395.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] 1 dimensional optimization with local minima
I am using numerical optimization to fit a 1 parameter model, in which the input parameter is bounded. I am currently using optimize(), however, the problem turns out to have local minima, and optimize does not always seem to find the global minimum. I could to write a wrapping function that tries multiple intervals or starting values, but I would prefer a package that has built-in methods to make it more robust against local minima. I checked the CRAN Task View for Optimization, however there seem to be a lot of alternatives, and not being an optimization expert, I could use some advice. What could be an appropriate package or function for one-dimensional bounded optimization, that includes some protection against local minima? - Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://old.nabble.com/1-dimensional-optimization-with-local-minima-tp26160001p26160001.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Announce: lme4 web application
inspired by useR! 2009, yeroon.net is a new project developing statistical web applications to make popular R packages easier available. A first version of the lme4 web interface is available at http://yeroon.net/lme4/ http://yeroon.net/lme4/ . It implements most lme4 features and some more. A short 2minute how-to demo video that illustrates how to use the application is available on youtube: http://www.youtube.com/watch?v=_OHps7z3Pqc&hd=1. More information and details are available on my website http://www.jeroenooms.com/lme4.html We hope you will give it a try, and that you like it. Any feedback/suggestions/bugreports are welcome of course. note: because this is a public demo server, R sessions are currently limited to 40seconds. If you experience timeouts, try again later (server can be busy). Thank you! Jeroen ----- Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://www.nabble.com/Announce%3A-lme4-web-application-tp25435585p25435585.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] [Hmisc] Latex to pdf
I would like to print some tables and figures to a PDF device on a CentOS 5 vps. However, I cannot seem to get the latex function from Hmisc working. I followed the example, and got an error: sh: xdvi: command not found. I tried installing the 'tetex-xdvi' linux package, and now it returns: Error: Can't open display. I guess the reason for this is that the machine is a VPS terminal, so it has no display, however I dont understand why it does not write to the PDF device. Some code: > pdf("test.pdf") > x <- matrix(1:6, nrow=2, dimnames=list(c('a','b'),c('c','d','this that'))) > latex(x) # creates x.tex in working directory This is pdfeTeX, Version 3.141592-1.21a-2.2 (Web2C 7.5.4) entering extended mode (/tmp/Rtmp7bbXMN/file643c9869.tex LaTeX2e <2003/12/01> Babel and hyphenation patterns for american, french, german, ngerman, b ahasa, basque, bulgarian, catalan, croatian, czech, danish, dutch, esperanto, e stonian, finnish, greek, icelandic, irish, italian, latin, magyar, norsk, polis h, portuges, romanian, russian, serbian, slovak, slovene, spanish, swedish, tur kish, ukrainian, nohyphenation, loaded. (/usr/share/texmf/tex/latex/base/report.cls Document Class: report 2004/02/16 v1.4f Standard LaTeX document class (/usr/share/texmf/tex/latex/base/size10.clo)) (/usr/share/texmf/tex/latex/geometry/geometry.sty (/usr/share/texmf/tex/latex/graphics/keyval.sty) (/usr/share/texmf/tex/latex/geometry/geometry.cfg)) No file file643c9869.aux. [1] (./file643c9869.aux) ) Output written on file643c9869.dvi (1 page, 372 bytes). Transcript written on file643c9869.log. Error: Can't open display: - Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://www.nabble.com/-Hmisc--Latex-to-pdf-tp25316986p25316986.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Anova over a list of models
2009/9/5 Henrique Dallazuanna > > Try this: > anova(myModels[[1]],myModels[[2]]) > > do.call(anova, myModels) Does this work for you? Both functions are failing here: > anova(myModels[[1]],myModels[[2]]) Error in names(mods) <- sapply(as.list(mCall)[c(FALSE, TRUE, modp)], as.character) : 'names' attribute [6] must be the same length as the vector [2] > do.call(anova, myModels) Error in as.character.default(X[[1L]], ...) : no method for coercing this S4 class to a vector __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Anova over a list of models
I have a list object, in which I have stored n lme4-models. For example: library(lme4); myModels <- list(); myModels[1] <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy) myModels[2] <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), sleepstudy) Now I would like to perform an anova over all models in the list. However, the anova function requires that every model is inserted as a seperate argument, i.e. anova(model1,model2). I run into two problems: 1) anova(myModels[1],myModels[2]) returns an error. 2) if n, the number of models, is unknown, how do I add all models as a seperate argument? ----- Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://www.nabble.com/Anova-over-a-list-of-models-tp25311985p25311985.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Convert dataframe to array of records
I would like to convert a dataframe to an array of lists, one for every record. A natural choide is apply as.list to the rows. However, as it seems, as.list() automatically converts all list elements to the same datatype. Eg: myData <- data.frame(a="foo",b=as.logical(rbinom(10,1,.5))); apply(myData,1,as.list); In this output, all boolean values have been converted to character strings. I don't understand why this happens; a list does not require that every element is of the same datatype. Is there an easy way (ie avoid for-loops etc) to convert the dataframe to an array of records, while keeping the datatypes for every field? - Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://www.nabble.com/Convert-dataframe-to-array-of-records-tp25310023p25310023.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Problem Installing R 2.9.1.1 RHEL x86_64 binary
I just grabbed the new EL5 binary's for my x64 VPS from CRAN. However, where updates usually go smoothly, I now get these errors: -bash-3.2# rpm -i R-2.9.1-1.el5.x86_64.rpm error: Failed dependencies: R-devel = 2.9.1-1.el5 is needed by R-2.9.1-1.el5.x86_64 -bash-3.2# rpm -i R-core-2.9.1-1.el5.x86_64.rpm error: Failed dependencies: perl(File::Copy::Recursive) is needed by R-core-2.9.1-1.el5.x86_64 -bash-3.2# rpm -i R-devel-2.9.1-1.el5.x86_64.rpm error: Failed dependencies: R-core = 2.9.1-1.el5 is needed by R-devel-2.9.1-1.el5.x86_64 pcre-devel is needed by R-devel-2.9.1-1.el5.x86_64 What could be the problem? - Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://www.nabble.com/Problem-Installing-R-2.9.1.1-RHEL-x86_64-binary-tp24931890p24931890.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] popular R packages
> > I agree with Thomas, over the years I have installed R on at least 5 > computers. > I don't see why per-marchine statistics would not be useful. When you installed a package on five machines, you probably use it a lot, and it is more important to you than packages that you only installed once. Furthermore I don't think the distribution of packages has to be problematic. I guess downloads are only slightly related to the specific mirror, so download statistics from one of the popular mirror's would do for me. Of course these statistics are never perfect, but they could be informative... [[alternative HTML version deleted]] __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] popular R packages
I would like to get some idea of which R-packages are popular, and what R is used for in general. Are there any statistics available on which R packages are downloaded often, or is there something like a package-survey? Something similar to http://popcon.debian.org/ maybe? Any tips are welcome! - Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://www.nabble.com/popular-R-packages-tp22391260p22391260.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] lme4 and Variable level detection
I am making a little GUI for lme4, and I was wondering if there is a function that automatically detects on which level every variable exists. Furtheremore I got kind of confused about what a random effects model actually calculates. I have some experience with commercial software packages for multilevel analysis, like HLM6, and I was surprised that lme4 does not require the user to specify the level for every predictor variable. Is this because the function automatically detects the level by testing on which levels the predictor has variance, or is this information simply not needed? I was taught that a crosslevel interaction predicts the regression coefficient of the lower level variable, which is also what is implied by the HLM gui. However, in an lme4 formula, a crosslevel interaction has the same syntax as a regular interaction term. Furthermore, lme4 also allows adding crosslevel interactions without a random slope for the lower level variable. Now I'm confused. Is there a fundamental difference between a crosslevel interaction, or is the same thing as a regular interaction when the model also holds an error term for the lower level variable? - Jeroen Ooms * Dept. of Methodology and Statistics * Utrecht University Visit http://www.jeroenooms.com www.jeroenooms.com to explore some of my current projects. -- View this message in context: http://www.nabble.com/lme4-and-Variable-level-detection-tp22262944p22262944.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] package install error in CentOS
solved: There was indeed a problem with exec rights in the /tmp dir as they were set by my VPS host. I fixed it by creating a dir 'tempdir' in my homedir, and giving it 777 rights. Then set the environment variable TMPDIR in R: Sys.setenv(TMPDIR="/home/jeroen/tempdir"); install.packages("Cairo"); thank you :) Jeffrey Horner wrote: > > Check that your data partitions have the 'exec' flag set in /etc/fstab, > particulary the /tmp partition: > > http://www.centos.org/modules/newbb/viewtopic.php?topic_id=1687&forum=31 > > Jeff > > Jeroen Ooms wrote: >> I am trying to install package "Cairo" on CentOS 5.2, but I keep getting >> this >> error: >> >> * Installing *source* package 'Cairo' ... >> /usr/lib64/R/bin/INSTALL: ./configure: /bin/sh: bad interpreter: >> Permission >> denied >> ERROR: configuration failed for package 'Cairo' >> ** Removing '/usr/lib64/R/library/Cairo' >> >> The downloaded packages are in >> /tmp/Rtmp8ML568/downloaded_packages >> Updating HTML index of packages in '.Library' >> Warning message: >> In install.packages("Cairo") : >> installation of package 'Cairo' had non-zero exit status >> >> I tried to do it manually but with no luck: >> >> [jer...@138 shizzle]$ sudo R CMD INSTALL Cairo_1.4-4.tar.gz >> * Installing to library '/usr/lib64/R/library' >> * Installing *source* package 'Cairo' ... >> /usr/lib64/R/bin/INSTALL: ./configure: /bin/sh: bad interpreter: >> Permission >> denied >> ERROR: configuration failed for package 'Cairo' >> ** Removing '/usr/lib64/R/library/Cairo' >> >> I have tried to changing the $TMPDIR to another dir, and giving it 777 >> permissions, but I keep getting the error. Some info: >> >> >>> sessionInfo() >>> >> R version 2.8.0 (2008-10-20) >> x86_64-redhat-linux-gnu >> >> locale: >> C >> >> attached base packages: >> [1] stats graphics grDevices utils datasets methods base >> >> >> [jer...@138 shizzle]$ gcc --version >> gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42) >> 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. >> >> >> > > __ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide > http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > > -- View this message in context: http://www.nabble.com/package-install-error-in-CentOS-tp21094790p21097936.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] png() and jpg() devices acting weird.
I use a CentOS 5.2 VPS to generate graphs through an R web-application. I generate generate both pdf() and png() formats of the graphs. The pdf works just fine and generates perfect pictures. However, the figures generated by the png() (and also the jpg) device are messed up. The weird thing is that it does not generate an error. It does generate a file with a figure of the correct size, but the figures are mostly just white space, or small parts of the actual figure. X11 is not installed on the machine so I have to use type="cairo". I have tried installing and updating cairo, glib2, gtk+ in linux, and installed the R-package "Cairo", but with no result. > sessionInfo() R version 2.8.0 (2008-10-20) x86_64-redhat-linux-gnu locale: C attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] Cairo_1.4-4 -- View this message in context: http://www.nabble.com/png%28%29-and-jpg%28%29-devices-acting-weird.-tp21098121p21098121.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] package install error in CentOS
I am trying to install package "Cairo" on CentOS 5.2, but I keep getting this error: * Installing *source* package 'Cairo' ... /usr/lib64/R/bin/INSTALL: ./configure: /bin/sh: bad interpreter: Permission denied ERROR: configuration failed for package 'Cairo' ** Removing '/usr/lib64/R/library/Cairo' The downloaded packages are in /tmp/Rtmp8ML568/downloaded_packages Updating HTML index of packages in '.Library' Warning message: In install.packages("Cairo") : installation of package 'Cairo' had non-zero exit status I tried to do it manually but with no luck: [jer...@138 shizzle]$ sudo R CMD INSTALL Cairo_1.4-4.tar.gz * Installing to library '/usr/lib64/R/library' * Installing *source* package 'Cairo' ... /usr/lib64/R/bin/INSTALL: ./configure: /bin/sh: bad interpreter: Permission denied ERROR: configuration failed for package 'Cairo' ** Removing '/usr/lib64/R/library/Cairo' I have tried to changing the $TMPDIR to another dir, and giving it 777 permissions, but I keep getting the error. Some info: > sessionInfo() R version 2.8.0 (2008-10-20) x86_64-redhat-linux-gnu locale: C attached base packages: [1] stats graphics grDevices utils datasets methods base [jer...@138 shizzle]$ gcc --version gcc (GCC) 4.1.2 20071124 (Red Hat 4.1.2-42) 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. -- View this message in context: http://www.nabble.com/package-install-error-in-CentOS-tp21094790p21094790.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] a ratio-variable predictor
Maybe this is more of a statistical question than an R question, but I am going to ask it anyway :) Cortisol and Testosteron are known to interact in the body, and some literature suggest that especially the ratio between the two is a good predictor. So I want to add the ratio predictor (y~cort/test) to a glm, and later a multilevel model, however I have no experience with ratio variables. Intuitively, I would think that a ratio is very similar to an interaction effect, only with an inverse scale for the second term (cort* 1/test). However, I found that even more than with normal interaction effects, the scaling of the variables becomes important. Furthermore there is the obvious problem (which is not too big of a problem in my case), of values that are close to zero on the second term. So what is an appropriate way to incorporate a ratio-predictor? Any tips on R procedure/package that I could use, or any other experiences with ratio-predictors are welcome. -- View this message in context: http://www.nabble.com/a-ratio-variable-predictor-tp21069805p21069805.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Multivariate kernel density estimation
I would like to estimate a 95% highest density area for a multivariate parameter space (In the context of anova). Unfortunately I have only experience with univariate kernel density estimation, which is remarkebly easier :) Using Gibbs, i have sampled from a posterior distirbution of an Anova model with k means (mu) and 1 common residual variance (s2). The means are independent of eachother, but conditional on the residual variance. So now I have a data frame of say 10.000 iterations, and k+1 parameters. I am especially interested in the posterior distribution of the mu parameters, because I want to test the support for an inequalty constrained model (e.g. mu1 > mu2 > mu3). I wish to derive the multivariate 95% highest density parameter space for the mu parameters. For example, if I had a posterior distirbution with 2 means, this should somehow result in the circle or elipse that contains the 95% highest density area. Is something like this possible in R? All tips are welcome. -- View this message in context: http://www.nabble.com/Multivariate-kernel-density-estimation-tp20894766p20894766.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] plotting density for truncated distribution
thank you, both solutions are really helpful! -- View this message in context: http://www.nabble.com/plotting-density-for-truncated-distribution-tp20684995p20703469.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] plotting density for truncated distribution
I am using density() to plot a density curves. However, one of my variables is truncated at zero, but has most of its density around zero. I would like to know how to plot this with the density function. The problem is that if I do this the regular way density(), values near zero automatically get a very low value because there are no observed values below zero. Furthermore there is some density below zero, although there are no observed values below zero. This illustrated the problem: mydata <- rnorm(10); mydata <- mydata[mydata>0]; plot(density(mydata)); the 'real' density is exactly the right half of a normal distribution, so truncated at zero. However using the default options, the line seems to decrease with a nice curve at the left, with some density below zero. This is pretty confusing for the reader. I have tried to decrease the bw, masks (but does not fix) some of the problem, but than also the rest of the curve loses smoothness. I would like to make a plot of this data that looks like the right half of a normal distribution, while keeping the curve relatively smooth. Is there any way to specify this truncation in the density function, so that it will only use the positive domain to calculate density? -- View this message in context: http://www.nabble.com/plotting-density-for-truncated-distribution-tp20684995p20684995.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.8.0 is released
Yes I indeed explicitly compiled with --without-x. You were right, it was just a simple missing semicolon. I fixed it by adding a simicolon at the end of line 1657 in the file /src/main.platform.c: int X11 = FALSE; Something to fix in the new version, though. On Mon, Oct 20, 2008 at 10:39 PM, Duncan Murdoch <[EMAIL PROTECTED]> wrote: > On 10/20/2008 4:34 PM, Jeroen Ooms wrote: >> >> I'm getting a unexpected compiling error when doing make: >> >> gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2 >> -I../../src/extra/pcre -I. -I../../src/include -I../../src/include >> -I/usr/local/include -DHAVE_CONFIG_H -fpic -g -O2 -c platform.c -o >> platform.o >> platform.c: In function 'do_capabilities': >> platform.c:1661: error: expected ',' or ';' before 'Rf_checkArityCall' >> make[3]: *** [platform.o] Error 1 >> >> R.2.7.2 compiled without any problems on the same machine. >> Here is my config.log: http://jeroen.xlshosting.net/config.log.zip >> Am I doing anything wrong? And will their be binary Debian packages for >> this >> release (they never appeared for R-2.7.2)? > > If you look at the file, it appears someone forgot a semicolon at the end of > line 1657, which is only compiled for people on Unix with no X11. That's > likely a configuration problem, e.g. you don't have the X11 development > libraries installed, or the configure script couldn't find them. > > Duncan Murdoch > __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.8.0 is released
I'm getting a unexpected compiling error when doing make: gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2 -I../../src/extra/pcre -I. -I../../src/include -I../../src/include -I/usr/local/include -DHAVE_CONFIG_H -fpic -g -O2 -c platform.c -o platform.o platform.c: In function 'do_capabilities': platform.c:1661: error: expected ',' or ';' before 'Rf_checkArityCall' make[3]: *** [platform.o] Error 1 R.2.7.2 compiled without any problems on the same machine. Here is my config.log: http://jeroen.xlshosting.net/config.log.zip Am I doing anything wrong? And will their be binary Debian packages for this release (they never appeared for R-2.7.2)? thank you! -- View this message in context: http://www.nabble.com/R-2.8.0-is-released-tp20066170p20078229.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] R 2.8.0 is released
I'm getting a unexpected compiling error when doing make: gcc -std=gnu99 -I../../src/extra/zlib -I../../src/extra/bzip2 -I../../src/extra/pcre -I. -I../../src/include -I../../src/include -I/usr/local/include -DHAVE_CONFIG_H -fpic -g -O2 -c platform.c -o platform.o platform.c: In function 'do_capabilities': platform.c:1661: error: expected ',' or ';' before 'Rf_checkArityCall' make[3]: *** [platform.o] Error 1 R.2.7.2 compiled without any problems on the same machine. Here is my config.log: http://jeroen.xslhosting.net/config.log.zip Am I doing anything wrong? And will their be binary Debian packages for this release (they never appeared for R-2.7.2)? thank you! -- View this message in context: http://www.nabble.com/R-2.8.0-is-released-tp20066170p20078192.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] drop1() seems to give unexpected results compare to anova()
Thomas Chu wrote: > > Neither of those 3 lines of commands managed to drop x4 and its P value > magically decreased from 0.94 to almost 0! I am also baffled by how R > calculated those RSS. > Maybe it is using a different type of SS. If i have a lm() model, and i do: options(contrasts=c("contr.sum", "contr.poly")); anovafit <- drop1(model,attributes(model$terms)$term.labels,test="F"); then i get identical SS, F and p values as in SPSS. Maybe http://www.nabble.com/set-type-of-SS-in-anova()-to18287076.html#a18287076 this post is helpfull. Also check out the post on http://myowelt.blogspot.com/ this blog from 2008-05-24: Obtaining the same ANOVA results in R as in SPSS - the difficulties with Type II and Type III sums of squares . -- View this message in context: http://www.nabble.com/drop1%28%29-seems-to-give-unexpected-results-compare-to-anova%28%29-tp18770635p1813.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
Re: [R] Object-oriented programming in R for Java programmers?
Werner Wernersen wrote: > > I have done oo programming in C++ and Java before but the first few > tutorial on R oo were a bit confusing for me. > My personal experience is that the type of OO programming that makes for example Java code nice and easy to structure is not possible in R. The biggest problem for me is, correct me if i'm wrong, that R does not store memory references in its identifiers (variables), but a creates new 'object' for every identifier. For example, if you do in R: a <- 123 b <- 456 a <- b a <- 789 b If you would do a similar thing in Java, bot the variables 'a' and 'b' would have changed to the value 789, because both the variables now refer to the same object. So manipulating one also manipulates the other. However, in R, variable 'b' still stores the value of 456 at the end of this example. What this means for OO programming is that there is no easy way to reference to objects. For example, if you have want to access a variable which is part of a dataframe object, which is nested in a list object, you can only reference this object every time using list$dataframe$varname, where in Java, you could create a new variable that references to this specific object. Once datastructures become more complex, this handicap gets bigger and bigger. However, please don't take this for granted since I am only a beginning R programmer (and slightly more advanced Java programmer). I am also really curious what others have to say because I am having the same problem of my R-code quickly getting messy and confusing. -- View this message in context: http://www.nabble.com/Object-oriented-programming-in-R-for-Java-programmers--tp18675688p18679872.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
[R] Link functions in SEM
Is it possible to fit a structural equation model with link functions in R? I am trying to build a logistic-regression-like model in sem, because incorporating the dichotomous variables linearly seems inappropriate. Mplus can do something similar by specifying a 'link' parameter, but I would like to be able to do it in R, ofcourse. I have explored the 'sem' package from John Fox, but it does not seem to be able to fit non-linear relations. Is there some R-package or way to get this done? I have also considered creating a seperate latent variable in the sem model for the systematic component of the predictors, but then I still need a way to fix a non-linear link from the systematic component to the dichotomous Y variable. -- View this message in context: http://www.nabble.com/Link-functions-in-SEM-tp18679236p18679236.html Sent from the R help mailing list archive at Nabble.com. __ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.