Displaying 20 results from an estimated 20000 matches similar to: "Is there a "by()" function in R like in S?"
2004 Oct 25
2
box() and hist()
Hi,
does anybody know why the following is not working:
> hist(rnorm(200))
> box(bty="o")
gives me a box without rounded corners.
System:
> R.Version()
$platform
[1] "i386-pc-mingw32"
$arch
[1] "i386"
$os
[1] "mingw32"
$system
[1] "i386, mingw32"
$status
[1] ""
$major
[1] "2"
$minor
[1] "0.0"
$year
2004 Jul 16
1
Fixed and random factors in aov()
Hi,
I'm confused about how to specify random and fixed factors in an aov()
term. I tried to reproduce a textbook example: One fixed factor (Game, 4
levels) and one random factor (Store, 12 levels), response is Points.
The random factor Store is nested in Game. I tried
> str(kh.df)
`data.frame': 48 obs. of 4 variables:
$ Subj : Factor w/ 48 levels
2008 Apr 15
1
by inconsistently strips class - with fix
summary:
The function 'by' inconsistently strips class from the data to which
it is applied.
quick reason:
tapply strips class when simplify is set to TRUE (the default) due to
the class stripping behaviour of unlist.
quick answer:
This can be fixed by invoking tapply with simplify=FALSE, or changing
tapply to use do.call(c instead of unlist
executable example:
2010 Sep 13
2
value returned by by()
Hi,
I noticed that by() returns an object of class 'by', regardless of what
its argument 'simplify' is. ?by says that it always returns a list if
simplify=FALSE, yet by.data.frame shows:
---<--------------------cut here---------------start------------------->---
function (data, INDICES, FUN, ..., simplify = TRUE)
{
if (!is.list(INDICES)) {
IND <-
2007 Dec 10
2
bug in by.data.frame, R-2.6.1 (PR#10506)
by() fails for 1-column matrices and dataframes:
X <- data.frame(a=1:10)
g <- gl(2,5)
by(X, g, colMeans)
Suggested fix:
--- by-old.R 2007-12-10 15:26:22.501086600 +0100
+++ by.R 2007-12-10 15:25:58.390477200 +0100
@@ -26,7 +26,7 @@
IND[[1]] <- INDICES
names(IND) <- deparse(substitute(INDICES))[1]
} else IND <- INDICES
- FUNx <-
2000 Apr 28
1
Using 'by()' in a function
I have a list of dataframes, and want to apply a function to subsets of the rows
of each dataframe. It seemed natural to write a function that takes a dataframe
as an argument, and uses 'by() within it to apply the function to the dataframe
subsets. However, I cannot get it to work. The problem seems to be passing the
data argument of by() as a function argument. Is this bug, or am I
2001 Nov 22
4
changing the magnification of axis annotation
Hi all,
how do I change the magnification of xaxis annotation? I need a smaller
axis text size in some of my plots. I tried cex.axix=0.5 in plot(), but
this doesn't work.
Thanks, Sven
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or
2002 May 29
4
Why is.integer() doesn't work with single values?
Hi all,
I don't understand the behavior of is.integer():
> x <- integer()
> is.integer(x)
[1] TRUE
> x <- 10
> is.integer(x)
[1] FALSE
> x <- 1:10
> is.integer(x)
[1] TRUE
Why is.interger() returns FALSE if x has only one element? And how can
someone check if x is an integer but contains only one value? (R 1.5.0
on Linux i386)
Thanks, Sven
2001 Jul 26
6
replacing values in a vector
Hi all,
there is a vector v with several NAs. I want to create a new vector n of
the same length as v and the same NAs as in v and tried this:
n <- vector(length=length(v), mode="numeric")
replace(n, which(is.na(v)), NA)
but this does't work, all values in n are 0. What went wrong?
Thanks, Sven
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
2003 Aug 27
2
How to test a model with two unkown constants
Hi all,
suppose I've got a vector y with some data (from a repeated measure
design) observed given the conditions in f1 and f2. I've got a model
with two unknown fix constants a and b which tries to predict y with
respect to the values in f1 and f2. Here is an exsample
# "data"
y <- c(runif(10, -1,0), runif(10,0,1))
# f1
f1 <- rep(c(-1.4, 1.4), rep(10,2))
# f2
f2 <-
2001 Jun 13
2
Maybe OT: large fonts in eps-figures
Hi there,
if I copy an x11() graphics device to an eps-file (with dev.copy2eps())
the font in the legend is very large and doesn't fit to the legend box
in the eps-file (same with a postscript file). I'm not sure if this is a
R problem rather than a ghostscript one.
But is there a way to solve this problem in R or depends this on my
ghostscript installation?
System: R Version 1.2.3 on
2002 Sep 18
2
comparing elements in a vector
How about --
d is a vector as you described it, then define
d1 <- d[1:(length(d)-1)]
d2 <- d[2:length(d)]
d3 <- d1!=0 & d2!=0 & (d1-d2)!=0
I think d3 is the final vector you wanted.
I didn't test it, so I'm not sure my logic is right, but I think this is
definitely a path you can take...
-----Original Message-----
From: owner-r-help at stat.math.ethz.ch
2001 Jul 09
1
Error plotting time series
Hi there,
when plotting a time series I got this error message:
Error in xy.coords(x, y, xlabel, ylabel, log) :
x and y lengths differ
In addition: Warning messages:
1: longer object length
is not a multiple of shorter object length in: vx.1[int.lr] + (-1) *
vx.2[int.rl]
vx.1[int.rl] and vx.2[int.rl] have the same length. Does anybody know
what the warning message means?
Thanks, Sven
2002 Mar 21
1
Wilks Lamba
Hi all,
I can't figure out how to compute Wilks Lambda in a one way repeated
measure design. My matrix looks like:
> t2.m
Blank ECR ENC UEA UED
1 -0.15 0.14 0.16 0.09 0.14
2 0.30 0.08 0.14 0.14 0.14
[...]
where each row is a case and the columns are levels of one factor (named
trial):
> t2.fit <- manova(t2.m ~ 1)
> summary(t2.fit, intercept=T,
2000 Apr 13
1
how convert an array to a matrix?
Dear R-list,
is it possible to convert a threedimensional array to a matrix? The
array has the form
, , -4
-4 -3 -2 -1 0 1 2 3 4
-80 1588 NA 1171 NA 1121 NA 852 NA 1580
0 1497 NA 1311 NA 762 NA 1185 NA 1466
80 1960 NA 1257 NA 941 NA 1435 NA 1636
[...]
I need a matrix like
-80 -4 -4 1588
-80 -3 -4 NA
-80 -2 -4 1171
etc.
I?ve tried write.table() with no succes:
2001 Jun 01
1
Read to the end of a stream (package Rstreams)
Hi there,
I want to read all data from a binary file (with package Rstreams). I
tried the following function (small piece of code):
readdata <- function (file) {
# open file
s <- openstream(file, "read")
# read int values
while (s$position <= s$size) {
readint(s, 1, 2) -> type
[...]
}
return()
}
and got the following error:
> Error in
2002 Oct 09
1
Large F-value and small P-value
Hi all,
I computed a Wilks Lambda Test with manova:
> df.man <- manova(df.mul ~ 1, na.rm=TRUE)
> summary(df.man, intercep=T, test="Wilks")
Df Wilks approx F num Df den Df Pr(>F)
(Intercept) 1 0.0002824 393.3 9 1 0.03911 *
Residuals 9
---
Signif. codes: 0 `***' 0.001 `**' 0.01 `*'
2000 Apr 10
2
Newbie: how to calculate group averagege?
Dear R-List,
I?m new in R, so I hope my question is not to primitive, but I haven?t
found a solution in the R-help. I?ve got a datatframe with 3 factors,
called xf (9 levels), yf (9 levels), zf (3 levels) and one variable
(rt):
> xf yf zf rt
> 1 1 1 67
> 1 1 1 56
> 1 1 1 60
[...]
> 1 1 2 58
> 1 1 2 61
[...]
> 9 1
2002 Jan 09
2
Creating subsets with factors
Hi all,
I don't understand the following output. I've created a data subset from
a data frame by
> p1.sub <- subset(p1.dat, vp!="p1")
this is ok. But
> attach(p1.sub)
> vp
[1] p1ab p1ab p1ab p1ab p1ab p1br p1br p1br p1br p1br p1kf p1kf p1kf
p1kf p1kf
[16] p1mg p1mg p1mg p1mg p1mg p1mw p1mw p1mw p1mw p1mw
Levels: p1 p1ab p1br p1kf p1mg p1mw
shows me that the
2006 Dec 02
2
nonlinear quantile regression
Hello, I?m with a problem in using nonlinear quantile regression, the
function nlrq.
I want to do a quantile regression o nonlinear function in the form
a*log(x)-b, the coefficients ?a? and ?b? is my objective. I try to use the
command:
funx <- function(x,a,b){
res <- a*log(x)-b
res
}
Dat.nlrq <- nlrq(y ~ funx(x, a, b), data=Dat, tau=0.25, trace=TRUE)
But a can?t solve de problem,