how to simplify data with tidyr

60 views
Skip to first unread message

Yong

unread,
Aug 23, 2019, 12:57:11 PM8/23/19
to manipulatr
Dear group members,

How can I use tidyr to transform the format in image 1 to the format in image 2? 

Thanks in advance!
Yong
1.PNG
2.PNG

Arin Basu

unread,
Aug 23, 2019, 4:46:27 PM8/23/19
to Yong, manipulatr
How about
``` dataframe %>%
spread(sample, value)
```
?
-------------
Gate, Gate, Paragate, Parasamgate, Bodhi, Swahah!
(Gone, gone, gone beyond, gone completely beyond, awake! Hallellujah!)
-From "The Heart Sutra"
> --
> You received this message because you are subscribed to the Google Groups "manipulatr" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to manipulatr+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/manipulatr/2de8ce3d-77d4-4a9f-b3a0-da356380b338%40googlegroups.com.

Yong

unread,
Aug 24, 2019, 1:42:58 AM8/24/19
to manipulatr
Hi Arin,

Thanks for the advice! Because there are two replicates (same sample and feature, different values) for each sample in my data, there is one error after I use "spread". The error is "Duplicate identifiers for rows ". Are there other options for this problem?

Thanks,
Yong


On Friday, August 23, 2019 at 3:46:27 PM UTC-5, Arin Basu wrote:
How about
``` dataframe %>%
   spread(sample, value)
```
?
-------------
Gate, Gate, Paragate, Parasamgate, Bodhi, Swahah!
(Gone, gone, gone beyond, gone completely beyond, awake! Hallellujah!)
-From "The Heart Sutra"


On Sat, 24 Aug 2019 at 04:57, Yong <yjli...@tamu.edu> wrote:
>
> Dear group members,
>
> How can I use tidyr to transform the format in image 1 to the format in image 2?
>
> Thanks in advance!
> Yong
>
> --
> You received this message because you are subscribed to the Google Groups "manipulatr" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to manip...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages