Displaying 20 results from an estimated 9000 matches similar to: "plotting functions with line width (lwd) as vectors"
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 )
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
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
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,
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
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
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 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,
2002 Nov 04
1
[R] CTRL-C suspends echo of shell (R versions 1.6.0 and 1.6.1) (PR#2253)
Problem:
- Shell does not echo anymore
after using CTRL-C (to interrupt calculations)
once during a R session.
Procedure:
- [start session] R
- [input] CTRL-C
- [end session] q()
Some details:
- `stty` before: speed 38400 baud; line = 0; lnext = <undef>;
- `stty` after: speed 38400 baud; line = 0; lnext = <undef>; min = 1; time = 0;
-icrnl
-icanon -echo
I
2003 Jan 22
1
text() does not accept data of type POSIXlt (PR#2487)
[R 1.6.1]
PROBLEM
If text() is called with an argument of type POSIXlt,
I get the following error message:
"Error in as.double.default(x) :
(list) object cannot be coerced to vector type 14"
REMARK
plot() accepts this data.
EXAMPLE
data( Lifeboats, package='vcd' )
attach(Lifeboats)
plot( launch, total )
text( launch, total,
2003 Dec 05
1
R 1.8.1 ./configure with "," in working directory (PR#5536)
PROBLEM
``./configure'' creates empty Makefiles and the following error messages
if there is a ``,'' in the name of the working directory.
REMARK
As I have seen, ``,'' is used as separator for the sed statements in
config.status. Would it be possible to use instead a character which
cannot be used in a pathname, e.g. ``;''?
ERROR MESSAGES
...
checking for lpr...
2003 Jan 21
1
[R] proposal: lattice/levelplot: panel.catlevelplot
I suggest to add a panel function to levelplot (or perhaps
to an other 3d lattice function) which is able to translate
the z values into the size of the rectangles.
It could be used to display categorical data.
I append the proposed code and two examples:
- panel.catlevelplot()
- example1.catlevelplot.esoph()
- example2.catlevelplot.esoph()
Wolfram Fischer
#------ CODE
2006 Apr 26
1
lwd - Windows
Dear all
Is there a way or trick in windows to plot a line width that is not an
integer i.e 1.5?
I am aware that the documentation for window devices states "Line widths as
controlled by par(lwd=) are in multiples of the pixel size, and multiples <
1 are silently converted to 1" but I was wondering if there is a workaround
this.
Also, IMHO the documentation for lwd in par may
2004 Mar 10
3
converting lists got by tapply to dataframes
I have two lists:
xa <- list( X=c(1,2,3), Y=c(4,5,6), Z=c(7,8,9) )
xb <- with( barley, tapply( X=seq(1:nrow(barley)), INDEX=site
, FUN=function(z)yield[z]))
I can convert xa to a dataframe easily with:
as.data.frame(xa)
But if i try the same with xb I get:
as.data.frame(xb)
Error in as.data.frame.default(xb) :
can't coerce array into a data.frame
What