Displaying 20 results from an estimated 10000 matches similar to: "lattice: scales beginning at zero with relation="free""
2006 Dec 08
1
lattice: defining an own function using args for "formula" and "groups"
x.fun <- function( formula, data ) dotplot( formula, data )
x.grp <- function( formula, groups, data ) dotplot( formula, groups, data )
data( barley )
> x.fun( variety ~ yield | site, data=barley )
# no problem
> dotplot( variety ~ yield | site, groups=year, data=barley )
# no problem
> x.grp( variety ~ yield | site, groups=year, data=barley )
object "year" not found
2004 Oct 04
11
inverse function of order()
I have:
d <- sample(10:100, 9)
o <- order(d)
r <- d[o]
How I can get d (in the original order), knowing only r and o?
Thanks - Wolfram
2002 May 03
2
sub() of matrix returns a vector and not a matrix
Is there a simple possibility
to become directly a matrix
from a call of sub() on a matrix?
--------- START OF LOGFILE ----------------
# R 1.4.1
> a <- matrix( letters[1:6], 2, 3 )
# a is a matrix
> print( a )
[,1] [,2] [,3]
[1,] "a" "c" "e"
[2,] "b" "d" "f"
> b <- sub( '(.)', '-\\1-', a )
2006 Nov 29
4
Why the factor levels returned by cut() are not ordered?
What is the reason, that the levels of the factor
returned by cut() are not marked as ordered levels?
> is.ordered( cut( breaks=3, sample(10 ) ) )
FALSE
> help(factor)
...
If 'ordered' is 'TRUE', the factor levels are assumed to be ordered.
...
Wolfram
2005 Apr 11
6
How to change letters after space into capital letters
What is the easiest way to change within vector of strings
each letter after a space into a capital letter?
E.g.:
c( "this is an element of the vector of strings", "second element" )
becomes:
c( "This Is An Element Of The Vector Of Strings", "Second Element" )
My reason to try to do this is to get more readable abbreviations.
(A suggestion would be to
2003 Jan 24
4
new function: showcolors {base}
I propose to add a function that allows
to display colors selected by a text pattern
or by color vectors in a plot.
Wolfram Fischer
#--- showcolors.R
showcolors <-
function(
col = "red"
, index = NULL
, pie = TRUE
, lwd = 6
, cex = 1.0
, main = NULL
, sub = NULL
, ...
){
n.colors <- length( col )
if( n.colors > 1 ){
main <- deparse( substitute( col ) )
2008 Feb 14
1
{lattice/grid} "Error using packet 1" and traceback
On some errors during the plot of a lattice/grid graphics, there is written
a message like "Error using packet 1: missing value where TRUE/FALSE needed"
into the concering panel and the next panel is plotted.
Which option I could use to stop the execution to have a look
at the error by a traceback?
Regards - Wolfram
2003 Aug 29
2
length() and nchar()
I would propose to add "
See also:
`nchar' for counting the number of character in
character vectors.
"
to the helpfile of length(),
because it is rather difficult
to find nchar() if one has only
search terms as "length", "len",
"strlen" in mind.
Sincerly
Wolfram Fischer
2003 Dec 22
1
[R] lattice: levelplot: error: min not meaningful for factor (PR#6005)
R 1.8.1:
___COMMAND____________________________________________
levelplot( yield ~ year * variety | site, barley )
___ERROR_MESSAGE______________________________________
Error in Summary.factor(..., na.rm = na.rm) :
"min" not meaningful for factors
___COMMENT____________________________________________
levelplot( yield ~ as.numeric(year) * as.numeric(variety) | site,
2004 Dec 07
1
how to test the existence of a name in a dataframe
I wanted to test if there exists already a name (which is
incidentally a substring of another name) in a dataframe.
I did e.g.:
> data(swiss)
> names(swiss)
[1] "Fertility" "Agriculture" "Examination" "Education"
[5] "Catholic" "Infant.Mortality"
> ! is.null(swiss$EduX)
[1] FALSE
> !
2004 Mar 04
1
lattice/grid: problem with viewports for strips with zero height
PROBLEM
# Allocating strip labels by the function strip.fun():
strip.test()
# Result: No strips: ok. No strings: NOT OK.
# The distance ``y.text=unit(6,"points")'' is ignored;
# the strings are not seen on the output.
TRIALS FOR WORKAROUNDS
strip.test( strip.lines=1 )
# Result: 2 strips: ok, but not whished. 2 strings: ok.
2005 Apr 15
4
function corresponding to map of perl
Is there a function in R that corresponds to the
function ``map'' of perl?
It could be called like:
vector.a <- map( vector.b, FUN, args.for.FUN )
It should execute for each element ele.b of vector.b:
FUN( vector.b, args.for.FUN)
It should return a vector (or data.frame) of the results
of the calls of FUN.
It nearly works using:
apply( data.frame( vector.b ), 1, FUN,
2002 Nov 15
1
lattice: formatting tickmark labels of log scaled axes
Problem:
How can I format tickmark labels of log scaled axes of lattice
graphics in the usual `xxx'-Format (and not in the scientific
format).
Example:
(according to the help-page of xyplot):
In the first plot I get the xxx-Format,
in the second plot I get the scientific format (10^xxx):
data(sunspot)
plot( 1:37, sunspot, log='y',type='l')
xyplot( sunspot ~ 1:37,
2007 Feb 15
2
Problems with 'delay'/'delayedAssign' when installing data package
I downloaded:
http://www.bioconductor.org/data/metaData/hgu95av2_1.7.0.tar.gz
described as:
Package: hgu95av2
Title: A data package containing annotation data for hgu95av2
Version: 1.7.0
Created: Wed Jan 12 16:57:23 2005
Author: Lin,Chenwei
Description: Annotation data file for hgu95av2 assembled using data
from public data repositories
Maintainer:
2004 Feb 12
2
lattice: showing panels for factor levels with no values
How to show panels for factor levels of conditioning variables
which do have no values?
E.g. there are panels for "Grand Rapids" when they have values:
data( barley )
with( barley, dotplot(variety ~ yield | year * site, layout=c(6,2) ) )
There are no panels for "Grand Rapids"
when there are no values for "Grand Rapids":
my.barley <- subset( barley, ! ( site ==
2004 Jun 11
1
lattice: cumsum and xyplot
I want to display cumulative summary functions with lattice.
First I tried to get cumulated data:
library(lattice)
data(barley)
d.cum <- with( barley, by( yield, INDICES=list(site=site,year=year), FUN=cumsum ) )
I got a list of vectors.
I tried to get a dataframe which I could use in xyplot.
But neither of the following functions led to the goal:
d.cum.df1 <-
2002 May 21
1
plotting functions with line width (lwd) as vectors
If I want to plot different widths of line segments or arrows
I have to program loops to plot each line apartly. Is that
right?
n <- 6
x <- 1:n
y <- rnorm(1:n)
q <- ( x %% 3 + 1 ) * 2
plot( x, y, cex=q )
for( i in 1:(n-1) ) lines( x[i:(i+1)], y[i:(i+1)], lwd=q[i], col=q[i] )
Would it not be possible to make plotting functions accept
vectors of line widths (as they
2004 Oct 22
1
ave gives unexpected NA's
[R 2.0.0 on Linux]
I tried:
> df <- data.frame(
grp1=factor( c('A' ,'A' ,'A' ,'D', 'D' ) ) ,
grp2=factor( c('a1','a2','a2','d1','d1') )
)
> df
grp1 grp2 val
1 A a1 1
2 A a2 2
3 A a2 4
4 D d1 8
5 D d1 16
I got:
> with( df, ave( val, grp1, grp2, FUN=sum ) )
2002 Nov 11
2
repeating a dataframe n times in the direction of the rows
Question:
How can a repeat a dataframe n times
in the direction of the rows?
(Or: How I can rbind a dataframe n times ?)
Example Data:
x <- data.frame( alpha=letters[1:3], num=1:3 )
n <- 4
Complicated solution: To rbind a dataframe n times I can program a loop:
xr <- x
for( i in 2:n ) xr <- rbind( xr, n )
Observation: To cbind a dataframe n times I
2009 Mar 30
1
Lattice axis list (when relation = "free")
Dear R users:
I am having difficulty to place x-axis location alternatively
top/bottom side in Lattice plot, which is composed of seven-column as
following:
E1 E2 E3 E4 E5 E6 E7
Case1 -505.85 -75.32 494.52 -12.31 -98.96 50.34 -48.62
Case2 -50.46 -60.97 68.32 -8.66 -51.77 25.17 -26.60
Case3 -253.00 -54.99 243.48 -8.76