Closed RobertTalbert closed 10 months ago
Which version of dplyr are you using? With 1.1.3 I'm not getting an error here.
And here is a reprex with session info in case that's helpful:
library(tidyverse)
library(janitor)
students <- read_csv("https://raw.githubusercontent.com/hadley/r4ds/main/data/students.csv", na = c("N/A", ""))
#> Rows: 6 Columns: 5
#> ── Column specification ────────────────────────────────────────────────────────
#> Delimiter: ","
#> chr (4): Full Name, favourite.food, mealPlan, AGE
#> dbl (1): Student ID
#>
#> ℹ Use `spec()` to retrieve the full column specification for this data.
#> ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
students <- students |>
janitor::clean_names() |>
mutate(
meal_plan = factor(meal_plan),
age = parse_number(if_else(age == "five", "5", age))
)
students
#> # A tibble: 6 × 5
#> student_id full_name favourite_food meal_plan age
#> <dbl> <chr> <chr> <fct> <dbl>
#> 1 1 Sunil Huffmann Strawberry yoghurt Lunch only 4
#> 2 2 Barclay Lynn French fries Lunch only 5
#> 3 3 Jayendra Lyne <NA> Breakfast and lunch 7
#> 4 4 Leon Rossini Anchovies Lunch only NA
#> 5 5 Chidiegwu Dunkel Pizza Breakfast and lunch 5
#> 6 6 Güvenç Attila Ice cream Lunch only 6
Created on 2023-11-09 with reprex v2.0.2
The code is
Running this in R Studio (Version 2023.09.1+494) with R 4.3.1 gives the error:
I had previously imported
students
using a CSV created from the text at the beginning of 8.2. (However running the code still changes the "five" that's in the CSV to a numerical 5 so I'm not sure if this is really an error or just an R warning.)