Indeed, I've worked with the solutions provided by others and the reshape package has been very fluid to use. Thanks for the suggestion.
Chad On Sat, Oct 10, 2015 at 4:56 PM, Frans Marcelissen < fransiepansiekever...@gmail.com> wrote: > I think this is what reshape is made for... > Frans > -------------------------------------- > > rater.id <- c(1, 2, 1, 3, 2, 3) > observation <- c(1, 1, 2, 2, 3, 3) > rating <- c(6, 7, 4, 6, 2, 4) > dat=data.frame(rater.id,observation,rating) > > library(reshape) > dat2<-melt(dat, id.vars = c('rater.id','observation')) > cast(dat2,observation~rater.id) > observation 1 2 3 > 1 6 7 NA > 2 4 NA 6 > 3 NA 2 4 > > 2015-10-10 20:15 GMT+02:00 David L Carlson <dcarl...@tamu.edu>: > >> Don't post in html, the list scrambles your tables. Assuming your data >> looks like this >> >> > rater.id <- c(1, 2, 1, 3, 2, 3) >> > observation <- c(1, 1, 2, 2, 3, 3) >> > rating <- c(6, 7, 4, 6, 2, 4) >> > dat <- data.frame(rbind(rater.id, observation, rating)) >> > dat >> X1 X2 X3 X4 X5 X6 >> rater.id 1 2 1 3 2 3 >> observation 1 1 2 2 3 3 >> rating 6 7 4 6 2 4 >> >> We need to transpose the data and then use xtabs(). This will work as >> long as there is not more than one rating on an observation by the same >> rater: >> >> > t(dat) >> rater.id observation rating >> X1 1 1 6 >> X2 2 1 7 >> X3 1 2 4 >> X4 3 2 6 >> X5 2 3 2 >> X6 3 3 4 >> >> > tbl <- xtabs(rating~observation+rater.id, t(dat)) >> > tbl >> rater.id >> observation 1 2 3 >> 1 6 7 0 >> 2 4 0 6 >> 3 0 2 4 >> >> If the 0's are a problem: >> >> > tbl[tbl==0] <- NA >> > print(tbl, na.print=NA) >> rater.id >> observation 1 2 3 >> 1 6 7 <NA> >> 2 4 <NA> 6 >> 3 <NA> 2 4 >> >> >> David L. Carlson >> Department of Anthropology >> Texas A&M University >> >> >> -----Original Message----- >> From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Chad >> Danyluck >> Sent: Friday, October 9, 2015 4:02 PM >> To: r-help@r-project.org >> Subject: [R] Reformatting dataframe for use with icc() >> >> Hello, >> >> I want to determine the inter-rater reliability of ratings made from a >> random selection of observers and observations. I plan to use the irr >> package to calculate the ICC, however, my dataframe is not organized in a >> way that the icc() function can handle. The icc() function works with >> dataframes in the following format: >> >> rater1 rater2 rater3... >> observation >> 1 6 7 NA >> 2 4 NA 6 >> 3 NA 2 4 >> ... >> >> My dataframe is organized in the following format: >> >> rater.id 1 2 1 3 2 3 ... >> observation 1 1 2 2 3 3 ... >> rating 6 7 4 6 2 4 ... >> >> I would like to reformat my dataframe as it is organized in the first >> example but I am not sure how to go about doing this. Any suggestions >> would >> be appreciated. >> >> Kind regards, >> >> Chad >> >> -- >> Chad M. Danyluck, MA >> PhD Candidate, Psychology >> University of Toronto >> >> >> >> “There is nothing either good or bad but thinking makes it so.” - William >> Shakespeare >> >> [[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> ______________________________________________ >> R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >> https://stat.ethz.ch/mailman/listinfo/r-help >> PLEASE do read the posting guide >> http://www.R-project.org/posting-guide.html >> and provide commented, minimal, self-contained, reproducible code. >> > > -- Chad M. Danyluck, MA PhD Candidate, Psychology University of Toronto “There is nothing either good or bad but thinking makes it so.” - William Shakespeare [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.