0

I am trying to use a R package called "agrmt" and use "consensus" function to calculate consensus between each collector.

My dataset is a survey data. The first column is collector ID and the other columns are different questions. The answer for survey question is from 1 to 5. I want to get " consensus score" for each question for each distinct collector ID.

If I use this "consensus" function, and use consensus(table(test_qes[, x])) This statement basically first get the frequency for each 1 to 5 then calculate consensus score. But this is only for a question not for each distinct collector.

I use the below R code and it gave me lots of warnings and it's not correct.

for (i in 1:a) {
  consensus_1 <- test_qes %>%
    group_by(Collector.ID) %>%
    summarise_each(funs(consensus(table(test_qes[, i + 1]))))
}

I may have to use function or double loop ? Can anybody who can help me correct this code or give me some hints?I appreciate for any constructive suggestions! Thank you !!!

John
  • 1
  • 1
  • 1
    Please do not post an image of code/data/errors: it cannot be copied or searched (SEO), it breaks screen-readers, and it may not fit well on some mobile devices. Ref: https://meta.stackoverflow.com/a/285557/3358272 (and https://xkcd.com/2116/). Please just include the code, console output, or data (e.g., `dput(head(x))` or `data.frame(...)`) directly. – r2evans Mar 23 '20 at 16:53
  • 1
    Please make this question *reproducible*. This includes sample code (including listing non-base R packages), sample *unambiguous* data (e.g., `dput(head(x))` or `data.frame(x=...,y=...)`), and expected output. Refs: https://stackoverflow.com/questions/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Mar 23 '20 at 16:54
  • Is it good enough now ? – John Mar 23 '20 at 19:02
  • 1
    I think you missed my points, and perhaps didn't read any of the links in the second comment. I get: `Error: object 'test_qes' not found` (same for `a`). If you cannot provide actual data, then it is up to you to provide good-enough fake data for us to see what is being done; this can be done very simply with `data.frame(...)` and a few columns, few rows. Or if you'd prefer, you can provide a small sample of your data using `dput(head(test_qes))`; if it has many columns, you likely only need to give us a few, so perhaps `dput(test_qes[1:5,1:5])`. Either way, `dput` or `data.frame`, *please*. – r2evans Mar 23 '20 at 19:19

0 Answers0