samedi 31 octobre 2020

Accessing a variable in a data frame by columns number in R?

I hope you haven't gotten corona virus and you are all healthy. I have a data frame as "df" and 41 variables var1 to var41. If i write this command

pcdtest(plm(var1~ 1 , data = df, model = "pooling"))[[1]]

i can see the test value. But i need to apply this test for 41 times. I want to access variable by column number which is "df[1]" for "var1" and "df[41]" for "var41"

pcdtest(plm(df[1]~ 1 , data = dfp, model = "pooling"))[[1]]

Bu it fails. Could you please help me to do this? I will have result in for loop. And i will calculate the descriptive statistics for all the results. But it is very difficult to do test for each variable.

Aucun commentaire:

Enregistrer un commentaire