Reputation: 9
I'm new to R (and programming) looking for help adding the total number of times a specific character appears within one of my columns. All in all there are 175 total rows. Here's a condensed version of my tibble:
random_code | location |
---|---|
ABCD20 | San Francisco |
ABCD30 | Seattle |
ABCD40 | New York |
.... | .... |
I'm sure there is a way to calculate the number of times each random_code
appears in the table but I'm not sure how.
Any suggestions?
Upvotes: 0
Views: 20
Reputation: 4425
You can try
library(dplyr)
df |> group_by(random_code) |> mutate(times = n())
Upvotes: 1