Displaying 1 result from an estimated 1 matches for "itemprice".
2011 Aug 03
4
slow computation of functions over large datasets
...on is painfully slow: in
1min only about 90 rows are calculated.
The computation time taken for a given number of rows increases with the
size of the dataset, see the example with my function below:
# small dataset: function performs well
exampledata<-data.frame(orderID=c(1,1,1,2,2,3,3,3,4),itemPrice=c(10,17,9,12,25,10,1,9,7))
exampledata[1,"orderAmount"]<-exampledata[1,"itemPrice"]
system.time(for (i in 2:length(exampledata[,1]))
{exampledata[i,"orderAmount"]<-ifelse(exampledata[i,"orderID"]==exampledata[i-1,"orderID"],exampledata[i-1,&...