Hi. I´m begginer on R. Have to calculate the body mass in g for the Adelie Penguins species. I need some help how to write a code to summarize() and mean() functions to find the mean value for the variable (body_mass_g) on penguins dataset.
Your support
The online book R for Data Science (https://r4ds.had.co.nz) by Hadley Wickham and Garret Grolemund is an excellent way to learn R. For this particular problem, I suggest you look at section 5.6.
Here is a non-tidy solution:
library(palmerpenguins) df <- data.frame(penguins) df <- df[complete.cases(df),] # delete NA rows
mean(df[df$species=="Adelie",6]) mean(df[df$species=="Chinstrap",6]) mean(df[df$species=="Gentoo",6]) mean(df[,6])
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.