r

Point of latitude and longitude inside a complex spherical polygon

Question What R package has a function that can determine if a coordinate is within a closed, complex spherical polygon (i.e., a point inside a polygon on Earth's surface)? Related Links JPL: Formulae and explanation Java: Spheres software SO: Point inside or outside polygon SO: Point straddling the meridian SO: Point in polygon hit ...

version control for one-man project using eclipse?

I'm currently working on several projects on my own (at least the developing part is done only by me :). Using Eclipse with different Java, R, SQL and other source files I'm wondering what version control system would be best for me. At the time the history of Eclipse IDE seems to be enough, but I'm not sure if this will be true in a mo...

How to use ggplot2 make plot with 2 y axes, one y axis on the left, and another y axis on the right?

I need to plot a bar chart showing counts and a line chart showing rate all in one chart, I can do both of them separately, but when I put them together, I scale of the first layer (i.e. the geom_bar), is overlapped by the second layer (i.e. the geom_line), can I move the axis of the geom_line to the right? Thanks! ...

R: empirical version of pnorm() and qnorm()?

I have a normalization method that uses the normal distribution functions pnorm() and qnorm(). I want to alter my logic so that I can use empirical distributions instead of assuming normality. I've used ecdf() to calculate the empirical cumulative distributions but then realized I was beginning to write a function that basically was the ...

what's a prettier way to print info with R?

In R, I use the print function for output but I always get an ugly output. If I do print("hello world") the output is [1] "hello world" Is there a function/way to print output and just get the text I want ? Thanks ...

R: generate a repeating sequence

I need to generate a vector of the following format using R: 1:10, 1:10, 11:20, 11:20, ... 121:130, 121:130 Is there an easier way than creating 12 vectors and then repeating each one twice? ...

How to "re-arrange" the legend in ggplot2?

I have a plot with several lines representing different columns of data, the legend is being arrange as a vertical column, but I want to place it at the bottom of the chart and arrange the keys horizontally, can it be done? Thanks! ...

How to set the classpath for rJava in R?

Hi, I have a package for R which contains several jar files. For better maintenance I want to split the jars in a separate package and have the R source and two small jars in the main package. But now I always get a "NoClassDefFoundError" from rJava, if I call my functions. In the main package I have an onLoad function, which starts th...

Jitter plot in ggplot2, color by 1 variable, shade color by another variable?

Many hours of manic googling and leafing through ggplot2 documentation having brought me no closer, I was hoping someone could maybe nudge me in the right direction. I have cell count data for a few thousand subjects in a data.frame with the following layout: 1 subject per row. 1 column per cell type (5 total, each holding the percent...

R: Statistics of distribution

I have the number of samples per unit and need to calculate statistics with R. The table is like this (all rows and columns are actually filled with values, I only write a few here for easier visibility, and there are many more columns): Hour 1 2 3 4 H1 72 11 98 65 H2 19 27 H3 H4 H5 : H200000 I....

Compute Column in R

Hi All, What is the difference between the two statements below. They are rendering different outcomes, and since I am trying to come to R from SPSS, I am a little confused. ds$share.all <- ds[132]/ ds[3] mean(ds$share.all, na.rm=T) and ds$share.all2 <- ds$col1/ ds$Ncol2 mean(ds$share.all2, na.rm=T) they render the same mean, b...

Fitting a binormal distribution in R

As from title, I have some data that is roughly binormally distributed and I would like to find its two underlying components. I am fitting to the data distribution the sum of two normal with means m1 and m2 and standard deviations s1 and s2. The two gaussians are scaled by a weight factor such that w1+w2 = 1 I can succeed to do this u...

R: Creating a CSV out of serialized objects

I'm trying to take a list and serialize each item and put it into a CSV file with a key to create a text file with key/value pairs. Ultimately this is going to run through Hadoop streaming so before you ask, I think it really does need to be in a text file. (but I'm open to other ideas) This all seemed seemed pretty straight forward at f...

Decision Trees For Document Classification

Hi I wanted to know that is it possible to use decision trees for document classification and if yes then how should be the data representation be? I know the use of R package party for Decision Trees. ...

Minimum bounding rectangle of a circle on a sphere

What R packages are available to calculate the minimum bounding box for a great circle? For example: box <- polycirc( c( longitude, latitude ), distance=35 ) This would return the bounding box for the circle with a radius of 35 kilometres from the central point at the given coordinates (on Earth). Where: box.longitude_min = The l...

R summing in vectorized statements

I have the following statement. I seem to have to repeat myself by writing out the numbers myself. Using seq(-1,-9,-1) or -1:-9 doesn't seem to work. Is there another way to speak with R? difnormsum<-rowSums(data.frame(difnorm[[1]][-nrow(difnorm)],difnorm[[1]][-1], difnorm[[1]][-2],difnorm[[1]][-3],difnorm[[1]][-4],difnorm[[1]][-5]...

How can I get the actual vectors generated from bootstrapping using tsboot?

I need to get the actual list of elements used to generate each resampled statistic. To keep things really easy, I generated 100 random numbers and wanted to get the mean of each sample using tsboot from the boot package. x <- rnorm(100) y <- tsboot(x, mean, R=10, l=20, sim="fixed") What I need is the 10 lists of 20 numbers generated ...

R: serialize base64 encode/decode of text not exactly matching

in my previous question about using serialize() to create a CSV of objects I got a great answer from jmoy where he recommended base64 encoding of my serialized text. That was exactly what I was looking for. Oddly enough, when I try to put this in practice I get results that look right but don't exactly match what I ran through the serial...

Multiple Recodes in R

Hi all, I am looking to recode a large number of variables, and figure I can probably use some sort of loop to do so. What throws me is how to programmatically name each variable (I just want to keep the var name and append ".rc". Here is an example. Lets say I have a set of variables, var.1 to var.5. I am looking to create a new va...

How is the intercept computed in the GLM fit ?

Hi! I have been reading the code used by R to fit a generalized linear model (GLM), since the source-code of R is freely available. The algorithm used is called iteratively reweighted least squares (IRLS), which is a fairly documented algorithm. For each iteration, there is a call to a Fortran function to solve the weighted least square...