datacarpentry / r-intro-geospatial

Introduction to R for Geospatial Data
https://datacarpentry.org/r-intro-geospatial/
Other
47 stars 71 forks source link

Episode 4: Data Structures: Exploring Data Frames - `rbind` and factors #107

Open cengel opened 3 years ago

cengel commented 3 years ago

R is not giving a warning when executing rbind(gapminder, new_row). gapminder$continent is not a factor.

https://github.com/datacarpentry/r-intro-geospatial/blob/3ae8234810c878a3b99dc3fc4b6c2ba68d2f4c58/_episodes_rmd/04-data-structures-part2.Rmd#L262

It does, however, for the same reason, generate a warning message after running this: levels(gapminder$continent) <- c(levels(gapminder$continent), "Nordic") gapminder_norway <- rbind(gapminder, list('Norway', 2016, 5000000, 'Nordic', 80.3,49400.0, FALSE))

https://github.com/datacarpentry/r-intro-geospatial/blob/3ae8234810c878a3b99dc3fc4b6c2ba68d2f4c58/_episodes_rmd/04-data-structures-part2.Rmd#L282

And the fix suggested gapminder$continent <- as.character(gapminder$continent) also needs to be adjusted.