rcbindmanova

Difference between cbind with dataframe subset or indicating each column separately?


What is the difference between these two lines of codes?

varname1 <- cbind(df.name$var1, df.name$var2, df.name$var3)

varname2 <- cbind(df.name[1:3])

If I then try to use the next function I get an "invalid type (list) for variable "varname2".

This is the next function I try to use:

manova(varname ~ indepvar.snack+judge+rep,data = df.name)

So why does varname1 works and varname2 not?


Solution

  • Nulling my previous answer as I originaly thought you are column binding a series of columns in to a single columned dataframe.

    check str(varname1) since it results in matrix while str(varname2) is dataframe.

    manova is accepting matrix-type variable as argument. do:

    varname2 <- as.matrix(varname2)