I want obtain as result for df$y "01", "02", "03", "40h"
, but I can't understand my error:
library(tidyverse)
df <- tibble(x = c(1,2,3,4),
y = c("1","2","03","40h"))
df %>%
mutate(y = if_else(length(y) < 2, str_pad(width=2, pad="0"), y))
#> Error: Problem with `mutate()` input `y`.
#> x argument "string" is missing, with no default
#> i Input `y` is `if_else(length(y) < 2, str_pad(width = 2, pad = "0"), y)`.
Created on 2020-10-20 by the reprex package (v0.3.0)