Hello everyone
Suppose I have an S3 class "dog" and a function plot.dog() which
looks like this:
plot.dog <- function(x,show.uncertainty, ...){
if (show.uncertainty){
}
}
I think that it would be better to somehow precalculate the
uncertainty stuff and plot it separately.
How b
Dear User=B4s,
=20
run R2.2.0 for Windows Version (S.O. Windows XP) when install.packages()
function, after select the mirror, shown:
--- Please select a CRAN mirror for use in this session ---
Aviso: unable to access index for repository
http://cran.br.r-project.org/bin/windows/contrib/2.2
Aviso:
This is not a bug.
And if a bug, you are asked to only report bugs of recent versions of R!
Please ask questions on R-help!
1. Please check your firewall and proxy settings.
2. Please upgrade to a recent version of R.
Uwe Ligges
[EMAIL PROTECTED] wrote:
> Dear User=B4s,
> =20
> run R2.2.0 for
Robin Hankin <[EMAIL PROTECTED]> writes:
> Hello everyone
>
> Suppose I have an S3 class "dog" and a function plot.dog() which
> looks like this:
>
> plot.dog <- function(x,show.uncertainty, ...){
>
>if (show.uncertainty){
>and superimpose the results on the simple plot>
>
Full_Name: Gavin Simpson
Version: 2.5.0
OS: Linux (FC5)
Submission from: (NULL) (128.40.33.76)
Screeplots are a common plot-type used to interpret the results of various
ordination methods and other techniques. A number of packages include ordination
techniques not included in a standard R instal
Hi,
I have a big data frame:
> mat <- matrix(rep(paste(letters, collapse=""), 5*30), ncol=5)
> dat <- as.data.frame(mat)
and I need to do some computation on each row. Currently I'm doing this:
> for (key in row.names(dat)) { row <- dat[key, ]; ... do some computation on
row... }
w
Herve Pages wrote:
...
> But if, instead of the above, I do this:
>
> > for (i in nrow(dat)) { row <- sapply(dat, function(col) col[i]) }
Should have been:
> for (i in 1:nrow(dat)) { row <- sapply(dat, function(col) col[i]) }
>
> then it's 20 times faster!!
>
> > system.time(for (i in 1
Extracting rows from data frames is tricky, since each of the columns could be
of a different class. For your toy example, it seems a matrix would be a more
reasonable option.
R-devel has some improvements to row extraction, if I remember correctly. You
might want to try your example there.
Your 2 examples have 2 differences and they are therefore confounded in
their effects.
What are your results for:
system.time(for (i in 1:100) {row <- dat[i, ] })
--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
(801) 408-8111
> -Ori
Hi Hervé
depending on your problem, using "mapply" might help, as in the code
example below:
a = data.frame(matrix(1:3e4, ncol=3))
print(system.time({
r1 = numeric(nrow(a))
for(i in seq_len(nrow(a))) {
g = a[i,]
r1[i] = mean(c(g$X1, g$X2, g$X3))
}}))
print(system.time({
f = function(X1,
'format.pval' has a major limitation in its implementation for example
suppose a person had a vector like 'a' and the error being ±0.001.
> a <- c(0.1, 0.3, 0.4, 0.5, 0.3, 0.0001)
> format.pval(a, eps=0.001)
The person wants to have the 'format.pval' output with 2 digits always
showing l
Roger D. Peng wrote:
> Extracting rows from data frames is tricky, since each of the columns
> could be of a different class. For your toy example, it seems a matrix
> would be a more reasonable option.
There is no doubt about this ;-)
> mat <- matrix(rep(paste(letters, collapse=""), 5*30)
Here is an even faster one; the general point is to create a properly
vectorized custom function/expression:
mymean <- function(x, y, z) (x+y+z)/3
a = data.frame(matrix(1:3e4, ncol=3))
attach(a)
print(system.time({r3 = mymean(X1,X2,X3)}))
detach(a)
# Yields:
# [1] 0.000 0.010 0.005 0.000 0.000
Ulf Martin wrote:
> Here is an even faster one; the general point is to create a properly
> vectorized custom function/expression:
>
> mymean <- function(x, y, z) (x+y+z)/3
>
> a = data.frame(matrix(1:3e4, ncol=3))
> attach(a)
> print(system.time({r3 = mymean(X1,X2,X3)}))
> detach(a)
>
> # Yield
Hi Wolfgang,
Wolfgang Huber wrote:
>
> Hi Hervé
>
> depending on your problem, using "mapply" might help, as in the code
> example below:
>
> a = data.frame(matrix(1:3e4, ncol=3))
>
> print(system.time({
> r1 = numeric(nrow(a))
> for(i in seq_len(nrow(a))) {
> g = a[i,]
> r1[i] = mean(c(g
Hi Greg,
Greg Snow wrote:
> Your 2 examples have 2 differences and they are therefore confounded in
> their effects.
>
> What are your results for:
>
> system.time(for (i in 1:100) {row <- dat[i, ] })
>
>
>
Right. What you suggest is even faster (and more simple):
> mat <- matrix(rep(pas
Herve Pages <[EMAIL PROTECTED]> writes:
> So apparently here extracting with dat[i, ] is 300 times faster than
> extracting with dat[key, ] !
>
>> system.time(for (i in 1:100) dat["1", ])
>user system elapsed
> 12.680 0.396 13.075
>
>> system.time(for (i in 1:100) dat[1, ])
>user syst
17 matches
Mail list logo