Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
legTools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Harbor Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leg
legTools
Commits
5bc6e143
Commit
5bc6e143
authored
9 years ago
by
Walmes Zeviani
Browse files
Options
Downloads
Patches
Plain Diff
Add twoStripCombined function.
parent
7cf5cbe9
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
R/twoStripCombined.R
+88
-0
88 additions, 0 deletions
R/twoStripCombined.R
man/twoStripCombined.Rd
+48
-0
48 additions, 0 deletions
man/twoStripCombined.Rd
with
136 additions
and
0 deletions
R/twoStripCombined.R
0 → 100644
+
88
−
0
View file @
5bc6e143
#' @title Combine two strips in one to save space
#'
#' @name twoStripCombined
#'
#' @description this function allow combine tow strips in one to save
#' space. It was designed to be used with two conditioning variables.
#'
#' @param textPos position of the strip annotation. The \code{"border"}
#' value indicates that the first conditioning variable is to be aligned
#' to left strip border and the second to the right strip border. The
#' \code{"center"} indicates tha the first is to be right aligned to the
#' strip center and the second to be left aligned to strip center.
#'
#' @param sep a strip, to separate variable names and levels when
#' concatenation is required.
#'
#' @param invert logical, \code{TRUE} means that the first is to be
#' placed on left strip side.
#'
#' @param which.given,which.panel,factor.levels,var.name,strip.names,bg,...
#' arguments of \link[lattice]{strip.default}.
#'
#' @import lattice
#'
#' @export
#'
#' @examples
#'
#' require(lattice)
#'
#' xyplot(yield~K|N+P, data=npk, type=c("p","a"))
#'
#' xyplot(yield~K|N+P, data=npk, type=c("p","a"),
#' strip=twoStripCombined,
#' par.strip.text=list(lines=0.6))
#'
#' xyplot(yield~K|N+P, data=npk, type=c("p","a"),
#' strip=function(...){
#' twoStripCombined(textPos="center", sep="=",
#' strip.names=c("Nitr", "Phos"),
#' invert=TRUE, ...)
#' },
#' par.strip.text=list(lines=0.5),
#' par.settings=list(strip.background=list(col="gray75")))
#'
twoStripCombined
<-
function
(
textPos
=
c
(
"border"
,
"center"
),
sep
=
": "
,
invert
=
TRUE
,
which.given
,
which.panel
,
factor.levels
,
var.name
,
strip.names
=
var.name
,
bg
,
...
){
strip.fun
<-
function
(
i
,
pos
){
if
(
is.na
(
strip.names
[
i
])){
lab
<-
factor.levels
[
which.panel
[
which.given
]]
}
else
{
lab
<-
paste
(
sep
=
sep
,
strip.names
[
i
],
factor.levels
[
which.panel
[
which.given
]])
}
if
(
invert
){
switch
(
textPos
[
1
],
"border"
=
{
panel.text
(
x
=
0
,
y
=
0.5
,
pos
=
pos
[
1
],
lab
=
lab
)
},
"center"
=
{
panel.text
(
x
=
0.5
,
y
=
0.5
,
pos
=
pos
[
2
],
lab
=
lab
)
},
stop
(
"Only `\"border\"` and `\"center\"` values are allowed."
))
}
else
{
switch
(
textPos
[
1
],
"border"
=
{
panel.text
(
x
=
1
,
y
=
0.5
,
pos
=
pos
[
2
],
lab
=
lab
)
},
"center"
=
{
panel.text
(
x
=
0.5
,
y
=
0.5
,
pos
=
pos
[
1
],
lab
=
lab
)
},
stop
(
"Only `\"border\"` and `\"center\"` values are allowed."
))
}
}
##
##-------------------------------------------
##
if
(
which.given
==
1L
){
panel.rect
(
0
,
0
,
1
,
1
,
col
=
bg
,
border
=
1
)
strip.fun
(
i
=
1
,
pos
=
c
(
4
,
2
))
}
if
(
which.given
==
2L
){
strip.fun
(
i
=
2
,
pos
=
c
(
2
,
4
))
}
}
This diff is collapsed.
Click to expand it.
man/twoStripCombined.Rd
0 → 100644
+
48
−
0
View file @
5bc6e143
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/twoStripCombined.R
\name{twoStripCombined}
\alias{twoStripCombined}
\title{Combine two strips in one to save space}
\usage{
twoStripCombined(textPos = c("border", "center"), sep = ": ",
invert = TRUE, which.given, which.panel, factor.levels, var.name,
strip.names = var.name, bg, ...)
}
\arguments{
\item{textPos}{position of the strip annotation. The \code{"border"}
value indicates that the first conditioning variable is to be aligned
to left strip border and the second to the right strip border. The
\code{"center"} indicates tha the first is to be right aligned to the
strip center and the second to be left aligned to strip center.}
\item{sep}{a strip, to separate variable names and levels when
concatenation is required.}
\item{invert}{logical, \code{TRUE} means that the first is to be
placed on left strip side.}
\item{which.given,which.panel,factor.levels,var.name,strip.names,bg,...}{arguments of \link[lattice]{strip.default}.}
}
\description{
this function allow combine tow strips in one to save
space. It was designed to be used with two conditioning variables.
}
\examples{
require(lattice)
xyplot(yield~K|N+P, data=npk, type=c("p","a"))
xyplot(yield~K|N+P, data=npk, type=c("p","a"),
strip=twoStripCombined,
par.strip.text=list(lines=0.6))
xyplot(yield~K|N+P, data=npk, type=c("p","a"),
strip=function(...){
twoStripCombined(textPos="center", sep="=",
strip.names=c("Nitr", "Phos"),
invert=TRUE, ...)
},
par.strip.text=list(lines=0.5),
par.settings=list(strip.background=list(col="gray75")))
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment