I'm trying to count the number of occurrences of multiple character IDs that occur in multiple rows of one column.
I have a vector of independent IDs
x2<-sample(101:255,200,replace=TRUE)
And in a separate data frame I have column which consists of multiple character strings with some corresponding IDs, please forgive inability to create a full sample data set but the corresponding column in a data frame looks like this
sample <- c("105 234 213", "147 211 174", "223 250 243", "189 190 153", "137 200 199")
as.data.frame(sample)
The finished result would be a new data frame with an output like this
ID Occurrences
101 3
102 15
103 2
104 26
105 11
... etc
I hope this makes sense and any help would be great
IDs come fromx2and theOccurrencesfromsample?