1

I would count with the func table() in R how many time a value occures in a cell. But, some cell contains more value divided by colon. I report an example below:

example <- data.frame(c("A","B","A:::B"))
table(example)

the result is:

A A:::B     B 
1     1     1 

but i want something like this

A     B 
2     2 

I try to duplicate the rows with this characteristics, but the dataset is already too large and duplicate rows makes dataset impossible to use. How can i do? thanks

1 Answer 1

3

We can split the column values by ::: and get the table

table(unlist(strsplit(example[[1]], "\\:+")))
#  A B 
#  2 2 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.