Beginner Manipulating data in tidyverse, Starwars

Hi, Im a beginner/re-lerarner and immeaditly run into waht is probably an easy problem when maniulating data.

Tried following this video.(https://www.youtube.com/watch?v=nRtp7wSEtJA&list=PLtL57Fdbwb_Chn-dNR0qBjH3esKS2MXY3&index=5) with the following code. But dont get any output in the console.

library(tidyverse)
view(starwars)
starwars %>%
select(gender, mass, height, species) %>%
filter(species == "human") %>%
na.omit() %>%
mutate(height= height/100) %>%
mutate(BMI = mass/height^2) %>%
group_by(gender) %>%
summarise(average_BMI=mean(BMI)) %>%
view(average_BMI)

output:

starwars %>%

  • select(gender, mass, height, species) %>%
  • filter(species == "human") %>%
  • na.omit() %>%
  • mutate(height= height/100) %>%
  • mutate(BMI = mass/height^2) %>%
  • group_by(gender) %>%
  • summarise(average_BMI=mean(BMI))

A tibble: 0 × 2

:information_source: 2 variables: gender , average_BMI

starwars %>%

  • select(gender, mass, height, species) %>%
  • filter(species == "human") %>%
  • na.omit() %>%
  • mutate(height= height/100) %>%
  • mutate(BMI = mass/height^2) %>%
  • group_by(gender) %>%
  • summarise(average_BMI=mean(BMI)) %>%
  • view(average_BMI)
    Error: object 'average_BMI' not found

human should be spelled with a capital H or it wont match any value in the data.
filter(species == "Human")

1 Like

Thank you! That was it!

This topic was automatically closed 7 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.