cerveceria_dataset$CLIENTE <- separate(cerveceria_dataset$CLIENTE, col = CLIENTE, into = c("Nombre","Apellido"), sep = ";")
This code give me the
"Error in UseMethod("separate") : no applicable method for 'separate' applied to an object of class "character""enter image description here
CodePudding user response:
I think you are applying the function wrong. Try using -
cerveceria_dataset <- tidyr::separate(cerveceria_dataset,
col = CLIENTE, into = c("Nombre","Apellido"), sep = ";")
CodePudding user response:
tidyr::separate
splits a string column into multiple columns. If you are just working with a single character vector, you probably want something like stringr::split
, which splits a character vector into a list of vectors (or a matrix if you use str_split_fixed
).