Kevin CZ
Kevin CZ

Reputation: 1

How to use the method separate with a character?

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

Upvotes: 0

Views: 880

Answers (2)

Ronak Shah
Ronak Shah

Reputation: 388817

I think you are applying the function wrong. Try using -

cerveceria_dataset <- tidyr::separate(cerveceria_dataset, 
                       col = CLIENTE, into =  c("Nombre","Apellido"), sep = ";")

Upvotes: 1

Migwell
Migwell

Reputation: 20107

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).

Upvotes: 0

Related Questions