r

Plotting percent of resources vs percent of creators

I'd like to create a showing the degree of concentration of resources creation among the users of a web application. The plot would have % of resources on the y axis, and % (percentile?) of users on the x axis. This feels like a cumulative distribution, but my experiments with the empirical cdf in the stats package aren't getting me wha...

Reading JSON arrays from R

Then I read JSON files from R using rjson it seems that JSON arrays (enclosed with []) are converted to (unnamed) R lists, not vectors. Therefore I have to first unlist(recuresice=F) each of those lists before I can work with them. Is there any logic behind this conversion I am missing? I mean, why use a list (and not a vector) to st...

overriding a method in R, using NextMethod

how dows this work in R... I am using a package (zoo 1.6-4) that defines a S3 class for time series sets. I am writing a derived class where I want to override a few methods and can't get past this one:[.zoo! in my derived class rows are indexed by timestamp, like in zoo, but differently from zoo, I allow only POSIXct values in the in...

Basic data organization in R

I noticed I encounter this task quite often when programming in R, yet I don't think I implement it "pretty". I get a list of file names, each containing a table or a simple vector. I want to read all the files into some construct (list of tables?) so I can later manipulate them in simple loops. I know how to read each file into a tabl...

What causes an R script to get Killed?

I've been running some memory intensive processes on EC2 servers. The code runs quite well for about 12-14 hours (it's running 1000s of simulations on 12-14 large datasets) and then all of a sudden I just see the message "Killed" with no further explanation. What makes R do that? UPDATE: My server specs. ...

Finding the web address of a Javascript link

Hi all, I am using RCurl in R to try and download data from a website, but I'm having trouble finding out what URL to use. Here is the site: http://www.invescopowershares.com/products/holdings.aspx?ticker=PGX See how in the upper right, above the displayed sheet, there's a link to download the data as a .csv file? I was wondering ...

odbcConnectExcel function from RODBC package for R not found on Ubuntu

Installing the RODBC package on Ubuntu is a bit of a kludge. First I learned to install the following: $ sudo apt-get install r-cran-rodbc That wasn't good enough as the package was still looking for header files. I solved this issue by: $ sudo apt-get install unixodbc-dev Good, RODBC installed properly on the Ubuntu machine. But ...

ggplot and R: Two variables over time

I'd like to know how to make it so that x and y, in the following example data set are plotted on the vertical axis for each element of frame in the horizontal axis. How do I do this with ggplot2? x, y = variables, frame = YYYYMM Example Data: df <- structure(list(x = c(0.000892333625290767, 0.0161153931761482, 0.0188150880795816, 0...

Update Blues: install.packages("XXX")

So I recently (1 hour ago) updated to a 64-bit version of R and tried installing some of my trusty packages in the fresh install (Windows seperates 64/32 bit programs now in two program folders). Is there a work around for this? Warning message: In getDependencies(pkgs, dependencies, available, lib) : package ‘RMySQL’ is not availabl...

Igraph: Obtain the longest geodesic distance.

Hi, everybody! My question is the following: Consider a undirect graph with 10000 nodes and 4800 edges. Given this graph and given a node of this graph (for example, node 1), I need a command in igraph (R) to obtain the distance between this node 1 and the farest node in the graph, please. Thanks a lot, for your help! :) Kind regards, ...

Tcl/Tk: Maximize window / determine if window is maximized?

Can I find out if my toplevel window is maximized, and can I maximize it programmatically? I am using R's tcltk package 8.5 on Windows XP. The reason for the question is: I want to enforce a <Visibility> event by calling first withdraw and then deiconify. However, if the window was maximized before these two function calls, it is not af...

Avoiding a loop when entry i might take the value of entry i-1

I have vectors with mostly NA entries. I want to replace every NA with that vector's preceding non-NA entry. Specifically, the first entry will always be a 1, followed by a bunch of NAs, which I want to replace with 1. The ith entry could be another numeric, let's say 2, followed by more NAs that I want to replace with 2. And so on. The ...

complex eigenvectors

How does R represent complex eigenvectors? For example: > eigen(matrix(c(2,1,0,2),2,2)) $values [1] 2 2 $vectors [,1] [,2] [1,] 0 4.440892e-16 [2,] 1 -1.000000e+00 This does not indicate that eigenvector is complex. So how can I determine if eigenvector returned by R is real or not? ...

eigenvectors when A-lx is singular with no solution

How is R able to find eigenvectors for the following matrix? Eigenvalues are 2,2 so eigenvectors require solving solve(matrix(c(0,1,0,0),2,2)) which is singular matrix with no solution. > eigen(matrix(c(2,1,0,2),2,2)) $values [1] 2 2 $vectors [,1] [,2] [1,] 0 4.440892e-16 [2,] 1 -1.000000e+00 > solve(matrix(c(0,1,0,0),...

Converting time string to time or numeric format

I have a time column in the format of 00:00 00:30 01:00. I want to subset to certain hours but I don't understand how to convert it to the right format for the date i used as.date() is there someting similar? ...

Parsing command line arguments in R scripts

Is there any convenient way to automatically parse command line arguments passed to R scripts? Something like perl's Getopt::Long? ...

Are `=` and `<-` exactly the same in R?

Possible Duplicate: Assignment operators in R: = and <- Is it just a style preference? As far as I can tell, they are the same. I see many people prefer the "longer" <- version and I can't tell why (perhaps keeping away from = and == confusions?) ...

push to list in R

OK, this really basic. How do I add an element to a (named) list in R? EDIT when the key name is a varibale for (name in names(list$filenames)) { filename <- list$filenames[[name]] x <- read.table(filename) ret$name <- x # I want name to be interpreted here, not use "name" } ...

number of distinct eigenvectors in R

There are 2 eigenvectors corresponding to 1 eigenvalue (with multiplicity 4) for the following example. However, R returns 4 distinct eigenvectors. It looks like pairs of them are approximately the same only differing in machine floating point error (epsilon). Can you please check and confirm? > B [,1] [,2] [,3] [,4] [1,] 2 0 ...

Multi-level lists in R

Do I need to initialize each level of a multi-level list in R? l=list() l[["top"]]=list() l[["top"]][["mid"]]=list() l[["top"]][["mid"]][["low_key_1"]]="key_1_val" or is possible to apply some auto-initialization like on perl? ...