Commit ad6155f9 authored by Jean-Marie Lepioufle's avatar Jean-Marie Lepioufle
Browse files

plot_tbl_basic on its own file

parent 263976d5
#' plot_tbl_basic
#' plot_tbl_basic
#' @param x tbl_friendlyts data.frame
#' @param target target
#' @param group "none","YEAR","MONTH","WDAY","HOUR","MINUTE","SECOND"
#' @param path path
#' @param name name
#' @param DESKTOP boolean
#' @param width_mm width_mm
#' @param height_mm height_mm
#' @param y_name y_name
#' @keywords basicr
#' @export
#' @examples
#' \dontrun{
#' plot_tbl_basic()
#' }
plot_tbl_basic <- function(x,target,group,path=tempdir(),name=NULL,DESKTOP=TRUE,width_mm=200,height_mm=200,y_name="Y-axis"){
if ( (length(group)==1) && (prod(group %in% c("YEAR","MONTH","WDAY","HOUR","MINUTE","SECOND"))==1) ){
if (!DESKTOP) {
if(is.null(name)) {
filename <- normalizePath(file.path(path,paste0("basic_",group,"_",target,".tiff")),mustWork = FALSE)
} else filename <-normalizePath(file.path(path,paste0("basic_",group,"_",target,"_",name,".tiff")),mustWork = FALSE)
grDevices::tiff(filename = filename, width = width_mm, height = height_mm,
units = "mm", pointsize = 12,
compression = "lzw",
bg = "transparent", res = 300)
} else grDevices::dev.new()
names(x)[names(x)==target] <- "targ"
p <- switch(group,
"YEAR" = ggplot2::ggplot(x) + ggplot2::geom_boxplot(ggplot2::aes(x = YEAR, y = targ)) + ggplot2::labs(x = group, y = y_name),
"MONTH" = ggplot2::ggplot(x) + ggplot2::geom_boxplot(ggplot2::aes(x = MONTH, y = targ)) + ggplot2::labs(x = group, y = y_name),
"WDAY" = ggplot2::ggplot(x) + ggplot2::geom_boxplot(ggplot2::aes(x = WDAY, y = targ)) + ggplot2::labs(x = group, y = y_name),
"HOUR" = ggplot2::ggplot(x) + ggplot2::geom_boxplot(ggplot2::aes(x = HOUR, y = targ)) + ggplot2::labs(x = group, y = y_name),
"MINUTE" = ggplot2::ggplot(x) + ggplot2::geom_boxplot(ggplot2::aes(x = MINUTE, y = targ)) + ggplot2::labs(x = group, y = y_name),
"SECOND" = ggplot2::ggplot(x) + ggplot2::geom_boxplot(ggplot2::aes(x = SECOND, y = targ)) + ggplot2::labs(x = group, y = y_name),
stop("group not recognized"))
print(p)
if (!DESKTOP) {
grDevices::dev.off()
print(filename)
} else {}
return(TRUE)
} else stop("group must be of length 1 and refer to: 'YEAR', 'MONTH', 'WDAY', 'HOUR','MINUTE','SECOND'")
}
% Generated by roxygen2: do not edit by hand % Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.R % Please edit documentation in R/plot_tbl_basic.R
\name{plot_tbl_basic} \name{plot_tbl_basic}
\alias{plot_tbl_basic} \alias{plot_tbl_basic}
\title{plot_tbl_basic \title{plot_tbl_basic
plot_tbl_basic} plot_tbl_basic}
\usage{ \usage{
plot_tbl_basic(df, target, group, path = tempdir(), name = NULL, plot_tbl_basic(x, target, group, path = tempdir(), name = NULL,
DESKTOP = TRUE, width_mm = 200, height_mm = 200) DESKTOP = TRUE, width_mm = 200, height_mm = 200,
y_name = "Y-axis")
} }
\arguments{ \arguments{
\item{df}{tbl_friendlyts data.frame} \item{x}{tbl_friendlyts data.frame}
\item{target}{target} \item{target}{target}
...@@ -24,6 +25,8 @@ plot_tbl_basic(df, target, group, path = tempdir(), name = NULL, ...@@ -24,6 +25,8 @@ plot_tbl_basic(df, target, group, path = tempdir(), name = NULL,
\item{width_mm}{width_mm} \item{width_mm}{width_mm}
\item{height_mm}{height_mm} \item{height_mm}{height_mm}
\item{y_name}{y_name}
} }
\description{ \description{
plot_tbl_basic plot_tbl_basic
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment