If this is my dataset
Id Col_A_1 Col_A_2 Col_A_3 ..... Col_A_100
1 87 88 82 88
2 88 82 82 87
3 82 87 NA 82
4 88 87 82 88
5 87 87 87 88
What is the efficient way to execute table function on these columns from Col_A_1 to Col_A_100 ? I am trying to avoid running the table(df$Col_A_1 , useNA ="ifany"), table(df$Col_A_2 , useNA ="ifany"), .... table(df$Col_A_100 , useNA ="ifany")
100 times.
Also if possible, I like the output saved in a dataframe .
Expected output
Column 82 85 87 88 Missing
Col_A_1 1 0 2 2 0
Col_A_2 1 0 3 1 0
Col_A_3 3 0 1 0 1
.
.
.
Col_A_100 1 0 1 3 0
Thanks in advance.
# example data
d <- read.table(text = "
Id Col_A_1 Col_A_2 Col_A_3 Col_A_100
1 87 88 82 88
2 88 82 82 87
3 82 87 NA 82
4 88 87 82 88
5 87 87 87 88", header = TRUE)