r

Barplot Error in R

Hello Everyone, I recently created a barplot in R using some sample data with no trouble. Then I tried it again using the real data which was exactly the same as the sample data except there was more of it. The problem is now I get this error: Error in barplot.default(table(datafr)) : 'height' must be a vector or a matrix I don't...

Different legends and fill colours for facetted ggplot?

Hello, Sorry for not included any example data for my problem. I couldn’t find a way to easily produce an example shape file. Hopefully, experienced users of ggplot can see what I’d like to do from the description below. I’ve got: A data frame X with information about sample plots (plotid, var1, var2, var3, var4,…) A polygon shapefil...

Splitting a column in an R dataframe.

Hello, I have a column of data in a R data frame that has values such as Blue-#105 Green-#8845 Yellow-#5454 Blue-#999 I want to remove the last number part (starting at -#) so that Blue-#999 and Blue-#105 are consider the same thing when plotting. How could I accomplish this? Thanks so much ...

Subsetting data in python

Hi, I want to use the equivalent of the subset command in R for some python code I am writing. Here is my data: col1 col2 col3 col4 col5 100002 2006 1.1 0.01 6352 100002 2006 1.2 0.84 304518 100002 2006 2 1.52 148219 100002 2007 1.1 0.01 6292 10002 2006 1.1 0.01 5968 10002 2006 1....

r points in polygons

I have a million points and a large shape file 8gb which is too big for to load into memory in R. The shape file is single-layer so a given x,y will hit at most one polygon - as long as it's not exactly on a boundary! Each polygon is labelled with a 'severity' - e.g. 1,2,3. I'm using R on a 64-bit ubuntu machine with 12gb ram. What's...

ggplot2 Labeling a multilayered bar plot

What I'd like to do is label both of the geom_bar() 's in the following example with their respective data labels. So far, I can only get one or the other to show up: dput(): x <- structure(list(variable = c("a", "b", "c"), f = c(0.98, 0.66, 0.34), m = c(0.75760989010989, 0.24890977443609, 0.175125)), .Names = c("variable", "f", "m...

Not reading the data the right way?

I think I'm not asking the right question to begin with. New Question: I have a 1.5gig tsv file. It has 6 lines of junk at the top and one line of junk at the bottom, all of which I want to remove without having to open the file. Line 7 are the headers. I have 13 headers. Number of rows is unknown. How do I read the file into a datafra...

R: Revolution Analytics max-mem-size?

Hello I can specify the maximum amount of memory used by R or by an object in R with parameters such as --max-mem-size=1400M at command line. But how can I use it with Revolution Analytics? I've tried but it seems not no accept any parameter. I've also tried to look for configuration files, unsuccesfully. ...

Getting R plot type "b"

Hi, is there a way in ggplot2 to get the plot type "b"? See example: x <- c(1:5) y <- x plot(x,y,type="b") Ideally, I want to replace the points by their values to have something similar to this famous example: EDIT: Here some sample data (I want to plot each "cat" in a facet with plot type "b"): `df <- data.frame(x=rep(1:5,9),...

Cleaning up a barplot in R

Hello friendly computer people, I'm new to R and am getting a bit lost in the vast world of setting plot parameters. Currently I have a barplot that looks like this. My main issue is cleaning up the graph so that each bar is associated with a category. Right now the fonts are set so they overlap and don't show all the categories. In ot...

Install R packages from binary in Ubuntu Lucid

I've installed R in Ubuntu Lucid with the command sudo aptitude install r-base When I try to "install.packages" it seems to download source and then spend ages compiling it. How can I get it to just download and install the binaries, like I'm used to on Windows? Is there any need to compile the packages myself? I'm running insi...

Removing a particular category from a data frame in R

Hello nice people, I have a single column in a data frame in R that looks something like this: blue green blue yellow black blue green How do I remove all the rows that indicate blue? Please keep in mind that I don't want a NULL value represented in that row: I want the entire row removed. Thank you :) ...

Fast vector math in Clojure / Incanter

I'm currently looking into Clojure and Incanter as an alternative to R. (Not that I dislike R, but it just interesting to try out new languages.) I like Incanter and find the syntax appealing, but vectorized operations are quite slow as compared e.g. to R or Python. As an example I wanted to get the first order difference of a vector u...

List to integer or double in R

I have a list of about 1000 single integers. I need to be able to do some mathematical computations, but they're stuck in list or character form. How can I switch them so they're usable? sample data : y [[1]] [1] "7" "3" "1" "6" "7" "1" "7" "6" "5" "3" "1" "3" "3" "0" "6" "2" "4" "9" [19] "1" "9" "2" "2" "5" "1" "1" "9" "6" "7" "4...

Linear Model with Constraints, [R]

Hi all, I'm quite new to R and I have a following problem: I have a simple 2-factor linear model: Rate~factor1 + factor2 //factor1 has 8 categorical values, factor2 has 6 categories; model1 <- lm(Rate~factor1+factor2, data=myData) And want to put constraints SUM of factor1 coefficients = 0, the same for factor2. None of the manual...

vcovHC and confidence interval

Is it possible to have confint use the robust vcov obtained by vcovHC (from the sandwich package) after fitting a model? ...

Count number of vector values in range with R

In R, if you test a condition on a vector instead of a scalar, it will return a vector containing the result of the comparison for each value in the vector. For example... > v <- c(1,2,3,4,5) > v > 2 [1] FALSE FALSE TRUE TRUE TRUE In this way, I can determine the number of elements in a vector that are above or below a certain numb...

Tools Commonly used to Program in R

I apologize if this has already been asked a different way but I couldn't find anything getting at what I wanted. I am really getting into R from other packages (SPSS). As I learn about what truly can be done, I realize that there are additional "tools" that I need. This gets me to my question. What setup do you have for developing ...

gtkProgressBar in RGtk2

Hi everyone, I am trying to add a gtkProgressBar to a little interface I created for an R script (using the RGtk2 package). If I do something simple, as: for (i in 1:50) { gtkProgressBarSetFraction(progress, i/50) Sys.sleep(1) } everything runs smoothly and the bar is updated every second. However, when I go to my ac...

show data that exists in both MYSQL tables and/or R objects

Hi guys, i think its an regular problem, answered several times, but I just don't know how to ask the question right =( in MySQL: i have 2 tables with some kind of strings inside, now i want: 1. the data that occur in both tables 2. the data from a that is not in table b same in R: i have 2 R data.frame s and i want: 1. the data that...