I created a tibble named fish
. Using the %>% operator, then created an object called a result that should take fish
to then group entries by the species of fish and then compute the mean eye size of each species, but it is not coming out how it should. What am I doing wrong?
set.seed(23)
fish = tibble(
species=c(rep("toadfish", 333), rep("frogfish",333), rep("batfish", 334)),
body_size=rnorm(1000),
eye_size=abs(0.022*rnorm(1000)/body_size),
brain_volume=body_size^2*eye_size/.6
)
result <- fish %>% mean(fish$eye_size)