r

Scatter plot with indication of the density of points.

R's qplot function has a nifty alpha parameter for shading coincident points in a scatter plot darker. Here it is in action: http://www.decisionsciencenews.com/2010/07/01/maps-without-map-packages I'm wondering how to do the same in Mathematica. Here's code to grab the data from the above article and plot it, without the nifty shading...

Emacs, ESS, R -How did i do this?

http://picasaweb.google.com/lh/photo/F-p2qK3itxJsgj1tLLGsow?feat=directlink If you look at the picture, theres this usage bit from the R help files at the bottom in the minbuffer. howd i do that? it somehow just appeared, maybe cos i mashed the keyboard trying to run the commands. It disappeared when i restarted emacs:( thanks ...

Is it possible to jitter two ggplot geoms in the same way?

Using position_jitter creates random jitter to prevent overplotting of data points. In the below I have used the example of baseball statistics to illustrate my problem. When I plot the same data with two layers, the same jitter call jitters the geoms a bit differently. This makes sense because it presumably generates the random jitter ...

Comparing specific columns in 2 different files using R

Hi, I find myself having to do this very often -- compare specific columns from 2 different files. The columns, formats are the same, but the columns that need comparison have floating point/exponential format data, e.g. 0.0058104642437413175, -3.459017050577087E-4, etc. I'm currently using the below R code: test <- read.csv("C:/VBG...

Package compilation in R 2.11.1 fails on Windows

I recently upgraded R to 2.11.1 from 2.10.0 and now my package installation fails: $ R CMD INSTALL --build blah_1.0.tar.gz * installing to library 'c:/PROGRA~1/r/R-211~1.1/library' * installing *source* package 'blah' ... ** libs making DLL ... ... done ERROR: compilation failed for package 'blah' * removing 'c:/PROGRA~1/r/R-211~1.1...

R + ggplot: how to change options on a per-facet basis

Hi I'm using facets in ggplot2 to plot the distribution of expression in a large number of genes. My plotting commands are pretty generic: p <- ggplot(top_n,aes(x=value,fill=ptype)) p <- p + geom_density(alpha = 0.2) p <- p + facet_wrap(~probe,...) they just plot the data in top_n as distributions coloured according to the ptype varia...

Union in regular expression in R

I'm trying to use regular expressions in R to find one or more phrases within a vector of long sentences (which I'll call x). So, for example, this works fine for one phrase: grep("(phrase 1)",x) But this doesn't work for two (or more) phrases: grep("(phrase 1)+(phrase 2)+",x) As I would expect. As I read it, this last one should ...

large-scale regression in R with a sparse feature matrix

i'd like to do large-scale regression (linear/logistic) in R with many (e.g. 100k) features, where each example is relatively sparse in the feature space---e.g., ~1k non-zero features per example. it seems like the SparseM package slm should do this, but i'm having difficulty converting from the sparseMatrix format to a slm-friendly for...

Compare two data.frames to find the rows in data.frame 1 that are not present in data.frame 2

Hi all, I have the following 2 data.frames: a1 <- data.frame(a = 1:5, b=letters[1:5]) a2 <- data.frame(a = 1:3, b=letters[1:3]) I want to find the row a1 has that a2 doesn't. Is there a built in function for this type of operation? (p.s: I did write a solution for it, I am simply curious if someone already made a more crafted code)...

Is there a table comparing SQL commands with R commands ?

Or a list of how to do in R things you do in SQL (or vise versa) ? Thanks, Tal ...

Setting the background color of persp() plots

Is there any way to set the background color of plots constructed using the base R function persp()? bg="black" is ignored either when supplied to persp() or previously to par() Thanks ...

How can I get format() to return a 1-character result?

format(Sys.Date(),"%m") returns "07", but I'd like it to return "7" while still returning two characters when needed. adding width=8 to the argument list doesn't help, nor does anything else I've tried. My end goal is to make the stock quote reading function on p. 182 of R in a Nutshell work properly. ...

Recreate ggplot's geom_smooth CI background - in R basic?

Hi all, I wish to recreate this graph: (from here) Using R base graphics. I have no clue how to do that. Any advice ? (My motivation is that I wish to create a plot where the line width (and/or color) will reflect another dimension. Until now - ggplot2 is the only place I found in R for how to do this. I would be happy to be able...

R: replacing double escaped text

I'm gluing together a number of system calls using the Amazon Elastic Map Reduce command line tools. These commands return JSON text which has already been (partially?) escaped. Then when the system call turns it into an R text object (intern=T) it appears to get escaped again. I need to clean this up so it will parse with the rjson pack...

I want to generate n! permutations for a given n in R.

suppose n=3 then output should be: a vector containing vectors: 123 213 132 231 321 ...

Making R packages for installation by install.packages()

What is the difference between .tar.gz or .tgz files installed by R CMD install and install.packages()? I have made an example package with R CMD build, which I can currently install with R CMD install mypackage.tar.gz - and it works fine. I want to be able to install it through the install.packages() function (with a call like install.p...

Improvements to the base R graphics

When I'm generating graphics for publications and talks, I tend to use ggplot2. However, for very large data sets where I want to generate a quick plot or for courses where students don't have a good grounding in R, I use the base graphics. Are there any nice (simple!) ways of spicing up R graphics? For example, do you use a nice combin...

How To Create Vector of Vector In R

I have input data that contain lines like this: -0.438185 -0.766791 0.695282 0.759100 0.034400 0.524807 How can I create a data structure in R that looks like this: [[1]] [1] -0.438185 -0.766791 0.695282 [[2]] [1] 0.759100 0.034400 0.524807 ...

is there a way to get the colour theme from the R GUI into Emacs?

I find it hard to sort through all the messages in the R frame(?) in emacs, and I was wondering if it'll be easy to change the colours so that it looks more like the R GUI. Thanks ...

How can I count the number of times a value occurs in a column of a dataframe?

Is there a simple way of identifying the number of times a value is in a vector or column of dataframe? I essentially want the numerical values of a histogram but I do not know how to access it. # sample vector a <- c(1,2,1,1,1,3,1,2,3,3) #hist hist(a) Thank you. UPDATE: On Dirk's suggestion I am using hist. Is there a better way t...