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
7f74aab4
Commit
7f74aab4
authored
Jan 31, 2019
by
Jean-Marie Lepioufle
Browse files
related to l-moment
parent
0379f0cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
R/plot_lmrd.R
0 → 100644
View file @
7f74aab4
#' plot_lmrd
# Function adapted from the package lmom
# Draws an L-moment ratio diagram
#' plot_lmrd
#' @param x tbl_lmom data.frame
#' @param path path
#' @param name name
#' @param DESKTOP boolean
#' @param width_mm width_mm
#' @param height_mm height_mm
#' @keywords basicr
#' @export
#' @examples
#' \dontrun{
#' plot_lmrd()
#' }
plot_lmrd
<-
function
(
x
,
path
=
tempdir
(),
name
=
NULL
,
DESKTOP
=
TRUE
,
width_mm
=
200
,
height_mm
=
200
)
{
if
(
inherits
(
x
,
"tbl_lmom"
))
{
#start plot
if
(
!
(
DESKTOP
))
{
if
(
is.null
(
name
))
{
filename
<-
normalizePath
(
file.path
(
path
,
paste0
(
"lmrd.tiff"
)),
mustWork
=
FALSE
)
}
else
filename
<-
normalizePath
(
file.path
(
path
,
paste0
(
"lmrd_"
,
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
()
path
<-
try
(
normalizePath
(
file.path
(
.libPaths
()[
1
],
"basicr"
,
"data"
,
"lmrd_n_param_distrib.rda"
),
mustWork
=
TRUE
))
load
(
path
)
lmrd_distrib
<-
get
(
"lmrd_n_param_distrib"
,
envir
=
environment
())
lmrd_3
<-
lmrd_distrib
%>%
dplyr
::
filter
(
nb_par
==
3
)
lmrd_2
<-
lmrd_distrib
%>%
dplyr
::
filter
(
nb_par
==
2
)
x_min
<-
min
(
0
,
x
$
t_3
,
na.rm
=
TRUE
)
x_max
<-
max
(
0.6
,
x
$
t_3
,
na.rm
=
TRUE
)
y_min
<-
min
(
0
,
x
$
t_4
,
na.rm
=
TRUE
)
y_max
<-
max
(
0.4
,
x
$
t_4
,
na.rm
=
TRUE
)
# plot
p
<-
ggplot2
::
ggplot
()
+
ggplot2
::
geom_line
(
data
=
lmrd_3
,
ggplot2
::
aes
(
x
=
t_3
,
y
=
t_4
,
group
=
distribution
,
linetype
=
distribution
))
+
ggplot2
::
geom_point
(
data
=
lmrd_2
,
ggplot2
::
aes
(
x
=
t_3
,
y
=
t_4
,
group
=
distribution
,
shape
=
distribution
),
size
=
2
)
+
# ggplot2::scale_size_continuous(guide = FALSE) +
ggplot2
::
scale_shape_discrete
(
name
=
"2-par distribution"
)
+
ggplot2
::
scale_linetype_discrete
(
name
=
"3-par distribution"
)
+
ggplot2
::
geom_point
(
data
=
x
,
ggplot2
::
aes
(
x
=
t_3
,
y
=
t_4
,
colour
=
ID
),
size
=
2
,
shape
=
8
)
+
ggplot2
::
labs
(
x
=
expression
(
italic
(
L
)
*
"-skewness"
),
y
=
expression
(
italic
(
L
)
*
"-kurtosis"
))
+
ggplot2
::
xlim
(
x_min
,
x_max
)
+
ggplot2
::
ylim
(
y_min
,
y_max
)
print
(
p
)
if
(
!
(
DESKTOP
))
{
grDevices
::
dev.off
()
return
(
filename
)
}
else
{
return
(
TRUE
)
}
}
else
stop
(
"x as 'tbl_lmom' object"
)
}
man/lmrd_n_param_distrib.Rd
0 → 100644
View file @
7f74aab4
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lmrd_n_param_distrib.R
\docType{data}
\name{lmrd_n_param_distrib}
\alias{lmrd_n_param_distrib}
\title{lmrd_n_param_distrib}
\format{A rda file}
\source{
https://cran.r-project.org/web/packages/lmom/
}
\description{
lmrd_n_param_distrib provides L-skewness and L-kurtosis values of key 2-par and 3-par distributions
}
\references{
J. R. M. Hosking
}
\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