Luigi Marongiu
2021-Oct-23 20:15 UTC
[R] generate average frame from different data frames
Hello, I have a series of classifications of the same data. I saved this classification in a single dataframe (but it could be a list). X and Y are the variable and Z is the classification by three raters. `I` is the individual identifier of each entry: ``` z1 = c(0,0,0,0,0,1,0,0,0,2, 0,1,1,1,0,0,0,1,0,2, 0,1,1,2,0,0,0,1,0,2, 1,1,1,2,1,0,0,1,1,2, 1,0,0,2,1,1,0,1,2,0) z2 = c(0,0,0,0,0,1,0,0,1,1, 0,1,1,2,0,0,0,1,1,2, 0,0,0,1,0,0,0,1,0,0, 1,2,1,2,1,0,0,1,1,2, 1,0,1,2,1,1,0,1,2,0) z3 = c(0,0,0,2,0,0,0,0,0,2, 0,1,0,2,0,0,0,1,0,2, 0,1,1,2,0,0,0,1,0,2, 1,1,1,2,1,0,0,2,1,2, 2,0,1,1,1,1,0,1,1,0) df = data.frame(X=rep(1:5,3), Y=rep(1:5,3), Z=factor(c(z1,z2,z3)), I =1:150) ``` Is there a way to obtain a kind of heath map for each point? Let's say for the point (x=1,y-1), what was the most common (average) classification? Is it possible to get the 95% CI of that mean? Would Two-Dimensional Kernel Density Estimation be the right path? Thank you
Hi Luigi, I may be missing the point, but: matrix((z1+z2+z3)/3,ncol=10) gives you the mean rating for each item, and depending upon what distribution you choose, the confidence intervals could be calculated in much the same way. Jim On Sun, Oct 24, 2021 at 7:16 AM Luigi Marongiu <marongiu.luigi at gmail.com> wrote:> > Hello, > I have a series of classifications of the same data. I saved this > classification in a single dataframe (but it could be a list). X and Y > are the variable and Z is the classification by three raters. `I` is > the individual identifier of each entry: > ``` > z1 = c(0,0,0,0,0,1,0,0,0,2, > 0,1,1,1,0,0,0,1,0,2, > 0,1,1,2,0,0,0,1,0,2, > 1,1,1,2,1,0,0,1,1,2, > 1,0,0,2,1,1,0,1,2,0) > z2 = c(0,0,0,0,0,1,0,0,1,1, > 0,1,1,2,0,0,0,1,1,2, > 0,0,0,1,0,0,0,1,0,0, > 1,2,1,2,1,0,0,1,1,2, > 1,0,1,2,1,1,0,1,2,0) > z3 = c(0,0,0,2,0,0,0,0,0,2, > 0,1,0,2,0,0,0,1,0,2, > 0,1,1,2,0,0,0,1,0,2, > 1,1,1,2,1,0,0,2,1,2, > 2,0,1,1,1,1,0,1,1,0) > df = data.frame(X=rep(1:5,3), Y=rep(1:5,3), Z=factor(c(z1,z2,z3)), I =1:150) > ``` > Is there a way to obtain a kind of heath map for each point? Let's say > for the point (x=1,y-1), what was the most common (average) > classification? Is it possible to get the 95% CI of that mean? > Would Two-Dimensional Kernel Density Estimation be the right path? > Thank you > > ______________________________________________ > R-help at 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.