r

How do I apply underlying decision rules created from the R package randomForest onto a NEW Out of Bag test set?

Is this even possible? I had a dataset for training that included about 1500 entries. The randomForest created its decision rules and applied them to the randomly chosen (from the original dataset) Out of Bag training sample (bootstrapped 10,000 times). I have a separate (unclassified) dataset that I would like to apply the 10,000 cre...

Building and installing an R package library with a jnilib extension

I'm building an R package and need to build a jni library for OSX (called myPackage.jnilib) as part of my build process and then have R's automatic installation mechanisms put it inside the libs directory of my package. The problem is that R's default is to try and build an object called myPackage.so . I'd like to be able to customise t...

using stat_function and facet_wrap together in GGPLOT2 in R

I am trying to plot lattice type data with GGPLOT2 and then superimpose a normal distribution over the sample data to illustrate how far off normal the underlying data is. I would like to have the normal dist on top to have the same mean and stdev as the panel. here's an example: library(ggplot2) #make some example data dd<-data.fram...

How can I compute the probability at a point given a normal distribution in Perl?

Is there a package in Perl that allows you to compute the height of probability distribution at each given point. For example this can be done in R this way: > dnorm(0, mean=4,sd=10) > 0.03682701 Namely the probability of point x=0 falls into a normal distribution, with mean=4 and sd=10, is 0.0368. I looked at Statistics::Distribution...

How do you deal with missing data using numpy/scipy?

One of the things I deal with most in data cleaning is missing values. R deals with this well using its "NA" missing data label. In python, it appears that I'll have to deal with masked arrays which seem to be a major pain to set up and don't seem to be well documented. Any suggestions on making this process easier in Python? This is bec...

On Data Frame: Writing to File and Naming Binded Vector in R

I have a data that looks like this. And my code below simply compute some value and binds the output vector to the original data frames. options(width=200) args<-commandArgs(trailingOnly=FALSE) dat <- read.table("http://dpaste.com/89376/plain/",fill=T); problist <- c(); for (lmer in 1:10) { meanl <- lmer; stdevl <- (0.17*sqrt(l...

Recommendations for developing Sweave documents

I'm looking to streamline my Sweave document creation, and I'd like to hear about people's current setups. I feel like the holy grail goes something like this: Editing Rnw code on one half of the screen Single keybinding compiles Sweave document and runs pdflatex View PDF on the other half of the screen; once compiled, PDF is refres...

How to fit a random effects model with Subject as random in R?

Given data of the following form myDat = structure(list(Score = c(1.84, 2.24, 3.8, 2.3, 3.8, 4.55, 1.13, 2.49, 3.74, 2.84, 3.3, 4.82, 1.74, 2.89, 3.39, 2.08, 3.99, 4.07, 1.93, 2.39, 3.63, 2.55, 3.09, 4.76), Subject = c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L, 4L, 4L, 4L, 5L, 5L, 5L, 6L, 6L, 6L, 7L, 7L, 7L, 8L, 8L, 8L), Condition = c(0L, ...

removing plot margins in R

I want to remove the space between the axes of the plot and the plot contents themselves. Any ideas? ...

How do I print greek letters on the diagonal of a pairs plot in R?

I want to create a pairs plot in R that has labels on the diagonal written as greek letters. I've tried creating a custom text.panel function that wraps the labels in an expression() call, but this does not work. Here is a simple test case: pairs.greek <- function(x, ...) { panel.txt <- function(x, y, labels, cex, font, ...) { ...

Making animated gifs using R

Duplicate Creating a Movie from a Series of Plots in R Does anyone have any tips regarding making animated GIFs in R? I'm trying to make some time lapse map GIFs. ...

data.frame subset long format

I guess there will be a very simple answer to this. But here goes. Data in long format. like this d <- data.frame(cbind(numbers = rnorm(10), year = rep(c(2008, 2009), 5), name = c("john", "David", "Tom", "Kristin", "Lisa","Eve","David","Tom","Kristin","Lisa"))) How do I get a new dataframe only with rows for names that occur in both ...

Are there any good R object browsers?

S-Plus has a great object explorer and data editor built into its GUI. It allows you to easily see all the objects in the workspace at a glance, and sort them by name, size, or date. As far as I'm aware, the only equivalent for R is the object browser in JGR (http://jgr.markushelbig.org/). Otherwise I just use the search() and ls...

How come there is no 64bit build of R for Windows?

How come R does not have a 64bit windows pre-built binaries? ...

Dealing with time-periods such as 5 minutes and 30 seconds in R

Hi, Is there a good way to deal with time periods such as 05:30 (5 minutes, 30 seconds) in R? Alternatively what's the fastest way to convert it into an integer with just seconds? I can only convert to dates and can't really find a data type for time. I'm using R with zoo. Thanks a lot ! Seconds was the best way to deal with thi...

using RSPython in MacOSX

Dear all, I am trying to install the R/SPlus - Python Interface (RSPython) on my Mac OS X 10.4.11 with R version 2.7.2 (2008-08-25) and python 2.6.2 from fink. The routine: sudo R CMD INSTALL -c RSPython_0.7-1.tar.gz produced this error message: * Installing to library '/Library/Frameworks/R.framework/Resources/library' * Installin...

Getting data from text file (separated by spaces) using variable lengths into R

I have a text file similar to this (separated by spaces): x <- "DF12 This is an example 1 This DF12 This is an 1232 This is DF14 This is 12334 This is an DF15 This 23 This is an example " and I know the field lengths of each variable (there is 5 variables in this data set), which are: varlength <- c(2, 2, 18, 5, 18) How can I impor...

gls() vs. lme() in the nlme package

In the nlme package there are two functions for fitting linear models (lme and gls). What are the differences between them in terms of the types of models that can be fit, and the fitting process? What is the design rational for having two functions to fit linear mixed models where most other systems (e.g. SAS SPSS) only have one? ...

Getting LaTeX into R Plots

I would like to add LaTeX typesetting to elements of plots in R (e.g., the title, axis labels, annotations, etc.) using either the combination of base/lattice or with ggplot2. Is there a way to get LaTeX into plots using these packages, and if so, how is it done? If not, are there additional packages needed to accomplish this. For exa...

Using Rmpi on CentOs

I cant seem to get Rmpi to work on CentOs, I get this: > library(Rmpi) Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared library '/usr/lib64/R/library/Rmpi/libs/Rmpi.so': libmpi.so.0: cannot open shared object file: No such file or directory Error in library(Rmpi) : .First.lib failed for 'Rmpi' Error in dyn.un...