Pipe operator
Title
Question
For the assignment on pipe operator
1. Use the built-in data set iris. Using the pipe operator, group the flowers by their Species.
2. Summarise the grouped data by the mean of Sepal.Length and Sepal.Width.
R Pipe-Operator 12-13 min 20-30 sec
Answers:
As far as I understand, you want to have something like the command given below:
iris %>% group_by(Species) %>% summarise(mean(Sepal.Length), mean(Sepal.Width)) %>% View()
It is giving the error:
Error in iris %>% group_by(Species) %>% summarise(mean(Sepal.Length), :
could not find function "%>%"
%>% can be used only after loading the library dplyr, as given below:
----------------------------------------------------------------------------------------------------------------------------------------------
library(dplyr)
iris %>% group_by(Species) %>% summarise(mean(Sepal.Length), mean(Sepal.Width)) %>% View()
----------------------------------------------------------------------------------------------------------------------------------------------
Login to add comment
Login to add comment