I'm trying a different method to boxplot two population means.I'm using reshape2's melt function which comes inbuilt with 2 columns, variable and value. Below is the code. It works but I get a warning that
plot.Rttest: no visible binding for global variable 'variable'
plot.Rttest: no visible binding for global variable 'value'
Code -
#' Generic plot function that plots the population mean difference and its confidence interval
#'
#' @param x object that has the data
#' @param ... generic plot functions uses this argument so when overloading, it is needed
#'
#' @return returns a boxplot of both populations to see if their means are same of different or how far off
#' @importFrom ggplot2 aes geom_boxplot ggplot labs
#' @importFrom reshape2 melt
#' @examples
#' \dontrun{
#' plot(obj)}
#' @export
plot.Rttest <- function(x, ...){
w <- x[["data"]][["x"]]
v <- x[["data"]][["y"]]
df <- data.frame(w,v)
data_long = melt(df)
ggplot(data_long, aes(x=variable,y=value,fill =variable)) + geom_boxplot() +
labs(x="Population", y= "Samples")
}
I use roxygen2 to create the namespaces and skeleton. When I try to generate a skeleton, the variable and value don't appear but the warning is bothersome. I checked the documentation and couldn't find a way. If anyone can help me figure this out, I'd appreciate it!
Mike answered in the comments, just wanted to make a note.
ggplot(data_long, aes(x=.data_long[[variable]],y=.data_long[[value]],fill =.data_long[[variable]])) + geom_boxplot() + labs(x="Population", y= "Samples")