rbind

Memory efficient alternative to rbind - in-place rbind?

元气小坏坏 提交于 2019-12-02 22:02:13
I need to rbind two large data frames. Right now I use df <- rbind(df, df.extension) but I (almost) instantly run out of memory. I guess its because df is held in the memory twice. I might see even bigger data frames in the future, so I need some kind of in-place rbind. So my question is: Is there a way to avoid data duplication in memory when using rbind? I found this question , which uses SqlLite, but I really want to avoid using the hard drive as a cache. Ari B. Friedman data.table is your friend! C.f. http://www.mail-archive.com/r-help@r-project.org/msg175877.html Following up on nikola's

Rbind corresponding elements in two or more lists in R

会有一股神秘感。 提交于 2019-12-02 18:08:04
问题 I have 3 lists, each with 500 elements. Here for demonstrative purposes, I have 2 lists with 1 element each: structure(list(timeseries = c(1, 7, 59), t = c(1, 3, 7)), .Names = c("timeseries", "t"), row.names = c(NA, 3L), class = "data.frame") structure(list(timeseries = c(5, 6, 7), t = c(8, 9, 10)), .Names = c("timeseries", "t"), row.names = c(NA, 3L), class = "data.frame") My aim is to rbind the first element in list 1 with the first element in list 2 and 3. Then, the second element in list

R, rbind with multiple files defined by a variable

南笙酒味 提交于 2019-12-02 16:29:59
问题 First off, this is related to a homework question for the Coursera R programming course. I have found other ways to do what I want to do but my research has led me to a question I'm curious about. I have a variable number of csv files that I need to pull data from and then take the mean of the "pollutant" column in said files. The files are listed in their directory with an id number. I put together the following code which works fine for a single csv file but doesn't work for multiple csv

Rbind corresponding elements in two or more lists in R

喜你入骨 提交于 2019-12-02 10:47:13
I have 3 lists, each with 500 elements. Here for demonstrative purposes, I have 2 lists with 1 element each: structure(list(timeseries = c(1, 7, 59), t = c(1, 3, 7)), .Names = c("timeseries", "t"), row.names = c(NA, 3L), class = "data.frame") structure(list(timeseries = c(5, 6, 7), t = c(8, 9, 10)), .Names = c("timeseries", "t"), row.names = c(NA, 3L), class = "data.frame") My aim is to rbind the first element in list 1 with the first element in list 2 and 3. Then, the second element in list 1 with the second element in list 2 and 3. And so on. In my example, I would end up with a list of this

R, rbind with multiple files defined by a variable

我的未来我决定 提交于 2019-12-02 08:35:37
First off, this is related to a homework question for the Coursera R programming course. I have found other ways to do what I want to do but my research has led me to a question I'm curious about. I have a variable number of csv files that I need to pull data from and then take the mean of the "pollutant" column in said files. The files are listed in their directory with an id number. I put together the following code which works fine for a single csv file but doesn't work for multiple csv files: pollutantmean <- function (directory, pollutant, id = 1:332) { id <- formatC(id, width=3, flag="0"

rbind dataframes from a list

喜你入骨 提交于 2019-12-02 08:33:14
问题 One of my functions return a list of dataframes which I need to concatenate into 1 single dataframe. I do this using: do.call(rbind,list_df) This used to work as expected. But for some strange reason (which is driving me nuts!) it no longer does. Now, instead of combining into a single df, it just retains it as separate lists. When I print the output this is what I get (the list had 2 dataframes with 5 columns each, and the output is retained as such without concatenation) out_df [1,] List,5

adding rows to data.frame conditionally

喜欢而已 提交于 2019-12-02 02:59:41
问题 I have a big data.frame of flowers and fruits in a plant for a 30 years survey. I want to add zeros (0) in some rows which represent individuals in specific months where the plant did not have flowers or fruits (because it is a seasonal species). Example: Year Month Flowers Fruits 2004 6 25 2 2004 7 48 4 2005 7 20 1 2005 8 16 1 I want to add the months that are not included with values of zero so I was thinking in a function that recognize the missing months and fill them with 0. Thanks. 回答1:

add missed value based on the value of the column in r

十年热恋 提交于 2019-12-02 01:14:37
This is my sample dataset: vector1 <- data.frame( "name" = "a", "age" = 10, "fruit" = c("orange", "cherry", "apple"), "count" = c(1, 1, 1), "tag" = c(1, 1, 2) ) vector2 <- data.frame( "name" = "b", "age" = 33, "fruit" = c("apple", "mango"), "count" = c(1, 1), "tag" = c(2, 2) ) vector3 <- data.frame( "name" = "c", "age" = 58, "fruit" = c("cherry", "apple"), "count" = c(1, 1), "tag" = c(1, 1) ) list <- list(vector1, vector2, vector3) print(list) This is my test: default <- c("cherry", "orange", "apple", "mango") for (num in 1:length(list)) { #print(list[[num]]) list[[num]] <- rbind( list[[num]],

adding rows to data.frame conditionally

走远了吗. 提交于 2019-12-02 01:11:16
I have a big data.frame of flowers and fruits in a plant for a 30 years survey. I want to add zeros (0) in some rows which represent individuals in specific months where the plant did not have flowers or fruits (because it is a seasonal species). Example: Year Month Flowers Fruits 2004 6 25 2 2004 7 48 4 2005 7 20 1 2005 8 16 1 I want to add the months that are not included with values of zero so I was thinking in a function that recognize the missing months and fill them with 0. Thanks. ## x is the data frame you gave in the question x <- data.frame( Year = c(2004, 2004, 2005, 2005), Month =

Convert data frame of N columns into a data frame of two 'stacked' columns

别说谁变了你拦得住时间么 提交于 2019-12-02 00:57:18
问题 Hello Stack Community. I am doing work with network analytics and have a data reshaping question. My original data comes in as a series of columns each column being a "source" and "target" pair. The final data frame needs to be made up of two columns "source" and "target". Note these pairs are staggered as they source and targets are linked as in a directed network. (See the final_output in the code example for desired output) I created a very hacky method producing the output I need (see