I am new to R and usually rely on stata.

I have a considerably large data frame, it contains data from a broad range of surveys and years, each with their own types of classifications and answers. The variables have not been standardised. The data is at an Individual level.

Questions I have are the following:

How can I aggregate the surveys? How can Identify the number of surveys which have provided information on a particular variable i'm interested in like education?

enter image description here

Thank you very much,


  • $\begingroup$ (1) Too many ways to help without further guidance. (2) xtabs(~id_study+edu,data=df) might help. $\endgroup$ – r2evans May 9 '18 at 7:12

If I understand your question correctly you'd like to obtain the proportion of missing values of a specific column in your dataset. This can be obtained with the plyr library

For example:

df <- data.frame(Study=c('Study_1', 'Study_1', 'Study_2', 'Study_3'), col1=c(NA,NA,5,8), col2=c(8, NA, NA, 7))

column <- 'col1'           # is the column your are interested in

ddply(df, .(Study), function(x){

Study  V1
Study_1 100
Study_2   0
Study_3   0

Study_1 has 100% missing values and the other studies none, so except Study_1 all studies contains some information


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.