Hi, I'm new to R. I'm practicing with the data "ChickWeight" that is in R.
I need a little help to understand how to code something that I want with the spread() function...
I want to understand how this function works so I can apply it to other databases...
I have watched lots of youtube videos, but I still don't get it right.
I want to dominate it, he, he, he...
# I have this
df %>%
select(Chick, Diet) %>%
group_by(Chick) %>%
View()
Which gives me two columns -Chick- & -Diet-
I want to spread the -Diet- column and the value that I want is the count of how many -Chicks- of every type have what type of -Diet-??
#This is what I code
df %>%
+ select(Chick, Diet) %>%
+ group_by(Chick) %>%
+ count(Diet) %>%
+ spread(key = Diet, value = count(Diet)) %>%
+ View()
Error in View : no applicable method for 'count' applied to an object of class "c('integer', 'numeric')"
I want something like this:
Chick Diet 1 Diet 2 Diet 3
-
13. 12. 7
-
4. 9. 10
-
10. 22. 1
I hope I'm explaining myself...
Thx for your help