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
97c1a182
Commit
97c1a182
authored
Jan 10, 2019
by
jml
Browse files
add boolean DESKTOP
parent
83ad5993
Changes
2
Hide whitespace changes
Inline
Side-by-side
R/plot.R
View file @
97c1a182
...
...
@@ -2,12 +2,12 @@
#' plot_tbl_basic
#' plot_tbl_basic
#' @param x tbl_basic object
#' @param dataset friendlyr data.frame
#' @param df tbl_friendlyts data.frame
#' @param target target
#' @param group
group character
#' @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
#' @keywords basicr
...
...
@@ -16,16 +16,11 @@
#' \dontrun{
#' plot_tbl_basic()
#' }
plot_tbl_basic
<-
function
(
x
,
dataset
,
target
,
group
,
path
=
NULL
,
name
=
NULL
,
width_mm
=
200
,
height_mm
=
200
){
plot_tbl_basic
<-
function
(
df
,
target
,
group
,
path
=
tempdir
()
,
name
=
NULL
,
DESKTOP
=
TRUE
,
width_mm
=
200
,
height_mm
=
200
){
if
(
!
is.null
(
path
))
{
diagnrdir
<-
normalizePath
(
file.path
(
path
,
"basicr"
,
"figures"
),
mustWork
=
FALSE
)
dir.create
(
diagnrdir
,
showWarnings
=
FALSE
,
recursive
=
TRUE
)
if
(
is.null
(
name
))
{
filename
<-
normalizePath
(
tempfile
(
pattern
=
"file"
,
tmpdir
=
diagnrdir
,
fileext
=
".tiff"
),
mustWork
=
FALSE
)
}
else
filename
<-
normalizePath
(
file.path
(
diagnrdir
,
paste0
(
name
,
".tif"
)),
mustWork
=
FALSE
)
if
(
!
DESKTOP
)
{
filename
<-
normalizePath
(
file.path
(
path
,
paste0
(
"basic_"
,
group
,
"_"
,
target
,
".tiff"
)),
mustWork
=
FALSE
)
grDevices
::
tiff
(
filename
=
filename
,
width
=
width_mm
,
height
=
height_mm
,
units
=
"mm"
,
pointsize
=
12
,
...
...
@@ -34,21 +29,21 @@ plot_tbl_basic <- function(x,dataset,target,group,path=NULL,name=NULL,width_mm=2
}
else
grDevices
::
dev.new
()
# just to get class
x
<-
x
names
(
dataset
)[
names
(
dataset
)
==
target
]
<-
"targ"
names
(
df
)[
names
(
df
)
==
target
]
<-
"targ"
p
<-
switch
(
group
,
"HOUR"
=
ggplot2
::
ggplot
(
dataset
)
+
ggplot2
::
geom_boxplot
(
ggplot2
::
aes
(
x
=
HOUR
,
y
=
targ
))
+
ggplot2
::
labs
(
x
=
group
,
y
=
target
),
"WDAY"
=
ggplot2
::
ggplot
(
dataset
)
+
ggplot2
::
geom_boxplot
(
ggplot2
::
aes
(
x
=
wday
,
y
=
targ
))
+
ggplot2
::
labs
(
x
=
group
,
y
=
target
),
"MONTH"
=
ggplot2
::
ggplot
(
dataset
)
+
ggplot2
::
geom_boxplot
(
ggplot2
::
aes
(
x
=
MONTH
,
y
=
targ
))
+
ggplot2
::
labs
(
x
=
group
,
y
=
target
),
"YEAR"
=
ggplot2
::
ggplot
(
df
)
+
ggplot2
::
geom_boxplot
(
ggplot2
::
aes
(
x
=
YEAR
,
y
=
targ
))
+
ggplot2
::
labs
(
x
=
group
,
y
=
target
),
"MONTH"
=
ggplot2
::
ggplot
(
df
)
+
ggplot2
::
geom_boxplot
(
ggplot2
::
aes
(
x
=
MONTH
,
y
=
targ
))
+
ggplot2
::
labs
(
x
=
group
,
y
=
target
),
"WDAY"
=
ggplot2
::
ggplot
(
df
)
+
ggplot2
::
geom_boxplot
(
ggplot2
::
aes
(
x
=
wday
,
y
=
targ
))
+
ggplot2
::
labs
(
x
=
group
,
y
=
target
),
"HOUR"
=
ggplot2
::
ggplot
(
df
)
+
ggplot2
::
geom_boxplot
(
ggplot2
::
aes
(
x
=
HOUR
,
y
=
targ
))
+
ggplot2
::
labs
(
x
=
group
,
y
=
target
),
"MINUTE"
=
ggplot2
::
ggplot
(
df
)
+
ggplot2
::
geom_boxplot
(
ggplot2
::
aes
(
x
=
MINUTE
,
y
=
targ
))
+
ggplot2
::
labs
(
x
=
group
,
y
=
target
),
"SECOND"
=
ggplot2
::
ggplot
(
df
)
+
ggplot2
::
geom_boxplot
(
ggplot2
::
aes
(
x
=
SECOND
,
y
=
targ
))
+
ggplot2
::
labs
(
x
=
group
,
y
=
target
),
stop
(
"group not recognized"
))
print
(
p
)
if
(
!
is.null
(
path
)
)
{
if
(
!
DESKTOP
)
{
grDevices
::
dev.off
()
print
(
filename
)
}
else
{}
return
(
TRUE
)
...
...
man/plot_tbl_basic.Rd
View file @
97c1a182
...
...
@@ -5,22 +5,22 @@
\title{plot_tbl_basic
plot_tbl_basic}
\usage{
plot_tbl_basic(
x, dataset
, target, group, path =
NULL
, name = NULL,
width_mm = 200, height_mm = 200)
plot_tbl_basic(
df
, target, group, path =
tempdir()
, name = NULL,
DESKTOP = TRUE,
width_mm = 200, height_mm = 200)
}
\arguments{
\item{x}{tbl_basic object}
\item{dataset}{friendlyr data.frame}
\item{df}{tbl_friendlyts data.frame}
\item{target}{target}
\item{group}{
group character
}
\item{group}{
"none","YEAR","MONTH","WDAY","HOUR","MINUTE","SECOND"
}
\item{path}{path}
\item{name}{name}
\item{DESKTOP}{boolean}
\item{width_mm}{width_mm}
\item{height_mm}{height_mm}
...
...
@@ -35,4 +35,3 @@ plot_tbl_basic()
}
}
\keyword{basicr}
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