Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
rdiagnosis
basicr
Commits
ad6155f9
Commit
ad6155f9
authored
Jan 31, 2019
by
Jean-Marie Lepioufle
Browse files
plot_tbl_basic on its own file
parent
263976d5
Changes
2
Hide whitespace changes
Inline
Side-by-side
R/plot_tbl_basic.R
0 → 100644
View file @
ad6155f9
#' 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'"
)
}
man/plot_tbl_basic.Rd
View file @
ad6155f9
% 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}
\alias{plot_tbl_basic}
\title{plot_tbl_basic
plot_tbl_basic}
\usage{
plot_tbl_basic(df, target, group, path = tempdir(), name = NULL,
DESKTOP = TRUE, width_mm = 200, height_mm = 200)
plot_tbl_basic(x, target, group, path = tempdir(), name = NULL,
DESKTOP = TRUE, width_mm = 200, height_mm = 200,
y_name = "Y-axis")
}
\arguments{
\item{
df
}{tbl_friendlyts data.frame}
\item{
x
}{tbl_friendlyts data.frame}
\item{target}{target}
...
...
@@ -24,6 +25,8 @@ plot_tbl_basic(df, target, group, path = tempdir(), name = NULL,
\item{width_mm}{width_mm}
\item{height_mm}{height_mm}
\item{y_name}{y_name}
}
\description{
plot_tbl_basic
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment