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
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"),
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
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
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
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
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
> 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
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)
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
10 matches
Mail list logo