essage-
> From: R-help On Behalf Of Yuan Chun Ding
> Sent: Thursday, January 7, 2021 7:40 PM
> To: r-help@r-project.org
> Subject: [R] non-standard reshape from long to wide
>
> Dear R user,
>
> I want to reshape a long data frame to wide format, I made the following
>
-standard reshape from long to wide
Hello,
Here is a dplyr solution. The main trick is to create a column of 1's, then
pipe to pivot_wider.
library(dplyr)
library(tidyr)
df.long %>%
mutate(values = 1) %>%
pivot_wider(
id_cols = sample,
names_from = marker,
values_fr
Hello,
Here is a dplyr solution. The main trick is to create a column of 1's,
then pipe to pivot_wider.
library(dplyr)
library(tidyr)
df.long %>%
mutate(values = 1) %>%
pivot_wider(
id_cols = sample,
names_from = marker,
values_from = values,
values_fill = NA
)
Note:
mevar, ... :
>
> *From:* Bert Gunter [mailto:bgunter.4...@gmail.com]
> *Sent:* Thursday, January 7, 2021 10:52 AM
> *To:* Yuan Chun Ding
> *Cc:* r-help@r-project.org
> *Subject:* Re: [R] non-standard reshape from long to wide
>
>
>
> Is this homework? There is a no-h
com]
Sent: Thursday, January 7, 2021 10:52 AM
To: Yuan Chun Ding
Cc: r-help@r-project.org
Subject: Re: [R] non-standard reshape from long to wide
Is this homework? There is a no-homework policy on this list.
If not, note that you are usually asked to show what you tried and the error
messages you rec
Is this homework? There is a no-homework policy on this list.
If not, note that you are usually asked to show what you tried and the
error messages you received.
Bert Gunter
"The trouble with having an open mind is that people keep coming along and
sticking things into it."
-- Opus (aka Berkeley
Dear R user,
I want to reshape a long data frame to wide format, I made the following
example files. Can you help me?
Thank you,
Yuan Chun Ding
sample <-c("xr" , "xr" , "fh" , "fh" , "fh" , "uy" , "uy" , "uy" , "uy");
marker <-c("x" , "y" , "g" , "x" , "k" , "y" , "x" , "u" , "j");
df.long <-
7 matches
Mail list logo