Commit 372c6c11 authored by jml's avatar jml
Browse files

deplace qq-plot and qqRes-plot from friendlyts to basicr

parent 5b8fbe8a
#' plot_qq
#' plot_qq
#' @param x tbl_friendlyts data.frame
#' @param reference reference in character
#' @param client reference in character
#' @param path path
#' @param name name
#' @param width_mm width_mm
#' @param height_mm height_mm
#' @param DESKTOP boolean
#' @keywords basicr
#' @export
#' @examples
#' \dontrun{
#' plot_qq()
#' }
plot_qq <- function(x,reference,client,path=tempdir(),name=NULL,width_mm=200,height_mm=200,DESKTOP=TRUE){
if (!(DESKTOP)) {
if(is.null(name)) {
filename <- normalizePath(file.path(path,paste0("qq_",reference,"_",client,".tiff")),mustWork = FALSE)
} else filename <-normalizePath(file.path(path,paste0("qq_",reference,"_",client,"_",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)==reference] <- "refe"
names(x)[names(x)==client] <- "clie"
p <- ggplot2::ggplot(x, ggplot2::aes(x = refe, y = clie)) +
ggplot2::geom_abline(lty = "dashed", col = "red") +
ggplot2::geom_point() +
ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5)) +
ggplot2::coord_fixed(ratio = 1) +
ggplot2::labs(
x = reference,
y = client
)
print(p)
if (!(DESKTOP)) {
grDevices::dev.off()
return(filename)
} else {
return(TRUE)
}
}
#' plot_qqRes
#' plot_qqRes
#' @param x friendlyts data.frame
#' @param reference reference in character
#' @param client reference in character
#' @param path path
#' @param name name
#' @param width_mm width_mm
#' @param height_mm height_mm
#' @param DESKTOP boolean
#' @keywords friendlyts
#' @export
#' @examples
#' \dontrun{
#' plot_qqRes()
#' }
plot_qqRes <- function(x,reference,client,path=tempdir(),name=NULL,width_mm=200,height_mm=200,DESKTOP=TRUE){
if (!(DESKTOP)) {
if(is.null(name)) {
filename <- normalizePath(file.path(path,paste0("qqRes_",reference,"_",client,".tiff")),mustWork = FALSE)
} else filename <-normalizePath(file.path(path,paste0("qqRes_",reference,"_",client,"_",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)==reference] <- "refe"
names(x)[names(x)==client] <- "clie"
d <- x %>% transmute(refe=refe,eps=refe-clie)
p <- ggplot2::ggplot(d, ggplot2::aes(x = refe, y = eps)) +
ggplot2::geom_abline(lty = "dashed", col = "red") +
ggplot2::geom_hline(lty = "dashed", col = "green",yintercept=0) +
ggplot2::geom_point() +
ggplot2::theme(plot.title = ggplot2::element_text(hjust = 0.5)) +
ggplot2::coord_fixed(ratio = 1) +
ggplot2::labs(
x = reference,
y = "residual"
)
print(p)
if (!(DESKTOP)) {
grDevices::dev.off()
return(filename)
} else {
return(TRUE)
}
}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_qq.R
\name{plot_qq}
\alias{plot_qq}
\title{plot_qq
plot_qq}
\usage{
plot_qq(x, reference, client, path = tempdir(), name = NULL,
width_mm = 200, height_mm = 200, DESKTOP = TRUE)
}
\arguments{
\item{x}{tbl_friendlyts data.frame}
\item{reference}{reference in character}
\item{client}{reference in character}
\item{path}{path}
\item{name}{name}
\item{width_mm}{width_mm}
\item{height_mm}{height_mm}
\item{DESKTOP}{boolean}
}
\description{
plot_qq
plot_qq
}
\examples{
\dontrun{
plot_qq()
}
}
\keyword{basicr}
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot_qq.R
\name{plot_qqRes}
\alias{plot_qqRes}
\title{plot_qqRes
plot_qqRes}
\usage{
plot_qqRes(x, reference, client, path = tempdir(), name = NULL,
width_mm = 200, height_mm = 200, DESKTOP = TRUE)
}
\arguments{
\item{x}{friendlyts data.frame}
\item{reference}{reference in character}
\item{client}{reference in character}
\item{path}{path}
\item{name}{name}
\item{width_mm}{width_mm}
\item{height_mm}{height_mm}
\item{DESKTOP}{boolean}
}
\description{
plot_qqRes
plot_qqRes
}
\examples{
\dontrun{
plot_qqRes()
}
}
\keyword{friendlyts}
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