Re: [R] From long to wide format

2014-06-30 Thread arun
HI Jorge, I was able to reproduce the error.  The link below provides a way to adjust the stack. I didn't test it.  http://stackoverflow.com/questions/14719349/error-c-stack-usage-is-too-close-to-the-limit Also check this link http://stackoverflow.com/questions/13245019/how-to-change-the-stac

Re: [R] From long to wide format

2014-06-30 Thread Jorge I Velez
Hi Arun, Thank you very much for your suggestion. While running some tests, I came across the following: # sample data n <- 2000 p <- 1000 x2 <- data.frame(variable = rep(paste0('x', 1:p), each = n), id = rep(paste0('p', 1:p), n), outcome = sample(0:2, n*p, TRUE), rate = runif(n*p, 0.5, 1)) str(

Re: [R] From long to wide format

2014-06-30 Thread arun
Hi Jorge, You may try: library(dplyr) library(tidyr) #Looks like this is faster than the other methods. system.time({wide1 <- x2%>%         select(-rate) %>%         mutate(variable=factor(variable, levels=unique(variable)),id=factor(id, levels=unique(id))) %>%      s

[R] From long to wide format

2014-06-29 Thread Jorge I Velez
Dear R-help, I am working with some data stored as "filename.txt.gz" in my working directory. After reading the data in using read.table(), I can see that each of them has four columns (variable, id, outcome, and rate) and the following structure: # sample data x2 <- data.frame(variable = rep(pas