I'm trying to convert the Awesomness column from a logic to numeric type. When I filter the column I seem to get the output TRUE/FALSE/NA. I've played around with the function as.numeric without luck.
yo_jedi <- tribble(
~Name, ~Lightsaber_Color, ~Affiliation, ~Age, ~Midi_Chlorians, ~Years_of_Training, ~Homeworld,
"Luke Skywalker", "Blue", "Rebel Alliance", 32, 15000, 14, "Tatooine",
"Obi-Wan Kenobi", "Blue", "Jedi Order", 57, 18000, 40, "Stewjon",
"Yoda", "Green", "Jedi Order", 900, 20000, 800, "Dagobah",
"Rey", "Blue", "Resistance", 20, 8500, 7, "Jakku",
"Ahsoka Tano", "White", "Jedi Order", 32, 12000, 12, "Shili",
"Mace Windu", "Purple", "Jedi Order", 53, 15500, 28, "Haruun Kal",
"Anakin Skywalker", "Blue", "Jedi Order", 22, 16000, 12, "Tatooine",
"Padmé Amidala", "N/A", "Galactic Senate", 27, 15000, 2, "Naboo",
"Leia Organa", "Purple", "Rebel Alliance", 25, 14000, 0, "Alderaan",
"Chewbacca", "N/A", "Rebel Alliance", 200, 0, 0, "Kashyyyk"
)
yo_jedi |>
mutate(
Awesomeness = Years_of_Training / Midi_Chlorians * 10000,
) |>
arrange(Awesomeness, Age) |>
filter(Age > 30) |>
distinct(Lightsaber_Color, Affiliation = "Jedi Order", Awesomeness > 15)
A tibble: 6 × 3
Lightsaber_Color Affiliation Awesomeness > 15
1 Blue Jedi Order FALSE
2 White Jedi Order FALSE
3 Purple Jedi Order TRUE
4 Blue Jedi Order TRUE
5 Green Jedi Order TRUE
6 N/A Jedi Order NA