I have to manually collect some rows so based on the R Cookbook, it recommended me to pre-allocate some memory for a large data frame. Say my code is
dataSize <- 500000; shoesRead <- read.csv(file="someShoeCsv.csv", head=TRUE, sep=","); shoes <- data.frame(size=integer(dataSize), price=double(dataSize), cost=double(dataSize), retail=double(dataSize));
So now, I have some data about shoes which I imported via csv, and then I perform some calculation and want to insert into the data frame
shoes. Let's say the
someShoeCsv.csv has a column called
ukSize and so
usSize <- ukSize * 1.05 #for example
My question is how do I do so? Running the code, noting now I have a
usSize variable which was transformed from the
ukSize column, read from the csv file:
shoes <- rbind(shoes, data.frame("size"=usSize, "price"=price, "cost"=cost, "retail"=retail));
adds to the already large data frame.
I have experimented with doing the
list and then
rbind but understand that it is tedious and so I am thinking of using this method but still to no avail.