Displaying 20 results from an estimated 10000 matches similar to: "new function: showcolors {base}"
2003 Jan 24
0
new function: twotailed.colors {base}
I suggest to add a new function to create a vector of
n ``contiguous'' colors with tails in two colors.
This function is similar to `cm.colors' but the colors
can be choosen by hsv values.
This function could be used e.g. as alternative to
the default ``col.regions'' in `levelplot'.
Perhaps the arguments in the following code could be
simplified.
Wolfram Fischer
#---
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
2017 Apr 16
1
Getting high precision values from qnorm in the tail
Hello All
I am looking for high precision values for the normal distribution in the
tail,(1e-10 and 1 - 1e-10) as the R package that I am using sets any number
which is out of this range to these values and then calls the qnorm and qt
function.
What I have noticed is that the qnorm implementation in R is not symmetric
when looking at the tails. This is quite surprising to me, as it is well
known
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
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 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 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
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,
2004 Jul 08
2
Getting elements of a matrix by a vector of column indice s
See if the following helps:
> m <- outer(letters[1:5], 1:4, paste, sep="")
> m
[,1] [,2] [,3] [,4]
[1,] "a1" "a2" "a3" "a4"
[2,] "b1" "b2" "b3" "b4"
[3,] "c1" "c2" "c3" "c4"
[4,] "d1" "d2" "d3" "d4"
[5,]
2008 Sep 03
2
Highlighint rjs problem on a new product
Hi,
Problem Summary:
I have been trying to add the highlight effect to my table but
everytime a new record is added the highlighting gives an rjs error.
However when i click the add to cart button on a product that already
exists inside the table, the highlight effect works. Is this because
the partial must only have only one <tr></tr> in it and the <table>
must be on the other
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:
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
2003 Jul 14
1
for loop problem
Dear list,
Here's a function that works fine
when I assign one value to i.
qx, ax and gr are vectors.
ax.to.nax <- function(qx, ax, gr=c(0,1,5,10)){
px <- 1 - qx
last.n <- gr[length(gr)] - gr[length(gr) - 1]
all.bounds <- c(gr, gr[length(gr)] + last.n)
n <- diff(all.bounds)
#
i <- 1 # this i should loop through the values of
# gr: i=0, i=1, i=5 and i=10.
#
testprod
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
2013 Feb 25
1
colors to pie chart.
hello, all.
i am trying something new and am stuck. i typically go with whatever colors the pie function pops out, but i would like to customize it.
please find below a sample dataset.
##TVs per household.
TVs <- factor(c(rep("0", 1), rep("1", 16), rep("2", 14), rep("3", 12), rep("4", 3), rep("5", 2), rep("6", 2)))
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 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 ) )