r

overlapping y-scales in facet (scale="free")...

Hello, I've been learning ggplot in the last few weeks. Generally, I'm getting things done (slowly though), but now I'm stuck. I created the following facetted plot: http://dl.dropbox.com/u/7752237/example_bad_y_scales.pdf Faceting is done by pl <- pl + facet_wrap(~sci_name,ncol=1,scale="free") The Problem: Numbers on the y-scale d...

how to extract a subset of a data frame based on a condition involving a field?

I have a large CSV with the results of a medical survey from different locations (the location is a factor present in the data). As some analyses are specific to a location and for convenience, I'd like to extract subframes with the rows only from those locations. It happens that the location is the very first field so yes, I could do it...

Dynamically generate an R lattice graph for many fields

I'm wondering if the following is possible. I have a survey with 100+ questions, all categorical, collected in 4 locations. All questions are labeled q1, q2 and so on. Let's say there are 100 for simplicity. I can visually compare the results of a particular question across locations with: library (lattice); histogram(~ q75 | location...

Cheat sheet for ggplot2?

There is lots of cheat sheets for R. Is there a cheat sheet for ggplot2? ...

Emacs ESS version of Clear Console

Is there an ESS version of the Clear Console command that can be found in the RGui(Ctrl-L)? I want to have a blank * R * buffer. ...

Can someone point me to census x11 filtering for R?

Dear all, I try to find out if x11 census type filtering is possible with R. I am pretty sure it is, but if I google or use ??x11 I only get information about the graphical device X11. Can anyone point me to some time series package respectively a function (e.g. within zoo or standard ts) that does it? thx in advance! ...

RSQLite query with user specified variable in the WHERE field

I am using a the RSQLite library in R in to manage a data set that is too large for RAM. For each regression I query the database to retrieve a fiscal year at a time. Now I have the fiscal year hard-coded: data.annual <- dbGetQuery(db, "SELECT * FROM annual WHERE fyear==2008") I would like to make the fiscal year (2008 above) to make ...

Problem with launching JAGUAR in R

Windows XP, R 2.11.1, Java JRE6 I just installed the Jaguar package. From an R console, I can do this: > library(JGR) Loading required package: rJava Loading required package: JavaGD Loading required package: iplots Please use the corresponding JGR launcher to start JGR. Run JGR() for details. You can also use JGR(update=TRUE) to upd...

Getting path of an R script

Is there a way to programmatically find the path of an R script inside the script itself? I am asking this because I have several scripts that use RGtk2 and load a GUI from a .glade file. In these scripts I am obliged to put a setwd("path/to/the/script") instruction at the beginning, otherwise the .glade file (which is in the same dire...

Subsetting a data frame based on contents of another data frame

I have two data.frames. For examples sake let's say they look like this: df1 <- data.frame(x=rep(letters[1:26], 16)) df2 <- data.frame(y=letters[1:4]) What I would like to do is subset 'df1' to contain the rows whose first column value matches any value within the first column of 'df2'. Now, I've tried: subset(df1, df1$x == df2$y)...

help me Sweave a multi-file project

Dear SOers, I am writing my thesis in LaTeX and because things got a bit long for my taste, I had split it into several files. Let's call them thesis.tex, intro.tex, mat_n_met.tex, rslts.tex and discsn.tex. I have linked intro.tex, mat_n_met.tex, rslts.tex and discsn.tex through thesis.tex with \include{intro} (and so on...). I have als...

log scale x-axis labels

The labels on the x-axis are defaulting to scientific notation no matter how small cex.axis is. How can I override scientific notation to get the labels to print out as specified? Here is the code (UNIT here is 0.0105): plot( xm,yv ,log="xy",ylim=c(0.1,20)/UNIT, xlim=c(0.004,20)*UNIT,xlab="Dose",xaxt="n",ylab="Amount",type="n") ax...

[R] Adding text to a plot

I am an R newbie and had a question. I am trying to place some text into an R plot. Here's some code using the brightness dataset in the UsingR package. library(UsingR) brightness MyMean <- mean(brightness) MyMedian <- median(brightness) MySd <- sd(brightness) hist(brightness, breaks=35, main="This is a Histogr...

Protecting function names in R

Is it possible in R to protect function names (or variables in general) so that they cannot be overwritten. I recently spotted that this can be a problem when creating a data frame with the name "new", which masked a function used by lmer and thus stopped it working. (Recovery is easy once you know what the problem is, here "rm(new)" d...

Command line Questions in R

I am building an user input interface in R. onload of the program, I would like like to ask the user what their preferences are according to a set of 6 fields. This will then be used as a comparison tool for the rest of the program. e.g., >ThisProgram >"Hello, on a scale of 1 to 10, how much would you say you rate the outdoors in y...

Can qplot directly display percentages without intermediate columns?

I have a bunch of histograms to plot on data that is still coming. As the sample sizes vary, in order to compare them I need to plot the histograms with percentages not counts. qplot (field, data=mydata, geom="histogram", binwidth=10) the above qplot displays the counts. The density option is not applicable as it divides the counts wi...

R: How to superimpose distribution curves on histograms using ggplot2 and lattice

Say, I am using facet_grid() in ggplot2 to obtain 2 histograms. Now I want to superimpose these histograms with Poisson curves (having different means for the 2 histogram plots/grids) and a second curve of another distribution (for which I want to manually provide the probability function of values). How can this be done? constructing ...

Remove all strings from a data frame in R?

Hello.... So I have a data frame in R that contains integers, NA's, and a random assortment of strings inside the cells. Only one data type per cell. What I'm wondering is how to change all of the cells that contain strings into NA. Any idea how I could do this? ...

How to evoke R home directory in file name construction?

I'm using R under Windows XP. It picked up the environmental variable HOME from windows which is > Sys.getenv("R_USER") R_USER "H:" However, how can I use that variable quickly in a file name? In particular, if I have a file stored at H:/tmp/data.txt. How should I construct the following command? data <- read.table("$R_HOME/tmp/dat...

LIM data access from R

How can one access LIM from R? ...