r

losing stdout in R console on Mac OS X

I'm working on a big Sweave document/script on a Mac OS X system, R version 2.9.2. Under some circumstances, it appears as if Sweave is redirecting stdout, so that x <- 1; print(x) gives nothing at all. (The console is still running, as plot(x) pops up a plot as normal.) So, two questions: How do I force stdout to go back to the consol...

Highlighting specific values in R plot

In R (statistical computing environment) I would like on a generic plot, with time on the x-axis, highlight some specific years. How can I bestly do this? My idea is for example a light yellow bar for the highlighted years, behind the plot of course. The plot code I have now: pdf("temperature_imfs_big_interm5.pdf", width=6, height=8);...

Counting the Number of Elements With The Values of x in a Vector?

This is a simple problem, but for the life of me I cannot find the answer. I have a vector of numbers: numbers <- c(4,23,4,23,5,43,54,56,657,67,67,435,453,435,324,34,456,56,567,65,34,435) I want to R to count the number of times a value "x" appears in the vector. Any help? ...

is there in R any standard logging package?

not only is googling R so terribly difficult, log4r has also been taken for Ruby! I am looking for the standard (if any) logging package for R. and some sample usage? I also don't see it in http://cran.r-project.org/web/packages/ (late edit: it is now at its place on CRAN and there's a R-Forge page for it.) ...

BEGINNER: extracting subsets of data

Hello, this seems to be an easy task really, but being completely new to the world of programming, I have problems with the following task: I have a huge file which has the following format: track type= wiggle name09 variableStep chrom=chr1 34 5 36 7 54 8 variableStep chrom=chr2 33 4 35 2 78 7 this is text with the word random in...

Conditional Column Creation

I have a data frame with two columns (data will not always be identical). 1 1 2 2 3 3 0 0 -1 -1 -2 -2 -3 -3 What I would like to do is create another column for the top 10% of the column and the bottom 10% of the column to be used as labels for a scatter plot. 1 1 2 2 3 3 1 0 0 -1 -1 -2 -2 -3 -3 2 In addition, it need...

Plot Histogram with Points Instead of Bars

Here is a question for R-users. I am interested in drawing a histogram with points stacked up, instead of a bar. For example if the data is (1,1,2,1,2,3,3,3,4,4), then I would like to see three points stacked up at 1, 2 points stacked up at 2 and so on. What is the best way to do this in R? ...

Repositioning scatter plot labels in ggplot2

Is it possible to reposition the labels such that in sector (-x,y) the label is on the left and sector (+x,y) the label is on the right? ...

Error in jpeg(a_paste_function) : too many open devices

I am trying to output about 250 plots from an r-script and I'm receiving this error. Is there some setting that I can adjust to avoid this problem? Here is an example of how I am creating the plots: for(x in 250) { plots <- ggplot(data=dat, aes(x,y,lab=labels)) jpeg(a_paste_function) print(plots) } One thing I notice is that, whe...

When to choose R vs. SciPy?

What are some advantages and disadvantages to doing statistical analyses in SciPy vs. R? They seem to have been designed with opposite philosophies (plain old library vs. DSL). What are some rules of thumb about which is the right tool for the job? ...

What is your preferred style for naming variables in R?

Which conventions for naming variables and functions do you favor in R code? As far as I can tell, there are several different conventions, all of which coexist in cacophonous harmony: 1. Use of period separator, e.g. stock.prices <- c(12.01, 10.12) col.names <- c('symbol','price') Pros: Has historical precedence in the R...

R: How do I best create a function that sums

With R. For a sequence of numbers x, how do I best create a function S(x, r, s) that computes sum(x[t]*x[t+r-s], t ranges from s to length(x)-r+1; r,s>0. Thanks. ...

Given a time series for many unique IDs, I need the top 100 deltas for each period

I have a time series of data in TSV like so: ID \t Date \t Value ------------------------------- 1234567 \t 2009-01-01T00:00:00.000Z \t 121 12131 \t 2009-06-01T00:00:00.000Z \t 151 12131 \t 2009-07-01T00:00:00.000Z \t 15153 ... It easily fits in RAM, but is too big for Excel. There is one value per month per ID, but not all IDs have ...

Strange error when building R packages for Windows

On one of my PCs, when I build any R package I get the following fatal error * checking for file 'forecast/DESCRIPTION' ... OK * preparing 'forecast': * checking DESCRIPTION meta-information ... OK * cleaning src * removing junk files * checking for LF line-endings in source and make files * checking for empty or unneeded directories * ...

creating a pdf in R that is vertically justified

Question: how can you create a pdf where the output is vertically justified, with for example, a one inch margin on top using pdf(). For example in pdf(file='test.pdf', paper='letter', pagecentre=F) ### code for plot here ### dev.off() is there an option where it generate output that starts from the top of the page rather than print...

R and Daily Projects

I'm now reading some books of R, but I want to know if I can use this language as I use Perl or Ruby. Things like: Image Processing File Compression Use APIs Interact With Internet But it's usual and simple(as in Perl or Ruby) to do things like this? PS: I liked this language very much, because of this I want to use it on my persona...

Inner sort with R - Once by numeric then by alpha

Hello and Happy Ho Ho, I have a data.frame, like this: nums<-c(5,7,8,9,10,3,2,1) text<-c("a","b","c","d","a 09","b 09","c 09","d 09") this <- data.frame() this <- cbind(text,nums) "a" 5 "b" 7 "c" 8 "d" 9 "a 09" 10 "b 09" 3 "c 09" 2 "d 09" 1 a:d = data from 2010, a 09:d:09 = data from 2009. I'd like it to be sorted first b...

Importing data from an XML file into R

I want to import an XML file from polarpersonaltrainer.com that stores heartrate data into a R data.frame. Is there a package that makes importing XML easy or do I have to write my own parser? ...

R Ports For Mobile Devices

I'm learning R and like the language very much because of its flexibility, but I want to know: Are there any ports of R for mobile devices? Where can I get them? ...

Turning a list of characters that contain numbers into integers in R

Is there a faster way in R to turn a list of characters like c("12313","21323") into a integer list like c(12313, 21323) than writing a for loop myself? ...