1

I have a bit of an issue with using R. We are trying to create an anova table with unequal amount of sample sizes. I was basing it off an example, however when trying to create it I get an error stating there is a differing number of rows. How would I go about fixing this? Here is the code

strokeTable<-data.frame(Strokes=c(sumStroke,shoStroke,winStroke),
            Season=factor(rep(c("Summer Stroke", "Shoulder Stroke", "Winter Stroke", 
            Games=c(length(sumStroke), length(shoStroke), length(winStroke))))))

and here's the values

sumStroke<-c(83,85,85,87,90,88,88,84,91,90)
shoStroke<-c(91,87,84,87,85,86,83)
winStroke<-c(94,91,87,85,87,91,92,86)
Phlex
  • 401
  • 2
  • 6
  • 17

1 Answers1

2

This should do it. R got confused because you called your times argument (how many times to repeat each factor level) Games instead. The second argument doesn't have to be named (R will do positional matching in that case), but if it is named it should be called times and not anything else ...

 strokeTable<-data.frame(Strokes=c(sumStroke,shoStroke,winStroke),
         Season=factor(rep(c("Summer Stroke",
                    "Shoulder Stroke", "Winter Stroke"),
              c(length(sumStroke), length(shoStroke), length(winStroke)))))

Alternatively:

 L <- list(sumStroke=sumStroke,shoStroke=shoStroke,winStroke=winStroke)
 data.frame(Strokes=unlist(L),
            Season=factor(rep(names(L),sapply(L,length))))
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453