Re: [R] Convert list of data frames to one data frame

2018-07-01 Thread Ira Sharenow via R-help
My final post for thisthread! Since I first asked myquestion on Stack Overflow, I posted all the solutions along with my timingstudy there. https://stackoverflow.com/questions/50807970/converting-a-list-of-data-frames-not-a-simple-rbind-second-row-to-new-columns/51129202#51129202 Thanks again

Re: [R] Convert list of data frames to one data frame

2018-06-30 Thread Jeff Newmiller
Your request is getting a bit complicated with so much re-hashing, but here are three solutions: base only, a bit of dplyr, and dplyr+tidyr: # # input data employees4List = list(data.frame(first1 = "Al", second1 = "Jones"), data.frame(first2 = c("Al2", "Barb"),

Re: [R] Convert list of data frames to one data frame

2018-06-30 Thread Ira Sharenow via R-help
I would like to thank everyone who helped me out. I have obtained some offline help, so I would like to summarize all the information I have received. Before I summarize the thread, there is one loose end. Initially I thought library(dplyr) dplyr::bind_rows(lapply(employees4List, function(x) rbin

Re: [R] Convert list of data frames to one data frame

2018-06-30 Thread Ira Sharenow via R-help
Bert, Thanks for your idea. However, the end results is not what I am looking for. Each initial data frame in the list will result in just one row in the final data frame. In your case Row 1 of the initial structure will become 1 b 2 c3d NA NA NA NA in the end structure Row 2 of the initial s

Re: [R] Convert list of data frames to one data frame

2018-06-29 Thread Jeff Newmiller
Code below... a) Just because something can be done with dplyr does not mean that is the best way to do it. A solution in the hand is worth two on the Internet, and dplyr is not always the fastest method anyway. b) I highly recommend that you read Hadley Wickham's paper on tidy data [1]. Als

Re: [R] Convert list of data frames to one data frame

2018-06-29 Thread Bert Gunter
Well, I don't know your constraints, of course; but if I understand correctly, in situations like this, it is usually worthwhile to reconsider your data structure. This is a one-liner if you simply rbind all your data frames into one with 2 columns. Here's an example to indicate how: ## list of t

Re: [R] Convert list of data frames to one data frame

2018-06-29 Thread Ira Sharenow via R-help
Sarah and David, Thank you for your responses.I will try and be clearer. Base R solution: Sarah’smethod worked perfectly Is there a dplyrsolution? START: list of dataframes FINISH: one data frame DETAILS: The initiallist of data frames might have hundreds or a few thousand data frames. Eve

Re: [R] Convert list of data frames to one data frame

2018-06-29 Thread David Winsemius
> On Jun 29, 2018, at 7:28 AM, Sarah Goslee wrote: > > Hi, > > It isn't super clear to me what you're after. Agree. Had a different read of ht erequest. Thought the request was for a first step that "harmonized" the names of the columns and then used `dplyr::bind_rows`: library(dplyr) new

Re: [R] Convert list of data frames to one data frame

2018-06-29 Thread Sarah Goslee
Hi, It isn't super clear to me what you're after. Is this what you intend? > dfbycol(employees4BList) first1 last1 first2 last2 first3 last3 1 Al Jones 2 Al Jones Barb Smith 3 Al Jones Barb Smith Carol Adams 4 Al Jones > > dfbycol(employees4List)

[R] Convert list of data frames to one data frame

2018-06-28 Thread Ira Sharenow via R-help
I have a list of data frames which I would like to combine into one data frame doing something like rbind. I wish to combine in column order and not by names. However, there are issues. The number of columns is not the same for each data frame. This is an intermediate step to a problem and the