The mean() function in this piped workflow throws an error when I run it. The argument is a column of my data set. Here is the code: hotel_bookings %>% mean(lead_time)
The error says "argument is not numeric or logical: returning NA", but all the values are numeric
The mean() function is not designed to be used with a pipe. You are passing the entire data frame to mean() as the object of which to take the mean. To get the mean of the lead_time, use mean(hotel_bookings$lead_time). Here is a simple example
DF <- data.frame(A = c(2,3,2), b = c(4,7,2))
DF |> mean(A)
#> Warning in mean.default(DF, A): argument is not numeric or logical: returning
#> NA
#> [1] NA
mean(DF$A)
#> [1] 2.333333