0

I am trying to do a Friedman's test and yes my data is repeated measures but nonparametric.

The data is organized like this from the csv and used Rstudio's import dataset function so it is a table in Rstudio:

score| treatment | day   
10 | 1 | 1     
20 | 1 | 1
40 | 1 | 1
7  | 2 | 1
100| 2 | 1
58 | 2 | 1
98 | 3 | 1     
89 | 3 | 1
40 | 3 | 1
70 | 4 | 1
10 | 4 | 1
28 | 4 | 1
86 | 5 | 1     
200| 5 | 1
40 | 5 | 1
77 | 1 | 2
100| 1 | 2
90 | 1 | 2     
33 | 2 | 2
15 | 2 | 2     
25 | 2 | 2
23 | 3 | 2
54 | 3 | 2
67 | 3 | 2
1  | 4 | 2     
2  | 4 | 2
400| 4 | 2
16 | 5 | 2
10 | 5 | 2
90 | 5 | 2
library(readr)

sample_data$treatment <- as.factor(sample_data$treatment) #setting treatment as categorical independent variable

sample_data$day <- as.factor(sample_data$day) #setting day as categorical independent variable

summary(sample_data)
#attach(sample_data) #not sure if this should be used only because according to https://www.sheffield.ac.uk/polopoly_fs/1.714578!/file/stcp-marquier-FriedmanR.pdf it says to use attach for R to use the variables directly

friedman3 <- friedman.test(y = sample_data$score, groups = sample_data$treatment, blocks = sample_data$day)

summary(friedman3)

I am interested in day and score using Friedman's.

this is the error I get:

>Error in friedman.test.default(y = sample_data$score, groups = sample_data$treatment, blocks = sample_data$day,  : 
  not an unreplicated complete block design

Not sure what is wrong.

Prior to writing the Friedman part of the code, I only specified day and treatment as categorical using as.factor

ineedhelp
  • 35
  • 8
  • Can you please read and incorporate elements from [How to make a great R reproducible example?](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Especially the aspects of using `dput()` for the input? – wibeasley Nov 24 '21 at 03:57
  • I am new to R and I have just read what dput() does but I am not entirely clear on what it means. What exactly do you mean in regards to dput() in this case? – ineedhelp Nov 24 '21 at 04:01
  • refer https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – Nad Pat Nov 24 '21 at 08:15
  • Thanks for asking if you don't understand. Look again through the link that @NadPat & I linked to, especially the high-ranking responses that describe `dput()`. You'll ultimately want a complete example that starts with something like `sample_data <- structure(list(treatment = c(1L, 2L, 3L, 1L, 2L, 3L), day = c(7L, 7L, 7L, 8L, 8L, 8L), score = c(10L, 20L, 40L, 7L, 100L, 58L)), class = "data.frame", row.names = c(NA, -6L))` – wibeasley Nov 24 '21 at 17:32
  • I will try my best for this because I imported a csv into R in order to do the Friedman's without any success. I will also add the code I am using to see what I am doing incorrectly. Thanks for replying – ineedhelp Nov 25 '21 at 06:06
  • Also sorry for the updated comment, I am using Rstudio – ineedhelp Nov 25 '21 at 06:16

0 Answers0