0

I'm trying to run a Manova in Rstudio but run into an error whenever i try to execute it. I have 2 dataframes containing 2678 and 2051 rows and an equal amount of columns. I rbind these dataframes into 1 and create a new variable y with the dependent variables (column 1:28) and a new variable x containing the independent variable (column 29). The independent variable is a factor with levels "True" & "False". The dataframes are imported from an csv excel file. Whenever i try to run y against x with manova i get the following errors:

manova(y ~ x, data = bigfile)

invalid type (list) for variable 'y'

I then do manova(unlist(y) ~ x, data = df)

Which gives me this error:

variable lengths differ (found for 'x')

I've looked at similar problems on this platform but none of these solutions seem to work for my problem. However, when I import my entire dataset into JASP it does run a Manova. So I guess the problem has to do with the way the data is imported/mutated in my dataset(s)

d <- data.frame("Label" = c("True", "False"), "v1" = c(21,14), "v2" = c(0.132, 0.456), "v3" = c(0.734, 0.824))
d2 <- data.frame("Label" = c("False", "False"), "v1" = c(48,18), "v2" = c(0.284, 0.137), "v3" = c(0.296, 0.112))

bigdf = rbind(d, d2)

y = cbind(bigdf[2:4])
x = bigdf[1]

aov = manova(y ~ x, data = bigdf)
Phil
  • 7,287
  • 3
  • 36
  • 66
Koen Wijnen
  • 55
  • 1
  • 8
  • 1
    I'm confused - you're talking about RStudio but then you have python code. Are you using python within the RStudio IDE? – Phil May 07 '20 at 14:05
  • Oh sorry, haven't had my coffee yet, let me update that – Koen Wijnen May 07 '20 at 14:42
  • Fixed now! Still same question – Koen Wijnen May 07 '20 at 14:46
  • There were a few errors in your code, which I fixed. Let me know if that is meant what you're trying to do. The error here is that you're trying to use a list as a dependent variable. If you run `manova(cbind(v1, v2, v3) ~ Label, data = bigdf)` that works. – Phil May 07 '20 at 15:11
  • When I use this code the unlist error dissappears except the "variable lengths differ (found for 'Label')" error still pops up. – Koen Wijnen May 07 '20 at 15:30
  • I'm not able to reproduce this error with the code and data provided above. – Phil May 07 '20 at 15:31
  • Then the problem is in my data, could it be that this error is due to unbalanced classes ? Or is it just a fault inside the data? – Koen Wijnen May 07 '20 at 15:34
  • The implication of the error is that you have a different number of rows in x and y. If you run `dim(y)` and `dim(x)` what do you get? – Phil May 07 '20 at 15:42
  • The dimension of y = 4729 28 The dimension of x = 4729 1 However, for a Manova equal balanced classes (so in this case rows) isn't obligatory right? – Koen Wijnen May 07 '20 at 15:46

0 Answers0