r

Setting up a CSV file for R to display histograms

Greetings, Basically, I have two vectors of data (let's call it experimental and baseline). I want to use the lattice library and histogram functions of R to plot the two histograms side-by-side, just as seen at the end of this page. I have my data in a CSV file like this: Label1,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 Label2,1,2...

Disable GUI, graphics devices in R

Is there an easy way to turn of all GUI elements in R and run it solely from the command line on OSX? I'm trying to replicate the behavior of a remote linux terminal on my OSX machine. Thus plot() should just save a file and things like CRAN mirror selection should be text, not a Tk interface. I'm having trouble finding where to set...

Set up large database in MySQL for analysis in R

I have reached the limit of RAM in analyzing large datasets in R. I think my next step is to import these data into a MySQL database and use the RMySQL package. Largely because I don't know database lingo, I haven't been able to figure out how to get beyond installing MySQL with hours of Googling and RSeeking (I am running MySQL and MySQ...

Using seq.Date as breaks in stat_bin for time-series

I am attempting to bin time-series data from several years of observation by month using the stat_bin function in ggplot2. The code looks like this: month.breaks<-seq.Date(from=min(afg$DateOccurred),to=max(afg$DateOccurred),by="month") # All months, for breaks report.region<-ggplot(afg,aes(x=DateOccurred))+stat_bin(aes(y=..density..,f...

derivative of a function

Hi, I am using D to get derivatives of a function. However, R does not simplify the expression when returning the derivative. I need to figure out if a function has a derivative that can be expressed generically. Is there some way in R to simplify the expression? > D(expression(sqrt(1 - x^2)), 'x') -(0.5 * (2 * x * (1 - x^2)^-0.5)) > D(...

Multiple Tables Sweave/Latex

Hi All, I am very new to LaTeX and Sweave but am excited that it may make my life much simpler when combined with R. What I am looking to do: Create multiple crosstabs, most likely in a loop. As a result, the number of tables will not be determined ahead of time and I am hoping to have a page break in between each. Lastly, for the ...

Including variables in expression call in R

Hi everyone, I was wondering if it were possible to include variables when using expression in R. For instance I would like to do something like this: par(mfrow=c(2,3)) for (i in 1:6) { plot(x, p1-i*p2, main=expression(Phi[1] - i * Phi[2])) } But this does not work, as it prints 1 - i2 (i.e. it does not substitute i with...

Cache expensive operations in R

A very simple question: I am writing and running my R scripts using a text editor to make them reproducible, as has been suggested by several members of SO. This approach is working very well for me, but I sometimes have to perform expensive operations (e.g. read.csv or reshape on 2M-row databases) that I'd better cache in the R enviro...

Including Script Files in an R Extension Package

I'm creating an R package and I need it to include a couple of non R script files which get called by one of my functions. I need these script files to be distributed with the package, naturally. So that leaves me with two questions: a) In which directory of the package tree should I place these files? b) Is that location mandatory or ...

used biocep with AWS?

Has anyone used biocep with AWS? I see a lot of presentations online but nothing that seems to do a thorough job of walking you through the process. There seems to be a lot of complexity to get your head around. I was hoping someone could point me to particularly useful forum threads or [even better] some real tutorials? ...

R: aggregate columns of a data.frame

I have a data.frame that looks like this > head(df) Memory Memory Memory Memory Memory Naive Naive 10472501 6.075714 5.898929 6.644946 6.023901 6.332126 8.087944 7.520194 10509163 6.168941 6.495393 5.951124 6.052527 6.404401 7.152890 8.335509 10496091 10.125575 9.966211 10.075613 10.310952...

Hmisc Table Creation

Just starting out with R and trying to figure out what works for my needs when it comes to creating "summary tables." I am used to Custom Tables in SPSS, and the CrossTable function in the package gmodels gets me almost where I need to be; not to mention it is easy to navigate for someone just starting out in R. That said, it seems l...

R: When using the rep(..,..) to replicate 1020 a character variables, the result contains just 1019 replicates?

When programming within the R environment I used rep("[35,40)",1020). This should give me a list with 1020 times "[35,40)". However, the result contains only 1019 of these elements. The programming was first done within a replicated for two vectors, but even when I split it up it doesn't work. What I tried is using differen versions of...

RODBC sqlSave column types: how determined?

I'm trying to understand how RODBC determines the column types of a newly created (Access) table? The R documentation of sqlSave is very cryptic: "types are selected by consulting arguments varTypes and typeInfo". And no examples for this arguments. Where can I find a better explanation? ...

[R] selecting rows

I have this d[d$Age > "2", ] and it returns all the rows that have an Age of over 2, but I want to only return the values in a few of the columns, say d$X and d$Y, not all of them. anyway i can do this? Thanks ...

writing a ".rtest" output to file, using the R program (ex) via write.table?

Hi all, I am using R to open up some saved .csv files in a particular pairwise manner and perform a statistical test ("mantel.rtest", found in the package "ade4"). The .csv files are sequentially named as either "fileAX" or "fileBY", where X and Y are integers. I'd like to save the results of this test in a single file, but am runnin...

Plotting to a file in R

I'm a complete newbie to R, and none of the introductions I've seen cover how to use R when all you've got is the command line and no windowing system. My data's on a server, and I'm working with it via ssh. In gnuplot, you can set your "display" to be a PNG file on disk. How do I plot something to a file on disk from R? R-2.9.1 on CentO...

Panel data: dealing with lagging and binary dependent variable with plm

I am attempting to run a pooled logistic regression with panel data and a binary dependent variable. Since I wanted to lag some of the variables, I used the plm package to create them. When I tried to do it other ways, I ran into problems. I can't use lag or embed, because it is panel data. hybridsubsidies <-pdata.frame(reduced, c...

Possibly inconsistent behavior in qplot() ??

I'm trying to use qplot() to plot a simple time series as one might do using plot(). The x variable is as.POSIXlt and the y is just some continuous measurement. Here is the code with some brief comments. Any help on why these data.frames behave differently would be very much appreciated. As you can see below, I can work around the pr...

help me improve my bootstrap

Consider the following code: require(Hmisc) num.boots <- 10 data <- rchisq(500, df = 5) #generate fake data #create bins binx <- cut(data, breaks = 10) binx <- levels(binx) binx <- sub("^.*\\,", "", binx) binx <- as.numeric(substr(binx, 1, nchar(binx) - 1)) #pre-allocate a matrix to be filled with samples output <- matrix(NA, nrow = n...