Displaying 20 results from an estimated 10000 matches similar to: "ltext( pos=NULL )"
2005 Nov 10
2
ltext - adding text to each panel from a matrix
Hi all (really probably just Deepayan):
In the plot below I want to add text on either side of each violin plot that
indicates the number of observations that are either positive or negative.
I'm trying to do this with ltext() and I've also monkeyed about with
panel.text(). The code below is generally what I want but my calls to
ltext() are wrong and I'm not sure how to fix them.
2003 Oct 27
1
How can strheight be calculated in lattice/grid?
If I have drawn a string with ``ltext( x, y, labels="first string" )''
how can a draw a second string just one line (or strheight("X")
below the first string regardless of the size and scales of the panel?
Thanks
Wolfram
2003 Jan 24
1
problem with srt vector in xyplot {lattice}
[ R 1.6.1 ]
PROBLEM
The plot of the appended code does produce
a postscript file which is not interpretable
by gv under Linux.
REMARK
If the srt argument is commented out or set to a constant
like 45 or 90, the ps file becomes interpretable.
CODE
xytest <- function( ... ){
with( airquality, { print( xyplot(
Ozone ~ Temp | Month
, panel
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 ) )
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
2004 Apr 14
1
ltext, plotmath, and substitute
I am interested to use plotmath functions within a panel function but am having
some problems getting the code right. Within each panel I am plotting the data,
fitting a regression line, and would like to print the regression equation.
Here is a trivial example of what I'd like to do:
# generate simple data
tmp.df <- data.frame(id = rep(1:4, each=4),
time = rep(1:4, 4),
das =
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 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
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
> !
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,
2006 Jul 19
2
trellis.focus with postscript device
Hello.
First: R 2.3.1 on Windows XP.
I am trying to add information (sample size) to the Trellis strips which
I am successful using the trellis.focus function with the default
Windows device. However, I typically use the postscript device as I use
LaTeX and \includegraphic for incorporating graphs into stat reviews.
Here's some example code (apologies for the lack of creativity and
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:
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
2003 Jan 15
1
lattice: cloud: aspect ratio, labels, vertical lines
I am interested to know how to make for clouds:
- aspect ratio = 1
- labels attached to points
- vertical lines from the points to the x/y base plane
I tried:
t = c( 'A', 'B', 'C', 'D' )
x = c( 100, 0, 200, 100 )
y = c( 0, 100, 0, 100 )
z = c( 80, 0, 20, 40 )
q = data.frame( x, y, z )
rownames( q ) = t
print(cloud( z ~ x *
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
2010 Jan 24
1
lattice ltext
Dear friends - please give me a hand.
I have a dataset of 40 patients in two groups observed on three
occasions. I only want to plot a line
for each patient in the two groups. I use the ltext function to put the
patient number but fail to make lattice understand the numbers as
unique since apparently it starts all over with 1:20 for each panel
instead of respecting my desires to have 1:20