saving . . . saved Pipe operator has been deleted. Pipe operator has been hidden .
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. 

How can I summarise 2 variables at the same time in same row

R Pipe-Operator 12-13 min 20-30 sec 04-05-20, 6:29 p.m. sakshi.khanna@juit.ac.in

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()
04-05-20, 6:51 p.m. sudhakarst


It is giving the error:
Error in iris %>% group_by(Species) %>% summarise(mean(Sepal.Length),  : 
  could not find function "%>%"
05-05-20, 3:37 p.m. sakshi.khanna@juit.ac.in
%>% 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()
----------------------------------------------------------------------------------------------------------------------------------------------
06-05-20, 8:20 p.m. sudhakarst

Login to add comment


Log-in to answer to this question.