I have a data.frame which I believe is melted already and am having trouble casting it to 'wide' format.
It looks something like > (x <- data.frame(ticker=c(rep("A",5),rep("B",6)), date=c(1:5, 1:6), value=c(NA,100*exp(rnorm(10,0,.1))))) > cast(x, date ~ ticker) # this does what I want with toy data But when I use my real data frame > str(prices) 'data.frame': 308188 obs. of 3 variables: $ Ticker: chr "ticker1" " ticker1" " ticker1" " ticker1" ... $ Date :Class 'Date' num [1:308188] 12296 12297 12298 12299 12300 ... $ Price : num NA NA NA NA NA NA NA NA NA NA ... I get > prices.wide <- cast(prices, Date ~ Ticker, add.missing=TRUE) Error in data.frame(data[, c(variables), drop = FALSE], result = data$value) : arguments imply differing number of rows: 308188, 0 (I tried various other arguments to cast - all gave the same error message.) It is a fact that the various tickers have data for different date ranges in the data frame and there are lots of NA's, but the toy example above has different date ranges for the two tickers and an NA, so I don't know what else to look for in my data, or what args to cast might make it work. Any insights or direction would be much appreciated. David L. Reiner, PhD Head Quant Rho Trading Securities, LLC [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.