r

htmlParse() segfault error in R XML package: 'memory not mapped'

I am using R 2.11.1 and XML package 3.1-0, and I was going through an example from R2GoogleMaps when I encountered a segfault error. #library(RJSONIO) library(R2GoogleMaps) library(XML) #library(RCurl) load("b.rda") # find in the sampleDocs folder in source file of R2GoogleMaps center = c(mean(range(b$lat)), mean(range(b$long))) code ...

Using R to draw a time series with discrete data

Greetings, I have a table that looks like the following: date value 2007-11-05 134 2007-12-08 234 2008-03-10 322 2008-03-11 123 ... In summary, it has daily values for three years, but it doesn't have values for every day. What I need is to draw a line chart plot(data$date, data$value) for the whole time span, but considering t...

Create new dummy variable columns from categorical variable

I have a several data sets with 75,000 observations and a type variable that can take on a value 0-4. I want to add five new dummy variables to each data set for all types. The best way I could come up with to do this is as follows: # For the 'binom' data set create dummy variables for all types in all data sets binom.dummy.list<-list...

How do I fit a model without specifying the number of variables?

I have a data.frame, df, with n variables in it. The variables can take any name. I want to be able to fit coxph(Surv(time_to_event,bad_outcome)~var1+var2+...+varn,data=df) But df is a variable, its length can change. How do I write a piece of code that can fit all the variables in df regardless of the number of variables in df and the...

How to edit R library sources

I've included a library called blotter in my R script which has a bug in it. Is there an easy way for me to edit the source to try and debug the issue? ...

Clustering Photos in R?

I have a kind of general R question here: Usually with digicams we tend to click a lot of immages which may be repetitive and can waste online space while sharing on Picassa or is an overhead when trying to delete some unwanted images. Is it possible to cluster photos using R? I mean there are some clustering abilities in Matlab for ...

R in batch mode

Is it necessary to have Rtools installed for running R in Batch mode, or is it fine if i just set up the environment variable for R.exe ...

How can I change XTS to data.frame and keep Index in R?

I have an XTS timeseries in R of the following format and am trying to do some processing, subsetting and re-arranging before exporting as a CSV for work in another program. head(master_1) S_1 2010-03-03 00:00:00 2.8520 2010-03-03 00:30:00 2.6945 2010-03-03 01:00:00 2.5685 2010-03-03 01:30:00 2.3800 2010-03-03 02:00:0...

R ggplot2: using stat_summary (mean) and logaritmic scale

I have a bunch of measurements over time and I want to plot them in R. Here is a sample of my data. I've got 6 measurements for each of 4 time points: values <- c (1012.0, 1644.9, 837.0, 1200.9, 1652.0, 981.5, 2236.9, 1697.5, 2087.7, 1500.8, 2789.3, 1502.9, 2051.3, 3070.7, 3105.4, 2692.5, 1488.5, 1978.1, 1925.4, 1524.3, ...

What are R's equivalents to Perl's map and grep?

I am interested in (functional) vector manipulation in R. Specifically, what are R's equivalents to Perl's map and grep? The following Perl script greps the even array elements and multiplies them by 2: @a1=(1..8); @a2 = map {$_ * 2} grep {$_ % 2 == 0} @a1; print join(" ", @a2) # 4 8 12 16 How can I do that in R? I got this far, us...

Is it possible to read music file metadata using R ?

Hi all, I've got a bunch of audio files (let's say ogg or mp3), with metadata. I wish to read their metadata into R so to create a data.frame with: file name file location file artist file album etc Any way you know of for doing that ? ...

how to estimate parameters in a mixture of two different distributions using R or any other programming language?

I have to estimate parameters of a mixture distribution which consists of Pareto distribution and Exponential distribution. I am using maximum likelihood estimation procedure by using log likelihood function and differentiating it with respect to each parameter.Since the log likelihood equation is non linear, I have to use Newton Rhapson...

OAuth access for R

I'm trying to use R to grab some web data that requires OAuth authentication. Searching on CRAN and RSeek.org for info on OAuth + R provides nothing. Any tips for accessing RESTful APIs with R using OAuth? I'm considering using some Python/Perl/Ruby to grab the data, save it to a text file, then work on it with R. I'd prefer to stay to...

Installing Rcpp in R 2.10 on Ubuntu

I'm trying to install Rcpp on Ubuntu 10.04 and getting this error (which implies that it doesn't exist): > install.packages("Rcpp") Warning in install.packages("Rcpp") : argument 'lib' is missing: using '/home/vadmin/R/i486-pc-linux-gnu-library/2.10' Warning message: In getDependencies(pkgs, dependencies, available, lib) : package ‘...

replicating probit regression in SAS and R

I'm trying to replicate my SAS work in R, but I get slightly different results -- differences that can't be explained by rounding error. Here's my SAS code: proc qlim data=mydata; model y = x1 x2 x3/ discrete(d=probit); output out=outdata marginal; title "just ran QLIM model"; run; quit; And here's my R code: mymodel <- glm...

How to get a .csv file into R?

Hello.... I have this .csv file: ID,GRADES,GPA,Teacher,State 3,"C",2,"Teacher3","MA" 1,"A",4,"Teacher1","California" And what I want to do is read in the file using the R statistical software and read in the Header into some kind of list or array (I'm new to R and have been looking for how to do this, but so far have had no luck). ...

R and stacked area charts?

Greetings, I have three TS variables resembling something like the following: data <- read.csv(...) dataA = zoo(data$valueA, data$date) dataB = zoo(data$valueB, data$date) dataC = zoo(data$valueC, data$date) days = seq(start(dataA), end(dataA), "day") dataAts = na.locf(merge(dataA, zoo(,days))) dataBts = na.locf(merge(dataB, zoo(,day...

Recommended IDE for R under linux

Hi, I found this question from over a year ago, but I wonder if there's anthing new under the sun. Spedifically, I do not get along with Emacs so well... p.s. I use eclipse for java and perl programming. ...

difference in R between identical(x, y) and isTRUE(all.equal(x, y))

suddenly a doubt... is there any difference between testing isTRUE(all.equal(x, y)) and identical(x, y)? the help page says: Don't use 'all.equal' directly in 'if' expressions-either use 'isTRUE(all.equal(....))' or 'identical' if appropriate. but that "if appropriate" leaves me in doubt. how do I decide which of the tw...

parallel computing of a function with doSMP on Windows

I'm trying to multicore a function (in Windows), which, at one point, calls another workhorse function (function within function). Here is a minimal working example. You will need doSMP and revoIPC packages (to get them, see Tal's post here). func1 <- function(x) {sqrt(x)} func2 <- function(y) { func1(y) } library(doSMP) wrk <- sta...