: Yuan Chun Ding
Cc: r-help mailing list
Subject: Re: [R] a simple reshape
Hi,
[For a non-tidyverse solution:]
Your problem is ambiguous without a 'time' variable; e.g., why should
the answer not be
test2 <- data.frame(vntr1=c("v1","v2"),
Hi,
[For a non-tidyverse solution:]
Your problem is ambiguous without a 'time' variable; e.g., why should
the answer not be
test2 <- data.frame(vntr1=c("v1","v2"),
a1 =c(NA, 0.5693),
a2 = c(0.02, 0.12),
a3 =c(NA, 0.11),
Hi Ding,
If you are still having trouble, perhaps:
library(prettyR)
stretch_df(test1,"vntr1","val")
Jim
On Sat, Apr 4, 2020 at 5:58 AM Yuan Chun Ding wrote:
>
> Hi R users,
>
> I want to do a data reshape from long to wide, I thought it was easy using
> tidyverse spread function, but it did no
Friday, April 3, 2020 12:08 PM
To: Yuan Chun Ding; r-help mailing list
Subject: Re: [R] a simple reshape
Hello,
It's a bit more complicated than you have coded it.
I will use pivot_wider, it's now the natural way of doing it.
test1 %>%
group_by(vntr1) %>%
mutate(g
quot;vntr1", names_from = "group",
>names_prefix = "a", :
> could not find function "pivot_wider"
>
>From: Rui Barradas [ruipbarra...@sapo.pt]
>Sent: Friday, April 3, 2020 12:08 PM
>To: Yuan Chun Ding; r-help mai
Rui Barradas [ruipbarra...@sapo.pt]
Sent: Friday, April 3, 2020 12:08 PM
To: Yuan Chun Ding; r-help mailing list
Subject: Re: [R] a simple reshape
Hello,
It's a bit more complicated than you have coded it.
I will use pivot_wider, it's now the natural way of doing it.
test1 %>
Hello,
It's a bit more complicated than you have coded it.
I will use pivot_wider, it's now the natural way of doing it.
test1 %>%
group_by(vntr1) %>%
mutate(group = row_number()) %>%
ungroup() %>%
pivot_wider(
id_cols ="vntr1",
names_from = "group",
names_prefix = "a",
Hi R users,
I want to do a data reshape from long to wide, I thought it was easy using
tidyverse spread function, but it did not work well. Can you help me?
Thank you,
Ding
test1 data frame is long file and test2 is the wide file I want to get
test1 <- data.frame (vntr1=c("v1","v1", "v2","v2"
8 matches
Mail list logo