Basically, what I want to do is run the function ndiffs on each column of a dataframe and then store these results in another dataframe so for example if I have a dataframe of 5 columns I would have as a result a dataframe with 5 columns and only 1 row. In each column of the results dataframe their is the result of the ndiffs function applied to the same column index on the original dataframe.
I was able to do this by looping through the columns using the code below:
df is the original dataframe and df2 is the result 
dataframe
df2=cbind(" ",ndiffs(as.numeric(unlist(df[2])), alpha =0.05, test ="adf", max.d = 3))
for (i in 3:ncol(df)){df2=cbind(df2,ndiffs(as.numeric(unlist(df[i])),alpha =0.05, test ="adf", max.d = 3))}
Is there a cleaner way to do this or not ?
 
    