r

Levels not present when handling 1,0,NA

Hi! Here I am with an other newbie question. I am importing a CSV file that looks like this: "username","interest","has_card" "test01","not_interesting",1 "test02","maybe_interesting",0 "test03","not_interesting",0 "test04","maybe",1 mydata <- read.table(file("test.csv", encoding = "UTF-8"), header=TRUE, sep=",") Then (maybe it soun...

Keeping Track of Word Proximity.

I am working on a small project which involves a dictionary based text searching within a collection of documents. My dictionary has positive signal words (a.k.a good words) but in the document collection just finding a word does not guarantee a positive result as there may be negative words for example (not, not significant) that may be...

How do you write your package documentation?

I haven't quite figured out a sensible workflow for building packages and writing their documentation. I want as much of the process (and the documentation) as possible to be automatically generated. The obvious way to do this seems to be to use package.skeleton to create the basic package files, then programmatically overwrite the DES...

Barplot visualization for a survey question based on checkboxes

Hi! I have to make a report of a survey where we have a question like this (all answers are checkboxes). What is you favorite cake(s) (please choose more than one): [] Tiramisù [] Carrot Cake [] Cupcake Then the survey software exports into CSV like this: "username","likes_tiramisu","likes_carrotcake","likes_cupcake" "test01",1,1,1 ...

Python and rpy2: How do I adjust/clear a graphic during runtime?

I'm using rpy2 to do data analysis and plotting in python. It works fine except for the fact that when I draw a plot, it's window hangs around until the program terminates. Is there a way to clear the plot during runtime? Additionally, If I ever resize the window, the plot disappears, but the window remains. When using R interactively, r...

multiplying all elements of a vector in R

I want a function to return the product of all the values in a vector, like sum but with multiplication instead of addition. I expected this to exist already, but if it does I can't find it. Here's my solution: product <- function(vec){ out <- 1 for(i in 1:length(vec)){ out <- out*vec[i] } out } This behaves t...

How do I uninstall rapache?

I want to uninstall rapache, make uninstall doesn't seem to do anything and a look at the rapache documentation and a google search turns up nothing. Any help would be great ...

How do I create a list of vectors in Rcpp?

Hi all. I'm writing an Rcpp module an would like to return as one element of the RcppResultSet list a list whose elements are vectors. E.g., .Call("myfunc")$foo should be something like: [[1]] [1] 1 [[2]] [1] 1 1 [[3]] [1] 1 1 1 (the exact numbers are not important here). The issue is that I don't know the right Rcpp way of doi...

Clustering with bigkmeans from bigmemory package in R?

I recently started experimenting with the biganalytics package for R. I ran into a problem however... I am trying to run bigkmeans with a cluster number of about 2000 e.g clust <- bigkmeans(mymatrix, centers=2000) However, I get the following error: Error in 1:(10 + 2^k) : result would be too long a vector Can someone maybe give me a...

[R] How to create multi-panels plots with scatterplot/xyplot and POSIX time objects?

Hi! A newbie question. (ADDED NEW INFO) I have a set of time stamped data that were collected randomly. I like to create a matrix of plots, but I could not create using either scatterplot or xyplot & time objects. my data dataset$Time #POSIX time objects (no set sampling period) #i built POSIX time objects by dataset$T...

Representing a "radiomatrix" question from a survey.

Hi I am making a report of a survey where we have what we call a "radiomatrix" and it looks like this. Then we import the answers is a table in R into something that looks like this: user tiramisu cupcake chocolate carrot test01 loves_it loves_it loves_it hate_it test02 likes_it likes_it loves_it likes_it test03 lik...

R: turning list items into objects

I have a list of objects that I've created manually, like this: rand1 <- rnorm(1e3) rand2 <- rnorm(1e6) myObjects <- NULL myObjects[[1]] <-rand1 myObjects[[2]] <-rand2 names(myObjects) <- c("rand1","rand2") I'm working on some code that bundles up objects and puts them up in S3. Then I have code in EC2 that I want to grab the myObjec...

Add objects to package namespace

I'd like to push a function inside a package namespace so it can access internal objects of that package (let's use stats package as an example). I've tried using myfun <- function(x) print(x) env = loadNamespace("stats") assign("myfun", myfun , env) But it is locked. So I've tried to unlock my object unlockBinding("myfun", env) Si...

Trimming a huge (3.5 GB) csv file to read into R

So I've got a data file (semicolon separated) that has a lot of detail and incomplete rows (leading Access and SQL to choke). It's county level data set broken into segments, sub-segments, and sub-sub-segments (for a total of ~200 factors) for 40 years. In short, it's huge, and it's not going to fit into memory if I try to simply read it...

R: Brace expansion in Sys.glob()

Is it possible to have R's Sys.glob() function expand braces? What I mean is a pattern similar to /home/foo/{a,b}/bar.txt should find files /home/foo/a/bar.txt and /home/foo/b/bar.txt should they both exist. By default R does not expand the braces. Brace expansion is possible in glob(3) with the GLOB_BRACE flag. I am guessing R is just...

How to find balanced panel data in R (aka, how to find which entries in panel are complete over given window)

I have a big panel of data from Compustat. To it I am adding some hand-collected data (seriously hand-collected from a stack of old books). But I don't want to hand-collect for the entire panel, only a randomly selected subset. To find the larger set (from which I'm randomly selecting) I would like to start with the balanced panel from C...

How can I make R take advantage of a high memory, high cpu server?

SO I've finally figured out how to get my R scripts to run on the Amazon EC2 cloud. I've been using an AMI with 26 ECUs, 8 Cores, and 69 gigs of RAM. I then divide up my code into multiple scripts, and run each one in an instance of R. With a server of this size, I can easily run 20-40 scripts simultaneously, each running several 1000 s...

Transforming R code into R style

Is there a way to write the following statement more effectively? accel is a dataframe. accel[[2]]<- accel[[2]]-weighted.mean(accel[[2]]) accel[[3]]<- accel[[3]]-weighted.mean(accel[[3]]) accel[[4]]<- accel[[4]]-weighted.mean(accel[[4]]) ...

how to integrate / link R and Computer Algebra Systems (CAS)

I'm looking for a possibility to use different 'higher' math operations in combination with R. A link or integration between R and a CAS would be the perfect solution. Which integration of R and other (math & statistic related) systems or vice verse are out there? How well do they work? What would you suggest? How expansive (in time, mo...

Best R package for doing Fourier Analysis for three dimensional function

I want to find a function that approximates a function that produces output that looks like: Blue, Red and Green are the X, Y and Z space dimensions. What R package should I use? ...