I am not sure why "na.rm=TRUE" in ggplot() and geom_col() don't remove the missing. Here is the input file (file name in the code is dat.csv ):
br,tr,obs,ee,dd
UU,RRR,228,0.38895,0.33691
BB,RRR,591,0.37254,0.40899
GG,RRR,702,0.36163,0.38155
UU,AAA,229,0.31594,0.32768
BB,AAA,591,0.18185,0.23339
GG,AAA,702,0.37287,0.40218
UU,BBB,228,0.16561,0.32313
BB,BBB,591,0.22578,0.41145
GG,BBB,702,0.28103,0.46357
UU,LLL,1,.,.
UU,TTT,107,-0.01136,0.2265
BB,TTT,33,-0.34362,0.07749
GG,TTT,54,0.00905,-0.07037
Here is the code
library("data.table")
library(conflicted)
library(tidyverse)
library(ggplot2)
ee <- fread("dat.csv", select = c("br","tr","obs","ee"))
ee_r <- data.frame(a = 1:nrow(ee), Method = "OLD")
ee <- cbind(rename(ee, Acc = ee), ee_r)
dd <- fread("dat.csv", select = c("br","tr","obs","dd"))
dd_r <- data.frame(a = 1:nrow(dd), Method = "NEW")
dd <- cbind(rename(dd, Acc = dd), dd_r)
dat <- rbind(ee,dd)
dat <- subset(dat, select = -c(a))
dat$Acc[dat$Acc=="."] <- NA
br_nbs <- paste(dat$br, dat$obs, sep = "\n")
br_nbs
#data <- subset(dat, !is.na(Acc)) This command gives me error
ggplot(dat, aes(x = br_nbs, y = Acc, fill = Method), na.rm=TRUE)+
geom_col(colour="black",width=1, position=position_dodge(0.7), na.rm=TRUE) +
facet_wrap(~tr, strip.position = "top", labeller = "label_value", scales = "free_x")
And here is the plot with NAs in the red box:
I appreciate any comments.
Thanks.