1

I was wondering about the most efficient way to calculate the frequencies of repeated values across multiple columns. In the code example below, I want to calculate the total number of times each unique value (1, 2, or 3) appears across the 3 columns (x, y, z). Thanks for your help!

x <- c(1,2,3)
y <- c(2,3,1)
z <- c(3,2,2)

df <- data.frame(x,y,z)

I'm new to R. So I tried using table() but it's not giving me what I'm looking for (the total number of times each unique value appears across the 3 columns).

kthomas
  • 11
  • 2

0 Answers0