Re: [R] bar chart with means - using ggplot

2009-09-12 Thread Dianne Cook

I would recommend not representing means by bars at all.

Bars are for counts, stacking from zero. Means are point estimates.  
ggplot has a lot of routines for displaying means with errors bars:  
geom_linerange, geom_pointrange. To hone your ggplot skills I  
recommend looking into these geoms.



On Sep 11, 2009, at 4:32 PM, Felipe Carrillo wrote:



Like this?

# example using qplot
library(ggplot2)
meanprice - tapply(diamonds$price, diamonds$cut, mean);meanprice
cut - factor(levels(diamonds$cut), levels = levels(diamonds$cut))
qplot(cut, meanprice, geom=bar, stat=identity, fill = I(grey50))
dev.new() # create a new graph to compare with qplot
# Example using ggplot
ggdata - data.frame(meanprice,cut);ggdata
ggplot(ggdata,aes(y=meanprice,x=cut)) +  
geom_bar(fill=grey50,stat='identity')


Felipe D. Carrillo
Supervisory Fishery Biologist
Department of the Interior
US Fish  Wildlife Service
California, USA


--- On Fri, 9/11/09, Andreas Christoffersen  
achristoffer...@gmail.com wrote:



From: Andreas Christoffersen achristoffer...@gmail.com
Subject: bar chart with means - using ggplot
To: ggplot2 ggpl...@googlegroups.com
Date: Friday, September 11, 2009, 1:50 PM

In the help pages hadley provides the following example
showing how to
achieve bar charts with y being means of a variable instead
of counts.
The example uses qplot however - and not ggplot. Since i
would like to
understand ggplot better I would really like to see how
this could be
done in ggplot.

# example using qplot
library(ggplot2)
meanprice - tapply(diamonds$price, diamonds$cut, mean)
cut - factor(levels(diamonds$cut), levels =
levels(diamonds$cut))
qplot(cut, meanprice, geom=bar, stat=identity, fill =
I(grey50))











--~--~-~--~~~---~--~~
You received this message because you are subscribed to the ggplot2  
mailing list.

To post to this group, send email to ggpl...@googlegroups.com
To unsubscribe from this group, send email to
ggplot2+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/ggplot2
-~--~~~~--~~--~--~---



---
Dianne Cook
dic...@iastate.edu

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] mclustBIC version 3.3.1

2009-09-12 Thread madmax1425

Hi there,
I started getting a new error with the latest mclust package version 3.3.1.
My only solution was to install the older package 3.2.1 or even 3.1-10. , (i
think older ones will still work since i ve been using it for a while)

the sentence giving trouble is:

BIC - mclustBIC(as.vector(data), G = 1:3, modelNames=c(E))

Quite often i get missing groups suggesting the data is not appropriate
for that clustering into 3 groups. I could not cast the results with NULL
values in order to continue my process.

Does anybody know anything about the new version of this function and how
its effectiveness got reduced so drastically? Its functionalities seem to
behave expanded handling noise etc etc as per changelog.

Any ideas or workaround?

Thanks a lot for the contribution in advance.

Max

-- 
View this message in context: 
http://www.nabble.com/mclustBIC-version-3.3.1-tp25411550p25411550.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] State Space models in R

2009-09-12 Thread Stephan Kolassa

Hi,

Rob Hyndman's forecast package does exponential smoothing forecasting 
based on state space models (and lots of other stuff, ARIMA et al.). 
It's not exactly the companion package to his book, but it comes close.


The book's (Forecasting with Exponential Smoothing - The State Space 
Approach) webpage is here:

http://www.exponentialsmoothing.net/

HTH,
Stephan



Giovanni Petris schrieb:

Hello everybody,

I am writing a review paper about State Space models in R, and I would
like to cover as many packages as I reasonably can. 


So far I am familiar with the following tools to deal with SS models:

* StructTS, Kalman* (in stats)
* packages dse[1-2] 
* package sspir

* package dlm

I would like to have some input from users who work with SS models:
are there any other packages for SS models that I am missing?, which
package do you use and why?, what do you think are advantages/
disadvantages of the package you use?

Of course I do have my own preferences (biased, of course) and
opinions about the different packages, but I would also like to
summarize in my paper the feedback I get from the R community.

Thank you in advance.

Best,
Giovanni Petris



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Completion for proto objects

2009-09-12 Thread Vitalie S.

On Fri, 11 Sep 2009 18:56:36 +0200, Gabor Grothendieck
ggrothendi...@gmail.com wrote:


in the devel version.  If that does not help let me know offline
and I will try to help you.


Thanks Gabor,
I solved the problem.
Here is the code in case somebody else wants to have full completions for  
proto objects:


# slightly modified utils:::specialCompletions
specialCompletions1 - function (text, spl)
{
wm - which.max(spl)
op - names(spl)[wm]
opStart - spl[wm]
opEnd - opStart + nchar(op)
if (opStart  1)
return(character(0L))
prefix - substr(text, 1L, opStart - 1L)
suffix - substr(text, opEnd, 100L)
if (op == ?)
return(helpCompletions(prefix, suffix))
if (opStart = 1)
return(character(0L))
tryToEval - function(s) {
try(eval(parse(text = s), envir = .GlobalEnv), silent = TRUE)
}
comps - switch(op, `$` = {
if (.CompletionEnv$settings[[ops]]) {
object - tryToEval(prefix)
if (inherits(object, try-error))
suffix
else {
if (!inherits(object, 'proto')  is.environment(object))  
{  ## this line is modified!!

ls(object, all.names = TRUE, pattern = sprintf(^%s,
 makeRegexpSafe(suffix)))
}
else {
grep(sprintf(^%s, makeRegexpSafe(suffix)),
 names(object), value = TRUE)
}
}
}
else suffix
}, `...@` = {
if (.CompletionEnv$settings[[ops]]) {
object - tryToEval(prefix)
if (inherits(object, try-error))
suffix
else {
grep(sprintf(^%s, makeRegexpSafe(suffix)),
 methods::slotNames(object), value = TRUE)
}
}
else suffix
}, `::` = {
if (.CompletionEnv$settings[[ns]]) {
nse - try(getNamespaceExports(prefix), silent = TRUE)
if (inherits(nse, try-error))
suffix
else {
grep(sprintf(^%s, makeRegexpSafe(suffix)),
 nse, value = TRUE)
}
}
else suffix
}, `:::` = {
if (.CompletionEnv$settings[[ns]]) {
ns - try(getNamespace(prefix), silent = TRUE)
if (inherits(ns, try-error))
suffix
else {
ls(ns, all.names = TRUE, pattern = sprintf(^%s,
 makeRegexpSafe(suffix)))
}
}
else suffix
}, `[` = , `[[` = {
comps - normalCompletions(suffix)
if (length(comps))
comps
else suffix
})
if (length(comps) == 0L)
comps - 
sprintf(%s%s%s, prefix, op, comps)
}

environment(specialCompletions1) - asNamespace(utils)
assignInNamespace(specialCompletions, specialCompletions1, utils)

## names for proto objects
names.proto - function(x){
.local - function(x){
if(inherits(x[[.super]], proto)) c(ls(x),  
Recall(x[[.super]]))

else ls(x)
}
unlist(.local(x))
}


## checks
tl - list(abc=afdas)
p1 - proto(p1_abc=123)
p2 - proto(.=p1, p2_abc=23423)

names(p2)
#[1] p2_abc p1_abc
names(p1)
#[1] p1_abc

Completion works fine.

Vitalie.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to visualize paired t-test results?

2009-09-12 Thread johannes rara
I would like to know if you have any suggestions how to visualize the
results from a paired t-test (see the example data below). I tried to
produce plots that show the mean and CI's from the original data and the
estimate of the difference between means and the confidence intervals (see
below) from the t-test. I really don't know what would be the best way to
graphically display the results. Thanks in advance.
 data ##
sam1 - c(51.7, 54.2, 53.3, 57, 56.4, 61.5, 57.2, 56.2, 58.4, 55.8)
sam2 - c(62.5, 65.2, 67.6, 69.9, 69.4, 70.1, 67.8, 67, 68.5, 62.4)
DF - stack(data.frame(sam1 = sam1, sam2 = sam2))

 paired-t-test ##

res - t.test(values ~ ind, data=DF, paired = TRUE)

 plots #
library(gregmisc)

opar - par(mfrow=c(1,2))
tapply(DF$values, list(DF$ind), ci)
plotmeans(values ~ ind, data=DF)

d - sam1 - sam2
stripchart(d, vertical=T, pch=16)
points(1, res$estimate, col=red, pch=16)
arrows(1, res$estimate, 1, res$conf.int[1], col=red, lwd=2, angle=90,
length=0.1)
arrows(1, res$estimate, 1, res$conf.int[2], col=red, lwd=2, angle=90,
length=0.1)

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] could not find function Varcov after upgrade of R?

2009-09-12 Thread zhu yao
After upgrading R to 2.9.2, I can't use the anova() fuction.
It says could not find function Varcov .
What's wrong with my computer? Help needed, thanks!

Yao Zhu
Department of Urology
Fudan University Shanghai Cancer Center
No. 270 Dongan Road, Shanghai, China

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] consistent results with heatmap.2

2009-09-12 Thread mkcheste
Hi,

I am trying to create a heatmap with some specific requirements.  Specifically, 
I need to be able to center the color-scale around 0, and I need to truncate 
the 
data so that a few extreme values do not cause the rest of the heatmap to 
appear 
black (on a red/green scale).

After reading through and experimenting with heatmap, heatmap.2, heatmap_plus, 
and heatmap_2, I believe heatmap.2 will provide the best solution - it appears 
to be the only option that will center around 0 without me manually adjusting 
the zlim.  In addition, the color key and distributional information is useful 
(at least for the non-truncated data).

Although I have not used truncated data at this point, I have so far been 
unable 
to produce consistent dendrograms when I'm not producing the dendrogram as part 
of the heatmap.  What am I missing?


###
R version 2.9.0 (2009-04-17)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

# The correct results
 hv - heatmap.2(x,
col=col.palette,
Colv=FALSE,
key=TRUE,
Rowv=cc1$order,
dendrogram=row,
scale=none,
tracecol=white,
cexCol=.5)

 hv$rowInd
 [1] 26 23  5 19 15  4  2 16 21 13 22 12 10 20  7  3 25  1  8 11 24  9 18 14 17
[26]  6

# Attempt 1
 cc = as.dendrogram(hclust(dist(x)))
 hv1 - heatmap.2(x,
col=col.palette,
Rowv=cc,
Colv=FALSE,
key=TRUE,
dendrogram=row,
scale=none,
tracecol=white,
cexCol=.5)
 hv1$rowInd
 [1]  5 23 26  1 25  8 11  9 24 18 14  6 17  2  4 16 21 13 22 12 10 20  3  7 15
[26] 19


# Attempt 2
 cutting - cutree(hclust(dist(x)),k=8) 
# I counted about 8 divisions in correct clustering
 hv2 - heatmap.2(x,
col=col.palette,
Rowv=cutting,
Colv=FALSE,
key=TRUE,
dendrogram=row,
scale=none,
tracecol=white,
cexCol=.5)
 hv2$rowInd
 [1]  5 23 26  1 25  8 11  9 24 18 14  6 17 15 19  2  4 16 21 13 22  3  7 12 10
[26] 20

# Attempt 3
 correct.order - hv$rowInd
 hv3 - heatmap.2(x,
col=col.palette,
Rowv=correct.order,
Colv=FALSE,
key=TRUE,
dendrogram=row,
scale=none,
tracecol=white,
cexCol=.5)
 hv3$rowInd
 [1]  5 26 23 15 19 22 13  7  3 12 20 10 16 21  4  2  8 11 25  1 24  9 18 14  6
[26] 17

My understanding is that my first attempt is the same call heatmap.2 makes - so 
there is no reason for the different results.

Note - if there is another way to create the heatmaps meeting my requirements 
using other packages, that works too - I just need something to produce 
consistent results.

Thanks!

Melissa Key
Graduate Student
Department of Statistics
Purdue University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] could not find function Varcov after upgrade of R?

2009-09-12 Thread zhu yao
I uses the Design library.

take this example:

library(Design)
n - 1000
set.seed(731)
age - 50 + 12*rnorm(n)
label(age) - Age
sex - factor(sample(c('Male','Female'), n,
  rep=TRUE, prob=c(.6, .4)))
cens - 15*runif(n)
h - .02*exp(.04*(age-50)+.8*(sex=='Female'))
dt - -log(runif(n))/h
label(dt) - 'Follow-up Time'
e - ifelse(dt = cens,1,0)
dt - pmin(dt, cens)
units(dt) - Year
dd - datadist(age, sex)
options(datadist='dd')
Srv - Surv(dt,e)

f - cph(Srv ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
cox.zph(f, rank) # tests of PH
anova(f)
# Error in anova.Design(f) : could not find function Varcov



Yao Zhu
Department of Urology
Fudan University Shanghai Cancer Center
No. 270 Dongan Road, Shanghai, China


2009/9/12 Ronggui Huang ronggui.hu...@gmail.com

 I cannot reproduce the problem you mentioned.

   ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
   trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group - gl(2,10,20, labels=c(Ctl,Trt))
weight - c(ctl, trt)
anova(lm.D9 - lm(weight ~ group))
  sessionInfo()
 R version 2.9.2 (2009-08-24)
 i386-pc-mingw32

 locale:
 LC_COLLATE=Chinese (Simplified)_People's Republic of
 China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
 China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
 China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_People's Republic
 of China.936

 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base

 2009/9/12 zhu yao mailzhu...@gmail.com:
  After upgrading R to 2.9.2, I can't use the anova() fuction.
  It says could not find function Varcov .
  What's wrong with my computer? Help needed, thanks!
 
  Yao Zhu
  Department of Urology
  Fudan University Shanghai Cancer Center
  No. 270 Dongan Road, Shanghai, China
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 HUANG Ronggui, Wincent
 Doctoral Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] could not find function Varcov after upgrade of R?

2009-09-12 Thread David Winsemius


On Sep 12, 2009, at 5:24 AM, zhu yao wrote:


After upgrading R to 2.9.2, I can't use the anova() fuction.
It says could not find function Varcov .
What's wrong with my computer? Help needed, thanks!


You have not given us very much information but from the naming  
conventions I would guess that you need to reinstall the Design/Hmisc  
combination of packages after having updated your R from an an earlier  
version of R that was different in the second digit. The libraries  
for the 2.9 series of R versions is stored in a different directory  
than the 2.8 or 2.7 versions. There is a simple command to the  
update.packages function that will reinstall updated versions of the  
packages you had previously installed. My practice, unnecessarily  
incremental, has been to reinstall each of the packages from scratch.


The automatic method would be:

update.packages()  # which will ask you to confirm eachnpackage

# or

update.packages(ask=FALSE) # which will not ask

--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Save data in txt

2009-09-12 Thread Lucas Sevilla García

Hi everyone

I have a little problem with R. I built a lineal regression equation using 
stepAIC function in both directions. Once I get this formula (lineal 
regression), I would like to save in a txt file data refered to p-value, 
r-squared, coefficients,...from the choosen model previously using stepAIC and 
p-value,r-squared, coefficients,...from each predictor. I try to use function 
Write to create a txt and save that data but I can't. So, Does anyone know a 
function to save specific data in a txt? I would like to save that specific 
data in separated columns, I mean, first column first predictor, second column 
p-value, third column r-squared, etc...

Refered to data from each predictor (p-value and r-squared), is there an order 
in R to obtain this data or I have to calculte them by myself? I know I can use 
r.squared but it gives me a value from the choosen model not from an specific 
predictor.

Cheers,

Lucas

_
[[elided Hotmail spam]]

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] could not find function Varcov after upgrade of R?

2009-09-12 Thread David Freedman

I've had the same problem with predict.Design, and have sent an email to the
maintainer of the Design package at Vanderbilt University.  I wasn't even
able to run the examples given on the help page of predict.Design - I
received the same error about Varcov that you did.  

I *think* it's a problem with the package, rather than R 2.9.2, and I hope
the problem will soon be fixed.  I was able to use predict.Design with 2.9.2
until I updated the Design package a few days ago.

david freedman


zhu yao wrote:
 
 I uses the Design library.
 
 take this example:
 
 library(Design)
 n - 1000
 set.seed(731)
 age - 50 + 12*rnorm(n)
 label(age) - Age
 sex - factor(sample(c('Male','Female'), n,
   rep=TRUE, prob=c(.6, .4)))
 cens - 15*runif(n)
 h - .02*exp(.04*(age-50)+.8*(sex=='Female'))
 dt - -log(runif(n))/h
 label(dt) - 'Follow-up Time'
 e - ifelse(dt = cens,1,0)
 dt - pmin(dt, cens)
 units(dt) - Year
 dd - datadist(age, sex)
 options(datadist='dd')
 Srv - Surv(dt,e)
 
 f - cph(Srv ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
 cox.zph(f, rank) # tests of PH
 anova(f)
 # Error in anova.Design(f) : could not find function Varcov
 
 
 
 Yao Zhu
 Department of Urology
 Fudan University Shanghai Cancer Center
 No. 270 Dongan Road, Shanghai, China
 
 
 2009/9/12 Ronggui Huang ronggui.hu...@gmail.com
 
 I cannot reproduce the problem you mentioned.

   ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
   trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group - gl(2,10,20, labels=c(Ctl,Trt))
weight - c(ctl, trt)
anova(lm.D9 - lm(weight ~ group))
  sessionInfo()
 R version 2.9.2 (2009-08-24)
 i386-pc-mingw32

 locale:
 LC_COLLATE=Chinese (Simplified)_People's Republic of
 China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
 China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
 China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_People's Republic
 of China.936

 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base

 2009/9/12 zhu yao mailzhu...@gmail.com:
  After upgrading R to 2.9.2, I can't use the anova() fuction.
  It says could not find function Varcov .
  What's wrong with my computer? Help needed, thanks!
 
  Yao Zhu
  Department of Urology
  Fudan University Shanghai Cancer Center
  No. 270 Dongan Road, Shanghai, China
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 HUANG Ronggui, Wincent
 Doctoral Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html

 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/could-not-find-function-%22Varcov%22-after-upgrade-of-R--tp25412881p25414017.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] could not find function Varcov after upgrade of R?

2009-09-12 Thread Carlos Alzola

Did you type library(Hmisc,T) before loading Design?

Carlos

--
From: David Freedman 3.14da...@gmail.com
Sent: Saturday, September 12, 2009 8:26 AM
To: r-help@r-project.org
Subject: Re: [R] could not find function Varcov after upgrade of R?



I've had the same problem with predict.Design, and have sent an email to 
the

maintainer of the Design package at Vanderbilt University.  I wasn't even
able to run the examples given on the help page of predict.Design - I
received the same error about Varcov that you did.

I *think* it's a problem with the package, rather than R 2.9.2, and I hope
the problem will soon be fixed.  I was able to use predict.Design with 
2.9.2

until I updated the Design package a few days ago.

david freedman


zhu yao wrote:


I uses the Design library.

take this example:

library(Design)
n - 1000
set.seed(731)
age - 50 + 12*rnorm(n)
label(age) - Age
sex - factor(sample(c('Male','Female'), n,
  rep=TRUE, prob=c(.6, .4)))
cens - 15*runif(n)
h - .02*exp(.04*(age-50)+.8*(sex=='Female'))
dt - -log(runif(n))/h
label(dt) - 'Follow-up Time'
e - ifelse(dt = cens,1,0)
dt - pmin(dt, cens)
units(dt) - Year
dd - datadist(age, sex)
options(datadist='dd')
Srv - Surv(dt,e)

f - cph(Srv ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
cox.zph(f, rank) # tests of PH
anova(f)
# Error in anova.Design(f) : could not find function Varcov



Yao Zhu
Department of Urology
Fudan University Shanghai Cancer Center
No. 270 Dongan Road, Shanghai, China


2009/9/12 Ronggui Huang ronggui.hu...@gmail.com


I cannot reproduce the problem you mentioned.

  ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
  trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
   group - gl(2,10,20, labels=c(Ctl,Trt))
   weight - c(ctl, trt)
   anova(lm.D9 - lm(weight ~ group))
 sessionInfo()
R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=Chinese (Simplified)_People's Republic of
China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_People's Republic
of China.936

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

2009/9/12 zhu yao mailzhu...@gmail.com:
 After upgrading R to 2.9.2, I can't use the anova() fuction.
 It says could not find function Varcov .
 What's wrong with my computer? Help needed, thanks!

 Yao Zhu
 Department of Urology
 Fudan University Shanghai Cancer Center
 No. 270 Dongan Road, Shanghai, China

[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




--
HUANG Ronggui, Wincent
Doctoral Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html



[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




--
View this message in context: 
http://www.nabble.com/could-not-find-function-%22Varcov%22-after-upgrade-of-R--tp25412881p25414017.html

Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] could not find function Varcov after upgrade of R?

2009-09-12 Thread David Winsemius
I am unable to reproduce that problem, either. Have both of you  
updated both the Design and Hmisc packages? Varcov is in Hmisc.


--
David Winsemius

On Sep 12, 2009, at 8:26 AM, David Freedman wrote:



I've had the same problem with predict.Design, and have sent an  
email to the
maintainer of the Design package at Vanderbilt University.  I wasn't  
even

able to run the examples given on the help page of predict.Design - I
received the same error about Varcov that you did.

I *think* it's a problem with the package, rather than R 2.9.2, and  
I hope
the problem will soon be fixed.  I was able to use predict.Design  
with 2.9.2

until I updated the Design package a few days ago.

david freedman


zhu yao wrote:


I uses the Design library.

take this example:

library(Design)
n - 1000
set.seed(731)
age - 50 + 12*rnorm(n)
label(age) - Age
sex - factor(sample(c('Male','Female'), n,
 rep=TRUE, prob=c(.6, .4)))
cens - 15*runif(n)
h - .02*exp(.04*(age-50)+.8*(sex=='Female'))
dt - -log(runif(n))/h
label(dt) - 'Follow-up Time'
e - ifelse(dt = cens,1,0)
dt - pmin(dt, cens)
units(dt) - Year
dd - datadist(age, sex)
options(datadist='dd')
Srv - Surv(dt,e)

f - cph(Srv ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
cox.zph(f, rank) # tests of PH
anova(f)
# Error in anova.Design(f) : could not find function Varcov



Yao Zhu
Department of Urology
Fudan University Shanghai Cancer Center
No. 270 Dongan Road, Shanghai, China


2009/9/12 Ronggui Huang ronggui.hu...@gmail.com


I cannot reproduce the problem you mentioned.


ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
 group - gl(2,10,20, labels=c(Ctl,Trt))
 weight - c(ctl, trt)
 anova(lm.D9 - lm(weight ~ group))
sessionInfo()

R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=Chinese (Simplified)_People's Republic of
China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_People's  
Republic

of China.936

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

2009/9/12 zhu yao mailzhu...@gmail.com:

After upgrading R to 2.9.2, I can't use the anova() fuction.
It says could not find function Varcov .
What's wrong with my computer? Help needed, thanks!

Yao Zhu
Department of Urology
Fudan University Shanghai Cancer Center
No. 270 Dongan Road, Shanghai, China


--
HUANG Ronggui, Wincent
Doctoral Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] could not find function Varcov after upgrade of R?

2009-09-12 Thread Frank E Harrell Jr
I apologize for this change in the Hmisc package which breaks the 
current version of Design in CRAN.  Design should be updated by early 
next week. In the meantime there are two solutions:


1. Install the rms package which is a replacement for Design with better 
graphics, and note the few changes you would need to make in your code 
as described in http://biostat.mc.vanderbilt.edu/Rrms (the main change 
is for plot(fit object)), or


2. Run source('http://biostat.mc.vanderbilt.edu/tmp/Varcov.r') to define 
the Varcov functions until Design is updated


Frank


David Freedman wrote:

I've had the same problem with predict.Design, and have sent an email to the
maintainer of the Design package at Vanderbilt University.  I wasn't even
able to run the examples given on the help page of predict.Design - I
received the same error about Varcov that you did.  


I *think* it's a problem with the package, rather than R 2.9.2, and I hope
the problem will soon be fixed.  I was able to use predict.Design with 2.9.2
until I updated the Design package a few days ago.

david freedman


zhu yao wrote:

I uses the Design library.

take this example:

library(Design)
n - 1000
set.seed(731)
age - 50 + 12*rnorm(n)
label(age) - Age
sex - factor(sample(c('Male','Female'), n,
  rep=TRUE, prob=c(.6, .4)))
cens - 15*runif(n)
h - .02*exp(.04*(age-50)+.8*(sex=='Female'))
dt - -log(runif(n))/h
label(dt) - 'Follow-up Time'
e - ifelse(dt = cens,1,0)
dt - pmin(dt, cens)
units(dt) - Year
dd - datadist(age, sex)
options(datadist='dd')
Srv - Surv(dt,e)

f - cph(Srv ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
cox.zph(f, rank) # tests of PH
anova(f)
# Error in anova.Design(f) : could not find function Varcov



Yao Zhu
Department of Urology
Fudan University Shanghai Cancer Center
No. 270 Dongan Road, Shanghai, China


2009/9/12 Ronggui Huang ronggui.hu...@gmail.com


I cannot reproduce the problem you mentioned.


 ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
 trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
  group - gl(2,10,20, labels=c(Ctl,Trt))
  weight - c(ctl, trt)
  anova(lm.D9 - lm(weight ~ group))
sessionInfo()

R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=Chinese (Simplified)_People's Republic of
China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_People's Republic
of China.936

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

2009/9/12 zhu yao mailzhu...@gmail.com:

After upgrading R to 2.9.2, I can't use the anova() fuction.
It says could not find function Varcov .
What's wrong with my computer? Help needed, thanks!

Yao Zhu
Department of Urology
Fudan University Shanghai Cancer Center
No. 270 Dongan Road, Shanghai, China

   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.




--
HUANG Ronggui, Wincent
Doctoral Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html



--
Frank E Harrell Jr   Professor and Chair   School of Medicine
 Department of Biostatistics   Vanderbilt University

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Save data in txt

2009-09-12 Thread David Winsemius


On Sep 12, 2009, at 7:56 AM, Lucas Sevilla García wrote:



Hi everyone

I have a little problem with R. I built a lineal regression equation  
using stepAIC function in both directions. Once I get this formula  
(lineal regression), I would like to save in a txt file data refered  
to p-value, r-squared, coefficients,...from the choosen model  
previously using stepAIC and p-value,r-squared, coefficients,...from  
each predictor. I try to use function Write to create a txt and  
save that data but I can't.


As I expected I get an error trying ?Write. Are you aware that  
complete case dependence for function names is enforced by R? Or are  
you using a package that has such a function but failed to tell us  
about that fact?




So, Does anyone know a function to save specific data in a txt?


?cat
?capture.output


I would like to save that specific data in separated columns, I  
mean, first column first predictor, second column p-value, third  
column r-squared, etc...


Refered to data from each predictor (p-value and r-squared), is  
there an order in R to obtain this data or I have to calculte them  
by myself?


A specific example would help here. You almost certainly do not need  
to calculate such information. They are probably available in either  
the model object itself or in the results of summary or aov.


I know I can use r.squared but it gives me a value from the choosen  
model not from an specific predictor.


If you can be more specific about what you are attempting to derive,  
it would be helpful. I suspect some sort of partial correlation  
coefficient but you are extremely vague in what you need.





Cheers,

Lucas

_
[[elided Hotmail spam]]

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] could not find function Varcov after upgrade of R?

2009-09-12 Thread Mark Difford

Hi Zhu,

 could not find function Varcov after upgrade of R?

Frank Harrell (author of Design) has noted in another thread that Hmisc has
changed... The problem is that functions like anova.Design call a function
in the _old_ Hmisc package called Varcov.default. In the new version of
Hmisc this is called something else (vcov.default).

The best way to fix this is to install the new (i.e. current) version of
Hmisc and Frank's replacement for his Design package, which is called rms
(Regression Modeling Strategies).

Regards, Mark.


zhu yao wrote:
 
 I uses the Design library.
 
 take this example:
 
 library(Design)
 n - 1000
 set.seed(731)
 age - 50 + 12*rnorm(n)
 label(age) - Age
 sex - factor(sample(c('Male','Female'), n,
   rep=TRUE, prob=c(.6, .4)))
 cens - 15*runif(n)
 h - .02*exp(.04*(age-50)+.8*(sex=='Female'))
 dt - -log(runif(n))/h
 label(dt) - 'Follow-up Time'
 e - ifelse(dt = cens,1,0)
 dt - pmin(dt, cens)
 units(dt) - Year
 dd - datadist(age, sex)
 options(datadist='dd')
 Srv - Surv(dt,e)
 
 f - cph(Srv ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
 cox.zph(f, rank) # tests of PH
 anova(f)
 # Error in anova.Design(f) : could not find function Varcov
 
 
 
 Yao Zhu
 Department of Urology
 Fudan University Shanghai Cancer Center
 No. 270 Dongan Road, Shanghai, China
 
 
 2009/9/12 Ronggui Huang ronggui.hu...@gmail.com
 
 I cannot reproduce the problem you mentioned.

   ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
   trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group - gl(2,10,20, labels=c(Ctl,Trt))
weight - c(ctl, trt)
anova(lm.D9 - lm(weight ~ group))
  sessionInfo()
 R version 2.9.2 (2009-08-24)
 i386-pc-mingw32

 locale:
 LC_COLLATE=Chinese (Simplified)_People's Republic of
 China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
 China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
 China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_People's Republic
 of China.936

 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base

 2009/9/12 zhu yao mailzhu...@gmail.com:
  After upgrading R to 2.9.2, I can't use the anova() fuction.
  It says could not find function Varcov .
  What's wrong with my computer? Help needed, thanks!
 
  Yao Zhu
  Department of Urology
  Fudan University Shanghai Cancer Center
  No. 270 Dongan Road, Shanghai, China
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 HUANG Ronggui, Wincent
 Doctoral Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html

 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/could-not-find-function-%22Varcov%22-after-upgrade-of-R--tp25412881p25414257.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Working with large matrix

2009-09-12 Thread Douglas Bates
On Fri, Sep 11, 2009 at 12:15 PM, A Ezhil ezhi...@yahoo.com wrote:
 Dear All,

 I have large matrix (46000 x 11250). I would like to do the linear regression 
 for each row. I wrote a simple function that has lm() and used 
 apply(mat,1,func). The issue is that it takes ages to load the file and also 
 to finish the lm. I am using LINUX 64 bit with 32G mem. Is there an elegant 
 and fast way of completing this task?

I'm not quite sure what you mean by do the linear regression for each
row but you may find it convenient to use a matrix as the response in
the call to lm.  In that case lm fits the same model, described by the
right hand side of the formula, to each column of the matrix on the
left hand side.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] SPSS Statistics-R Integration Plug-In

2009-09-12 Thread Muenchen, Robert A (Bob)
Hi Michael,

I've used the R plug-in and really like it. You can read my instructions
on how to install and use it by going to Amazon.com, searching for the
book, R for SAS and SPSS Users and then search inside the book for
the section, Running R from SPSS. I've only got about 3 pages on it
(28 bottom through 31), and Amazon will let you read them all. 

You do need to choose a specific version of R, but the old versions are
kept on CRAN, so they're easy to get. Version 18 of SPSS actually ships
with the version of R it needs on the SPSS DVD.

SPSS makes it really easy to transfer data and results back and forth,
and it formats the results nicely as SPSS pivot tables. I also have an
example of how to make an R program appear on the SPSS menus in R you
taking advantage of R?, an SPSS Directions 2009 talk. It's at:
http://RforSASandSPSSusers.com, right-hand side.

Cheers,
Bob

-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On Behalf Of Michael Chajewski
Sent: Tuesday, September 08, 2009 9:43 AM
To: r-help@r-project.org
Subject: [R] SPSS Statistics-R Integration Plug-In

Dear All,

Has anyone tried to use this plug-in? Since I am running R-2.9.1 it will
not even let me install it. Further, since I am running Windows I cannot
use the R provided R-2.7.0 Linux installation file from the archive
(tried to install it through cygwin and it was a mess). Suggestions?
Ideas? Has anybody used this plug-in?

Michael

--
Michael Chajewski, M.A.
Department of Psychology
Fordham University
Dealy Hall Room 239
441 East Fordham Road
Bronx, NY 10458
(718) 817-0654
http://www.chajewski.com

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Working with large matrix

2009-09-12 Thread Jonathan Baron
Another possible interpretation is that each row contains several
vectors, possibly laid end to end.  For example, if the row J were
length 30 (which it isn't), the first 10 might be Y, the next 10 X1,
and the next N2.  The function might be lm(J[1:10] ~ J[11:20] +
J[21:30]).

If this is what is going on, then one possible approach is to
transform this matrix into the long form, with one observation
(value of Y) and two predictors per row instead of (here) 10 values of
Y, then use lmList() in the lme4 package.  I suspect that this is
faster than using apply() with lm(), but I'm not sure.  I don't think
this will help load the file.

Jon

On 09/12/09 08:32, Douglas Bates wrote:
 On Fri, Sep 11, 2009 at 12:15 PM, A Ezhil ezhi...@yahoo.com wrote:
  Dear All,
 
  I have large matrix (46000 x 11250). I would like to do the linear 
  regression for 
 each row. I wrote a simple function that has lm() and used apply(mat,1,func). 
 The 
 issue is that it takes ages to load the file and also to finish the lm. I am 
 using 
 LINUX 64 bit with 32G mem. Is there an elegant and fast way of completing 
 this task?
 
 I'm not quite sure what you mean by do the linear regression for each
 row but you may find it convenient to use a matrix as the response in
 the call to lm.  In that case lm fits the same model, described by the
 right hand side of the formula, to each column of the matrix on the
 left hand side.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
Editor: Judgment and Decision Making (http://journal.sjdm.org)

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] mclustBIC version 3.3.1

2009-09-12 Thread Uwe Ligges



madmax1425 wrote:

Hi there,
I started getting a new error with the latest mclust package version 3.3.1.
My only solution was to install the older package 3.2.1 or even 3.1-10. , (i
think older ones will still work since i ve been using it for a while)

the sentence giving trouble is:

BIC - mclustBIC(as.vector(data), G = 1:3, modelNames=c(E))

Quite often i get missing groups suggesting the data is not appropriate
for that clustering into 3 groups. I could not cast the results with NULL
values in order to continue my process.

Does anybody know anything about the new version of this function and how
its effectiveness got reduced so drastically? Its functionalities seem to
behave expanded handling noise etc etc as per changelog.

Any ideas or workaround?

Thanks a lot for the contribution in advance.

Max




If you think there is a bug please mail to the package maintainer and 
report your findings.


Uwe Ligges

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] how to find maximum for multivariable data

2009-09-12 Thread caroline choong
Dear all,
I have a data set as follows:

 ID   cycle.number  cycle.result
1 2525  1   38
2 2525  2   38
3 2525  3   25
4 2525  4   25
5 2525  5   25
6 2525  6   25
7 2531  1   38
8 2531  2   38
9 2078  1   38
102078  2   38

I want to find out the maximum cycle.number for each ID, and later find the
corresponding cycle.result for that cycle.

I have already managed to pull out the maximum cycle by using a for loop:

max.cycle - vector()
patients - (levels(factor(ID)))
for (i in 1:length(patients)) {

max.cycle[i] - max(cycle.number[(ID %in% patients[i] )])

}

But i would like to know if there is a better or more elegant way of pulling
out the maximum cycle.number for each ID? Perhaps without the need for using
a for loop?

Many thanks,
Caroline

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot2::qplot() -- arbitary transformations of coordinate system?

2009-09-12 Thread hadley wickham
 Is there a place to find a list of the legal values for the coord_trans
 parameters. I spent a bunch of time searching the ggplot2 docs and r-help
 for same without success. I also made an attempt at looking at the code in R
 which also failed.

In the book, or with apropos(^Trans, ignore = F)

Hadley

-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to find maximum for multivariable data

2009-09-12 Thread Henrique Dallazuanna
Try this:

If cycle.number is ordered:

do.call(rbind, lapply(split(x, x$ID), tail, 1))


On Sat, Sep 12, 2009 at 12:36 PM, caroline choong carolinevcho...@gmail.com
 wrote:

 Dear all,
 I have a data set as follows:

 ID   cycle.number  cycle.result
 1 2525  1   38
 2 2525  2   38
 3 2525  3   25
 4 2525  4   25
 5 2525  5   25
 6 2525  6   25
 7 2531  1   38
 8 2531  2   38
 9 2078  1   38
 102078  2   38

 I want to find out the maximum cycle.number for each ID, and later find the
 corresponding cycle.result for that cycle.

 I have already managed to pull out the maximum cycle by using a for loop:

 max.cycle - vector()
 patients - (levels(factor(ID)))
 for (i in 1:length(patients)) {

 max.cycle[i] - max(cycle.number[(ID %in% patients[i] )])

 }

 But i would like to know if there is a better or more elegant way of
 pulling
 out the maximum cycle.number for each ID? Perhaps without the need for
 using
 a for loop?

 Many thanks,
 Caroline

[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to find maximum for multivariable data

2009-09-12 Thread David Winsemius


On Sep 12, 2009, at 11:36 AM, caroline choong wrote:


Dear all,
I have a data set as follows:

ID   cycle.number  cycle.result
1 2525  1   38
2 2525  2   38
3 2525  3   25
4 2525  4   25
5 2525  5   25
6 2525  6   25
7 2531  1   38
8 2531  2   38
9 2078  1   38
102078  2   38

I want to find out the maximum cycle.number for each ID, and later  
find the

corresponding cycle.result for that cycle.

I have already managed to pull out the maximum cycle by using a for  
loop:


max.cycle - vector()
patients - (levels(factor(ID)))
for (i in 1:length(patients)) {

max.cycle[i] - max(cycle.number[(ID %in% patients[i] )])

}

But i would like to know if there is a better or more elegant way of  
pulling

out the maximum cycle.number for each ID?


There is:

?tapply

 patients - read.table(textConnection(ID
cycle.number  cycle.result

+ 1 2525  1   38
+ 2 2525  2   38
+ 3 2525  3   25
+ 4 2525  4   25
+ 5 2525  5   25
+ 6 2525  6   25
+ 7 2531  1   38
+ 8 2531  2   38
+ 9 2078  1   38
+ 102078  2   38), header=TRUE)

 tapply(patients$cycle.number, patients$ID, max)
2078 2525 2531
   262



Perhaps without the need for using
a for loop?

Many thanks,



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] [R-pkgs] New package sos for searching help pages of contributed packages

2009-09-12 Thread spencerg
	  Searching help pages of contributed packages just got 
easier with the release of the new sos package. This is a 
replacement for and substantial enhancement of the existing 
RSiteSearch package.  To learn more about it, try 
vignette(sos). 



  We hope you find this as useful as we have.


  Spencer Graves, Sundar Dorai-Raj, Romain Francois

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Survreg function + deviation

2009-09-12 Thread Felipe
I am trying to estimate by MLE weibull coefficients and deviation. But how
can i estimate deviation? I tried to find at the list and at the internet
this but couldn't make it.  Anyone could help me on this?

Thanks.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] median() function on zoo objects

2009-09-12 Thread Marc Chiarini

Hello R-help community:

I have what I think is a simple question that I hope someone can 
answer.  When using the median() function on any zoo object (in 
particular, mine is an irregular time series), I get the following 
error, which is thrown from .gt():


Error in if (xi == xj) 0L else if (xi  xj) 1L else -1L :
 argument is of length zero

median() of course works fine on the coredata() of my zoo object, but 
not on the object itself.


Is the median.default function coded incorrectly for zoo objects?  If 
not, then I don't understand why functions like mean() and sd() work 
correctly on the same zoo object, but not median().  Am I asking the 
right questions?  Thanks for any help you can offer.


Regards,
Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] could not find function Varcov after upgrade of R?

2009-09-12 Thread David Freedman

Thanks for the reminder - actually I think I've become sloppy about the 'T'
(and the order of loading the Hmisc and Design packages), but that doesn't
seem to be the problem.  Also, all of my packages have been updated

david

Carlos Alzola wrote:
 
 Did you type library(Hmisc,T) before loading Design?
 
 Carlos
 
 --
 From: David Freedman 3.14da...@gmail.com
 Sent: Saturday, September 12, 2009 8:26 AM
 To: r-help@r-project.org
 Subject: Re: [R] could not find function Varcov after upgrade of R?
 

 I've had the same problem with predict.Design, and have sent an email to 
 the
 maintainer of the Design package at Vanderbilt University.  I wasn't even
 able to run the examples given on the help page of predict.Design - I
 received the same error about Varcov that you did.

 I *think* it's a problem with the package, rather than R 2.9.2, and I
 hope
 the problem will soon be fixed.  I was able to use predict.Design with 
 2.9.2
 until I updated the Design package a few days ago.

 david freedman


 zhu yao wrote:

 I uses the Design library.

 take this example:

 library(Design)
 n - 1000
 set.seed(731)
 age - 50 + 12*rnorm(n)
 label(age) - Age
 sex - factor(sample(c('Male','Female'), n,
   rep=TRUE, prob=c(.6, .4)))
 cens - 15*runif(n)
 h - .02*exp(.04*(age-50)+.8*(sex=='Female'))
 dt - -log(runif(n))/h
 label(dt) - 'Follow-up Time'
 e - ifelse(dt = cens,1,0)
 dt - pmin(dt, cens)
 units(dt) - Year
 dd - datadist(age, sex)
 options(datadist='dd')
 Srv - Surv(dt,e)

 f - cph(Srv ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
 cox.zph(f, rank) # tests of PH
 anova(f)
 # Error in anova.Design(f) : could not find function Varcov



 Yao Zhu
 Department of Urology
 Fudan University Shanghai Cancer Center
 No. 270 Dongan Road, Shanghai, China


 2009/9/12 Ronggui Huang ronggui.hu...@gmail.com

 I cannot reproduce the problem you mentioned.

   ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
   trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group - gl(2,10,20, labels=c(Ctl,Trt))
weight - c(ctl, trt)
anova(lm.D9 - lm(weight ~ group))
  sessionInfo()
 R version 2.9.2 (2009-08-24)
 i386-pc-mingw32

 locale:
 LC_COLLATE=Chinese (Simplified)_People's Republic of
 China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
 China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
 China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_People's Republic
 of China.936

 attached base packages:
 [1] stats graphics  grDevices utils datasets  methods   base

 2009/9/12 zhu yao mailzhu...@gmail.com:
  After upgrading R to 2.9.2, I can't use the anova() fuction.
  It says could not find function Varcov .
  What's wrong with my computer? Help needed, thanks!
 
  Yao Zhu
  Department of Urology
  Fudan University Shanghai Cancer Center
  No. 270 Dongan Road, Shanghai, China
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



 --
 HUANG Ronggui, Wincent
 Doctoral Candidate
 Dept of Public and Social Administration
 City University of Hong Kong
 Home page: http://asrr.r-forge.r-project.org/rghuang.html


 [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



 -- 
 View this message in context: 
 http://www.nabble.com/could-not-find-function-%22Varcov%22-after-upgrade-of-R--tp25412881p25414017.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/could-not-find-function-%22Varcov%22-after-upgrade-of-R--tp25412881p25416444.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to determine if a variable is already set?

2009-09-12 Thread carol white
Thanks for your replies.

I use the following script:

if(!exists(i)) stop (set the variable i, call. = FALSE)

but before the stop expression, Error gets displayed:

Error: set the variable i

Is there another function that stops the execution, prints an expression 
without printing Error or any other expression except the expression parameter?

Best,



--- On Fri, 9/11/09, Marc Schwartz marc_schwa...@me.com wrote:

From: Marc Schwartz marc_schwa...@me.com
Subject: Re: [R] how to determine if a variable is already set?
To: carol white wht_...@yahoo.com
Cc: r-h...@stat.math.ethz.ch
Date: Friday, September 11, 2009, 10:21 AM

On Sep 11, 2009, at 12:15 PM, carol white wrote:

 Hi,
 It might be a primitive question but how it is possible to determine if a 
 variable is initialized in an environment? Suppose that we start a R session 
 and wants to run a script which use the variable i. Which function could 
 evaluate if i is already initialized or not and if not, then ask 
 interactively the user to set it? This is to avoid the error message: object 
 i is not found.
 
 Regards,
 
 Carol


See ?exists

Note that this will tell you if the object exists, not if it contains a 
specifically desired initial value. You would have to check for the latter 
after determining that the object does indeed exist.

HTH,

Marc Schwartz




  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] median() function on zoo objects

2009-09-12 Thread Gabor Grothendieck
Can you provide a reproducible example.  See last line to every message
on r-help. When I try it it works:

 median(zoo(1:3))
2
2


On Sat, Sep 12, 2009 at 1:14 PM, Marc Chiarini marc.chiar...@tufts.edu wrote:
 Hello R-help community:

 I have what I think is a simple question that I hope someone can answer.
  When using the median() function on any zoo object (in particular, mine is
 an irregular time series), I get the following error, which is thrown from
 .gt():

 Error in if (xi == xj) 0L else if (xi  xj) 1L else -1L :
  argument is of length zero

 median() of course works fine on the coredata() of my zoo object, but not on
 the object itself.

 Is the median.default function coded incorrectly for zoo objects?  If not,
 then I don't understand why functions like mean() and sd() work correctly on
 the same zoo object, but not median().  Am I asking the right questions?
  Thanks for any help you can offer.

 Regards,
 Marc

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Triangular distribution for kernel regression

2009-09-12 Thread Bryan
Hello,

I am trying to get fitted/estimated values using kernel regression and a
triangular kernel.  I have found packages that easily fit values from a
kernel regression (e.g. ksmooth) but do not have a triangular distribution
option, and density estimators that have triangular distribution options
that I can't seem to use to produce estimated values (e.g. density).  Any
help is appreciated.

Bryan

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Triangular distribution for kernel regression

2009-09-12 Thread Gabor Grothendieck
Try:

RSiteSearch(kernel triangular)

On Sat, Sep 12, 2009 at 1:51 PM, Bryan thespamho...@gmail.com wrote:
 Hello,

 I am trying to get fitted/estimated values using kernel regression and a
 triangular kernel.  I have found packages that easily fit values from a
 kernel regression (e.g. ksmooth) but do not have a triangular distribution
 option, and density estimators that have triangular distribution options
 that I can't seem to use to produce estimated values (e.g. density).  Any
 help is appreciated.

 Bryan

        [[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] stack overflow when loading workspace

2009-09-12 Thread sebed1110-divers
Dear all,

I can't load my workspace of 25Mo on R version 2.9.2, because of a stack 
overflow. But I saved it normally (save.image()), and I didn't get any 
notification...
Does anyone know what that can be due to? Is there any limitation of number of 
objects (+/-63000)?

Thanks

Edwige Polus.



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] could not find function Varcov after upgrade of R?

2009-09-12 Thread Uwe Ligges



David Freedman wrote:

Thanks for the reminder - actually I think I've become sloppy about the 'T'
(and the order of loading the Hmisc and Design packages), but that doesn't
seem to be the problem.  Also, all of my packages have been updated



Note that Frank Harrell already answered that there is a Hmisc - Design 
issue which will be fixed early next week.


You had the unfortune to be too up to date and got the bug that was 
introduced very recently (and most people who answered had not so recent 
packages).


Uwe Ligges




david

Carlos Alzola wrote:

Did you type library(Hmisc,T) before loading Design?

Carlos

--
From: David Freedman 3.14da...@gmail.com
Sent: Saturday, September 12, 2009 8:26 AM
To: r-help@r-project.org
Subject: Re: [R] could not find function Varcov after upgrade of R?

I've had the same problem with predict.Design, and have sent an email to 
the

maintainer of the Design package at Vanderbilt University.  I wasn't even
able to run the examples given on the help page of predict.Design - I
received the same error about Varcov that you did.

I *think* it's a problem with the package, rather than R 2.9.2, and I
hope
the problem will soon be fixed.  I was able to use predict.Design with 
2.9.2

until I updated the Design package a few days ago.

david freedman


zhu yao wrote:

I uses the Design library.

take this example:

library(Design)
n - 1000
set.seed(731)
age - 50 + 12*rnorm(n)
label(age) - Age
sex - factor(sample(c('Male','Female'), n,
  rep=TRUE, prob=c(.6, .4)))
cens - 15*runif(n)
h - .02*exp(.04*(age-50)+.8*(sex=='Female'))
dt - -log(runif(n))/h
label(dt) - 'Follow-up Time'
e - ifelse(dt = cens,1,0)
dt - pmin(dt, cens)
units(dt) - Year
dd - datadist(age, sex)
options(datadist='dd')
Srv - Surv(dt,e)

f - cph(Srv ~ rcs(age,4) + sex, x=TRUE, y=TRUE)
cox.zph(f, rank) # tests of PH
anova(f)
# Error in anova.Design(f) : could not find function Varcov



Yao Zhu
Department of Urology
Fudan University Shanghai Cancer Center
No. 270 Dongan Road, Shanghai, China


2009/9/12 Ronggui Huang ronggui.hu...@gmail.com


I cannot reproduce the problem you mentioned.


 ctl - c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
 trt - c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
  group - gl(2,10,20, labels=c(Ctl,Trt))
  weight - c(ctl, trt)
  anova(lm.D9 - lm(weight ~ group))
sessionInfo()

R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=Chinese (Simplified)_People's Republic of
China.936;LC_CTYPE=Chinese (Simplified)_People's Republic of
China.936;LC_MONETARY=Chinese (Simplified)_People's Republic of
China.936;LC_NUMERIC=C;LC_TIME=Chinese (Simplified)_People's Republic
of China.936

attached base packages:
[1] stats graphics  grDevices utils datasets  methods   base

2009/9/12 zhu yao mailzhu...@gmail.com:

After upgrading R to 2.9.2, I can't use the anova() fuction.
It says could not find function Varcov .
What's wrong with my computer? Help needed, thanks!

Yao Zhu
Department of Urology
Fudan University Shanghai Cancer Center
No. 270 Dongan Road, Shanghai, China

   [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.




--
HUANG Ronggui, Wincent
Doctoral Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.html


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
View this message in context: 
http://www.nabble.com/could-not-find-function-%22Varcov%22-after-upgrade-of-R--tp25412881p25414017.html

Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.






__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] stack overflow when loading workspace

2009-09-12 Thread Uwe Ligges



sebed1110-div...@yahoo.fr wrote:

Dear all,

I can't load my workspace of 25Mo on R version 2.9.2, because of a stack 
overflow. But I saved it normally (save.image()), and I didn't get any 
notification...
Does anyone know what that can be due to? Is there any limitation of number of 
objects (+/-63000)?




At least, the error message would be helpful.

Uwe Ligges


Thanks

Edwige Polus.



  
	[[alternative HTML version deleted]]


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] median() function on zoo objects

2009-09-12 Thread Marc Chiarini
My apologies.  I don't know how it happened, but somehow the library 
must have been corrupted.  I re-installed the zoo package, and all was 
well again.  Thanks!

Regards,
Marc

Gabor Grothendieck wrote:
 Can you provide a reproducible example.  See last line to every message
 on r-help. When I try it it works:

   
 median(zoo(1:3))
 
 2
 2


 On Sat, Sep 12, 2009 at 1:14 PM, Marc Chiarini marc.chiar...@tufts.edu 
 wrote:
   
 Hello R-help community:

 I have what I think is a simple question that I hope someone can answer.
  When using the median() function on any zoo object (in particular, mine is
 an irregular time series), I get the following error, which is thrown from
 .gt():

 Error in if (xi == xj) 0L else if (xi  xj) 1L else -1L :
  argument is of length zero

 median() of course works fine on the coredata() of my zoo object, but not on
 the object itself.

 Is the median.default function coded incorrectly for zoo objects?  If not,
 then I don't understand why functions like mean() and sd() work correctly on
 the same zoo object, but not median().  Am I asking the right questions?
  Thanks for any help you can offer.

 Regards,
 Marc
 

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] ggplot2: deterministic position_jitter geom_line with position_jitter

2009-09-12 Thread Stephan Kolassa

Dear guRus,

I am starting to work with the ggplot2 package and have two very dumb 
questions:


1) deterministic position_jitter - the jittering is stochastic; is there 
any way to get a deterministic jittering? For instance:


example.data - 
data.frame(group=c(foo,bar,foo,bar,foo,bar),x=c(1,1,2,2,3,3),y=c(1,1,0,2,1,1))

set.seed(2009)
qplot(x,y,data=example.data,shape=group,position=position_jitter(w=0.1,h=0))

For x=1, the foo point is to the left of the bar point, and for x=3 the 
other way around. I would like to have all foo points at 
seq(1,3)-epsilon and all bar points at seq(1,3)+epsilon. Do I need to 
manually modify example.data$x groupwise for this?


2) geom_line with position_jitter - when I call multiple geoms with 
position_jitter, each geom gets its own jittering. For example 
(continuing with example.data above):


set.seed(2009)
qplot(x,y,data=example.data,geom=c(point,line),shape=group,position=position_jitter(w=0.1,h=0))

The lines do not connect the points - is there any way to have the 
geom_line connect all the foo points on the one hand and all the bar 
points on the other hand?


--

What I've done: searched through HW's book, googled, searched RSeek. For 
point 2) above, I tried using multiple layers and resetting the seed in 
between, to wit:


pp - ggplot(example.data,aes(x,y,shape=group))
set.seed(2009)
pp - pp+layer(geom=point,position=position_jitter(w=0.1,h=0))
set.seed(2009)
pp - pp+layer(geom=line,position=position_jitter(w=0.1,h=0))
print(pp)

This doesn't do what I want, either...

Why I'm doing this: example.data actually contains group means across a 
covariate x, and they need to be plotted as dots plus error bars 
(psychologists' convention), so use boxplots instead is a perfectly 
correct reply to my questions which unfortunately does not help me.


Thanks for your time!
Stephan

--

sessionInfo():

R version 2.9.2 (2009-08-24)
i386-pc-mingw32

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
 [1] grid  grDevices datasets  splines   graphics  stats tcltk 
utils methods   base


other attached packages:
 [1] ggplot2_0.8.3   reshape_0.8.3   plyr_0.1.9  proto_0.3-8 
svSocket_0.9-43 svMisc_0.9-48   TinnR_1.0.3 R2HTML_1.59-1 
Hmisc_3.7-0

[10] survival_2.35-4

loaded via a namespace (and not attached):
[1] cluster_1.12.0  lattice_0.17-25 tools_2.9.2

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ggplot2: deterministic position_jitter geom_line with position_jitter

2009-09-12 Thread hadley wickham
On Sat, Sep 12, 2009 at 1:34 PM, Stephan Kolassa stephan.kola...@gmx.de wrote:
 Dear guRus,

 I am starting to work with the ggplot2 package and have two very dumb
 questions:

 1) deterministic position_jitter - the jittering is stochastic; is there any
 way to get a deterministic jittering? For instance:

 example.data -
 data.frame(group=c(foo,bar,foo,bar,foo,bar),x=c(1,1,2,2,3,3),y=c(1,1,0,2,1,1))
 set.seed(2009)
 qplot(x,y,data=example.data,shape=group,position=position_jitter(w=0.1,h=0))

 For x=1, the foo point is to the left of the bar point, and for x=3 the
 other way around. I would like to have all foo points at seq(1,3)-epsilon
 and all bar points at seq(1,3)+epsilon. Do I need to manually modify
 example.data$x groupwise for this?

Yes.  The plyr package generally makes this sort of manipulation pain free.

 2) geom_line with position_jitter - when I call multiple geoms with
 position_jitter, each geom gets its own jittering. For example (continuing
 with example.data above):

 set.seed(2009)
 qplot(x,y,data=example.data,geom=c(point,line),shape=group,position=position_jitter(w=0.1,h=0))

 The lines do not connect the points - is there any way to have the geom_line
 connect all the foo points on the one hand and all the bar points on the
 other hand?

Again, you'll have to adding the jittering yourself.

 --

 What I've done: searched through HW's book, googled, searched RSeek. For
 point 2) above, I tried using multiple layers and resetting the seed in
 between, to wit:

 pp - ggplot(example.data,aes(x,y,shape=group))
 set.seed(2009)
 pp - pp+layer(geom=point,position=position_jitter(w=0.1,h=0))
 set.seed(2009)
 pp - pp+layer(geom=line,position=position_jitter(w=0.1,h=0))
 print(pp)

 This doesn't do what I want, either...

The jittering isn't evaluated until render time, so this won't help.
You'll notice if you draw the plot again, you'll get a different
rendering.

Hadley

-- 
http://had.co.nz/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to visualize paired t-test results?

2009-09-12 Thread Tal Galili
Hello johannes,

You're example looks nice and I am hoping to see more ideas from other
members.

Just one tiny idea:

In -
stripchart
Also use ylim to include the ZERO line (and then actually add the line) like
this:

plot.ylim - c(min(d, 0), max(d, 0))
abline(h = 0, lty = 2, col = blue, lwd =2)

stripchart(d, vertical=T, pch=16, ylim = plot.ylim )


This way you get to show how far you got the difference to be from the zero
(otherwise, all the graph gives is the variance, without any useful
knowledge of the distance of the differences from the zero)

Also, consider using this function for CI plotting:
http://finzi.psych.upenn.edu/R/library/plotrix/html/plotCI.html


Best,
Tal Galili








On Sat, Sep 12, 2009 at 12:00 PM, johannes rara johannesr...@gmail.comwrote:

 I would like to know if you have any suggestions how to visualize the
 results from a paired t-test (see the example data below). I tried to
 produce plots that show the mean and CI's from the original data and the
 estimate of the difference between means and the confidence intervals (see
 below) from the t-test. I really don't know what would be the best way to
 graphically display the results. Thanks in advance.
  data ##
 sam1 - c(51.7, 54.2, 53.3, 57, 56.4, 61.5, 57.2, 56.2, 58.4, 55.8)
 sam2 - c(62.5, 65.2, 67.6, 69.9, 69.4, 70.1, 67.8, 67, 68.5, 62.4)
 DF - stack(data.frame(sam1 = sam1, sam2 = sam2))

  paired-t-test ##

 res - t.test(values ~ ind, data=DF, paired = TRUE)

  plots #
 library(gregmisc)

 opar - par(mfrow=c(1,2))
 tapply(DF$values, list(DF$ind), ci)
 plotmeans(values ~ ind, data=DF)

 d - sam1 - sam2
 stripchart(d, vertical=T, pch=16)
 points(1, res$estimate, col=red, pch=16)
 arrows(1, res$estimate, 1, res$conf.int[1], col=red, lwd=2, angle=90,
 length=0.1)
 arrows(1, res$estimate, 1, res$conf.int[2], col=red, lwd=2, angle=90,
 length=0.1)

[[alternative HTML version deleted]]

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
http://www.r-statistics.com/
http://www.talgalili.com
http://www.biostatistics.co.il

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Triangular distribution for kernel regression

2009-09-12 Thread Bryan
Gabor,

Thanks for your quick reply (on a weekend even!)  I've looked through the
results of the search you recommended, and several related searches, and
don't see anything exceptionally helpful.  Kernel regression is a relatively
new analysis for me; I apologize for needing a little more direction.

I've understand that it is connected to local polynomial regression but I
can't seem to have any success from that direction either. At this point the
only package that is giving smoothed estimates as I would expect is ksmooth
- which doesn't include the appropriate distribution.

Best,
Bryan


On Sat, Sep 12, 2009 at 1:55 PM, Gabor Grothendieck ggrothendi...@gmail.com
 wrote:

 Try:

 RSiteSearch(kernel triangular)

 On Sat, Sep 12, 2009 at 1:51 PM, Bryan thespamho...@gmail.com wrote:
  Hello,
 
  I am trying to get fitted/estimated values using kernel regression and a
  triangular kernel.  I have found packages that easily fit values from a
  kernel regression (e.g. ksmooth) but do not have a triangular
 distribution
  option, and density estimators that have triangular distribution options
  that I can't seem to use to produce estimated values (e.g. density).  Any
  help is appreciated.
 
  Bryan
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] R on Multi Core

2009-09-12 Thread Tal Galili
Also have a look at the foreach package:
http://finzi.psych.upenn.edu/R/library/foreach/html/foreach-package.html








On Fri, Sep 11, 2009 at 11:05 PM, Noah Silverman n...@smartmediacorp.comwrote:

 Hi,

 Our discussions about 64 bit R has led me to another thought.

 I have a nice dual core 3.0 chip inside my Linux Box  (Running Fedora 11.)

 Is there a version of R that would take advantage of BOTH cores??
 (Watching my system performance meter now is interesting, Running R will
 hold a single core at 100% perfectly, but the other core sites idle.)

 Thanks!

 --
 Noah

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
--


My contact information:
Tal Galili
Phone number: 972-50-3373767
FaceBook: Tal Galili
My Blogs:
http://www.r-statistics.com/
http://www.talgalili.com
http://www.biostatistics.co.il

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Triangular distribution for kernel regression

2009-09-12 Thread Gabor Grothendieck
What about kknn -- that was listed as having the triangular distribution?


On Sat, Sep 12, 2009 at 3:42 PM, Bryan thespamho...@gmail.com wrote:
 Gabor,

 Thanks for your quick reply (on a weekend even!)  I've looked through the
 results of the search you recommended, and several related searches, and
 don't see anything exceptionally helpful.  Kernel regression is a relatively
 new analysis for me; I apologize for needing a little more direction.

 I've understand that it is connected to local polynomial regression but I
 can't seem to have any success from that direction either. At this point the
 only package that is giving smoothed estimates as I would expect is ksmooth
 - which doesn't include the appropriate distribution.

 Best,
 Bryan


 On Sat, Sep 12, 2009 at 1:55 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:

 Try:

 RSiteSearch(kernel triangular)

 On Sat, Sep 12, 2009 at 1:51 PM, Bryan thespamho...@gmail.com wrote:
  Hello,
 
  I am trying to get fitted/estimated values using kernel regression and a
  triangular kernel.  I have found packages that easily fit values from a
  kernel regression (e.g. ksmooth) but do not have a triangular
  distribution
  option, and density estimators that have triangular distribution options
  that I can't seem to use to produce estimated values (e.g. density).
   Any
  help is appreciated.
 
  Bryan
 
         [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] medcouple-based outlier detection in R

2009-09-12 Thread Manuj Sharma
I need to detect outliers in a large data set which is highly right-skewed. I 
plan to use medcouple-based outlier detection. Is there any support for 
medcouple-based outlier detection in R? Are there any other routines in R to 
perform outlier detection in highly right-skewed data?

Manuj Sharma



  See the Web#39;s breaking stories, chosen by people like you. Check out 
Yahoo! Buzz. http://in.buzz.yahoo.com/
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] medcouple-based outlier detection in R

2009-09-12 Thread David Winsemius


On Sep 12, 2009, at 3:54 PM, Manuj Sharma wrote:

I need to detect outliers in a large data set which is highly right- 
skewed. I plan to use medcouple-based outlier detection. Is there  
any support for medcouple-based outlier detection in R?


library(sos)  # a package that links to Baron's r-search
???medcouple

7 hits in 2 different packages (robustbase and LambertW)
So I would guess that the answer is yes.

Are there any other routines in R to perform outlier detection in  
highly right-skewed data?


Yes. Suggest you look over the Robust Statistics Task View.



Manuj Sharma

 See the Web#39;s breaking stories, chosen by people like you.  
Check out Yahoo! Buzz. http://in.buzz.yahoo.com/

[[alternative HTML version deleted]]


David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Triangular distribution for kernel regression

2009-09-12 Thread Mark Difford

Hi Brian,

 I am trying to get fitted/estimated values using kernel regression and a 
 triangular kernel.

Look at Loader's locfit package. You are likely to be pleasantly surprised.

Regards, Mark.


Bryan-65 wrote:
 
 Hello,
 
 I am trying to get fitted/estimated values using kernel regression and a
 triangular kernel.  I have found packages that easily fit values from a
 kernel regression (e.g. ksmooth) but do not have a triangular distribution
 option, and density estimators that have triangular distribution options
 that I can't seem to use to produce estimated values (e.g. density).  Any
 help is appreciated.
 
 Bryan
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Triangular-distribution-for-kernel-regression-tp25416706p25417878.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Re : stack overflow when loading workspace

2009-09-12 Thread sebed1110-divers
Hi,

the error message is Error: protect(): protection stack overflow

Edwige.






 Dear all,
 
 I can't load my workspace of 25Mo on R version 2.9.2, because of 
But I saved it normally (save.image()), and I didn't get any notification...
 Does anyone know what that can be due to? Is there any limitation of number 
 of objects (+/-63000)?



At least, the error message would be helpful.

Uwe Ligges

 Thanks
 
 Edwige Polus.
 
 
 
   [[alternative HTML version deleted]]
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Best Subset Selection - Leaps Package

2009-09-12 Thread Lars Bishop
Dear Experts,

I'm a new R user and I'll appreciate your help regarding the following. I'm
trying to generate an exhaustive search of all candidate models in a simple
linear regression and select the one with the lowest CV-error (or
alternatively the lowest Error on a Test set -- if I have lots of data). The
leaps package can generate this exhaustive search but all models are
evaluated on the train data (without cross-validation). How can I implement
what I'm trying to achieve?  Any guidance will help...


library(ElemStatLearn) #Follow the example of Page 58 in Elements of Stat
Learning Book

train - subset(prostate, train==TRUE )[,1:9]
test - subset(prostate, train=FALSE )[,1:9]

#Best subset selection
library(leaps)
prostate.leaps - regsubsets( lpsa ~ . , data=train, nbest=100, nvmax=8,
method=exhaustive, really.big=T)
prostate.leaps.sum - summary(prostate.leaps)
prostate.models - prostate.leaps.sum$which
prostate.models
prostate.models.rss - prostate.leaps.sum$rss
prostate.models.rss
prostate.models.size - as.numeric(attr(prostate.models, dimnames)[[1]])
prostate.models.best.rss -tapply(prostate.models.rss, prostate.models.size,
min)
prostate.models.best.rss

Thanks a lot!

Lars.

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Triangular distribution for kernel regression

2009-09-12 Thread Bryan
I originally looked over kknn because I need to be able to specify a
bandwidth parameter.  I am trying to replicate some previous non-R work in
R, so I can't stray to far from the procedure used there.  In reading the
paper referenced in the docs, I see that kknn can reduce to the
Nadaraya–Watson estimator, which is where I need to be, but I'm not sure how
to manipulate the bandwidth, as would be possible in other methods.  Can you
clarify this at all?

Bryan







On Sat, Sep 12, 2009 at 3:46 PM, Gabor Grothendieck ggrothendi...@gmail.com
 wrote:

 What about kknn -- that was listed as having the triangular distribution?


 On Sat, Sep 12, 2009 at 3:42 PM, Bryan thespamho...@gmail.com wrote:
  Gabor,
 
  Thanks for your quick reply (on a weekend even!)  I've looked through the
  results of the search you recommended, and several related searches, and
  don't see anything exceptionally helpful.  Kernel regression is a
 relatively
  new analysis for me; I apologize for needing a little more direction.
 
  I've understand that it is connected to local polynomial regression but I
  can't seem to have any success from that direction either. At this point
 the
  only package that is giving smoothed estimates as I would expect is
 ksmooth
  - which doesn't include the appropriate distribution.
 
  Best,
  Bryan
 
 
  On Sat, Sep 12, 2009 at 1:55 PM, Gabor Grothendieck
  ggrothendi...@gmail.com wrote:
 
  Try:
 
  RSiteSearch(kernel triangular)
 
  On Sat, Sep 12, 2009 at 1:51 PM, Bryan thespamho...@gmail.com wrote:
   Hello,
  
   I am trying to get fitted/estimated values using kernel regression and
 a
   triangular kernel.  I have found packages that easily fit values from
 a
   kernel regression (e.g. ksmooth) but do not have a triangular
   distribution
   option, and density estimators that have triangular distribution
 options
   that I can't seem to use to produce estimated values (e.g. density).
Any
   help is appreciated.
  
   Bryan
  
  [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 
 


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Triangular distribution for kernel regression

2009-09-12 Thread Gabor Grothendieck
You can specify the number of nearest neighbors.

On Sat, Sep 12, 2009 at 5:16 PM, Bryan thespamho...@gmail.com wrote:
 I originally looked over kknn because I need to be able to specify a
 bandwidth parameter.  I am trying to replicate some previous non-R work in
 R, so I can't stray to far from the procedure used there.  In reading the
 paper referenced in the docs, I see that kknn can reduce to the
 Nadaraya–Watson estimator, which is where I need to be, but I'm not sure how
 to manipulate the bandwidth, as would be possible in other methods.  Can you
 clarify this at all?

 Bryan







 On Sat, Sep 12, 2009 at 3:46 PM, Gabor Grothendieck
 ggrothendi...@gmail.com wrote:

 What about kknn -- that was listed as having the triangular distribution?


 On Sat, Sep 12, 2009 at 3:42 PM, Bryan thespamho...@gmail.com wrote:
  Gabor,
 
  Thanks for your quick reply (on a weekend even!)  I've looked through
  the
  results of the search you recommended, and several related searches, and
  don't see anything exceptionally helpful.  Kernel regression is a
  relatively
  new analysis for me; I apologize for needing a little more direction.
 
  I've understand that it is connected to local polynomial regression but
  I
  can't seem to have any success from that direction either. At this point
  the
  only package that is giving smoothed estimates as I would expect is
  ksmooth
  - which doesn't include the appropriate distribution.
 
  Best,
  Bryan
 
 
  On Sat, Sep 12, 2009 at 1:55 PM, Gabor Grothendieck
  ggrothendi...@gmail.com wrote:
 
  Try:
 
  RSiteSearch(kernel triangular)
 
  On Sat, Sep 12, 2009 at 1:51 PM, Bryan thespamho...@gmail.com wrote:
   Hello,
  
   I am trying to get fitted/estimated values using kernel regression
   and a
   triangular kernel.  I have found packages that easily fit values from
   a
   kernel regression (e.g. ksmooth) but do not have a triangular
   distribution
   option, and density estimators that have triangular distribution
   options
   that I can't seem to use to produce estimated values (e.g. density).
    Any
   help is appreciated.
  
   Bryan
  
          [[alternative HTML version deleted]]
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
 
 



__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re : stack overflow when loading workspace

2009-09-12 Thread Duncan Murdoch

On 12/09/2009 5:04 PM, sebed1110-div...@yahoo.fr wrote:

Hi,

the error message is Error: protect(): protection stack overflow


63000 objects is far more than most people would use, so you may have 
hit an internal limit.  The protection stack is used internally by R 
to temporarily mark objects as in use even if they haven't been 
assigned anywhere; overflows usually signal a bug in some code.  By 
default, it is limited to 5 entries, and it's very rare that any 
code would generate more than that number of temporary objects. 
However, if you have 63000 objects, it's conceivable that they are all 
protected at some point during loading.


The easiest way to fix this may be not to produce so many objects.  I 
suspect that they aren't all meaningful to you, you probably produced 
them automatically.  So why not store them within a list, or some other 
structure?  That's the normal way to program in R.


If you can't do that, you may be able to read your file by recompiling R 
with a larger stack limit.  The line to change is in src/include/Defn.h 
around line 214, currently


#define R_PPSSIZE   5L

Change that to a larger number and you might get lucky.

Duncan Murdoch



Edwige.







Dear all,

I can't load my workspace of 25Mo on R version 2.9.2, because of 

But I saved it normally (save.image()), and I didn't get any notification...

Does anyone know what that can be due to? Is there any limitation of number of 
objects (+/-63000)?




At least, the error message would be helpful.

Uwe Ligges


Thanks

Edwige Polus.



  [[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




  
	[[alternative HTML version deleted]]


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] (no subject)

2009-09-12 Thread KABELI MEFANE
Dear All
 
I hope you can help me with this small problem. I want to draw a normal 
distribution line to this data: 
p-rnorm(100, mean=5, sd=3000)
hist(p)
 
Kabeli


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to determine if a variable is already set?

2009-09-12 Thread Don MacQueen

Do watch out, however, for *where* i exits.

That is, if you type search() you will see a list of environments in 
which i might be found. You're probably assuming that i, if 
exists(i) is true, is in .GlobalEnv, but it might be in one of the 
other environments, in which case exists('i') will be TRUE, but it 
won't be the i you are looking for.


I believe you need to quote then name also
   use:exits('i')
   not:exists(i)

See  ?exists (again)

-Don


At 10:19 AM -0700 9/12/09, carol white wrote:

Thanks for your replies.

I use the following script:

if(!exists(i)) stop (set the variable i, call. = FALSE)

but before the stop expression, Error gets displayed:

Error: set the variable i

Is there another function that stops the execution, prints an 
expression without printing Error or any other expression except the 
expression parameter?


Best,



--- On Fri, 9/11/09, Marc Schwartz marc_schwa...@me.com wrote:

From: Marc Schwartz marc_schwa...@me.com
Subject: Re: [R] how to determine if a variable is already set?
To: carol white wht_...@yahoo.com
Cc: r-h...@stat.math.ethz.ch
Date: Friday, September 11, 2009, 10:21 AM

On Sep 11, 2009, at 12:15 PM, carol white wrote:


 Hi,
 It might be a primitive question but how it is possible to 
determine if a variable is initialized in an environment? Suppose 
that we start a R session and wants to run a script which use the 
variable i. Which function could evaluate if i is already 
initialized or not and if not, then ask interactively the user to 
set it? This is to avoid the error message: object i is not found.


 Regards,

 Carol



See ?exists

Note that this will tell you if the object exists, not if it 
contains a specifically desired initial value. You would have to 
check for the latter after determining that the object does indeed 
exist.


HTH,

Marc Schwartz




 
	[[alternative HTML version deleted]]


__
R-help@r-project.org mailing list
https://*stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://*www.*R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
--
Don MacQueen
Environmental Protection Department
Lawrence Livermore National Laboratory
Livermore, CA, USA
925-423-1062

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Normal distribution

2009-09-12 Thread KABELI MEFANE
 Dear All 
 
let me go one step further by asking you if you could help me show that the 
distribution of this data in normal.  have a little idea (by trial and 
error) but i seem to not fully understand how its done.
 
H-rnorm(100, mean=5, sd=3000)
par(las=1)
hist(H, breaks=seq(4, 6, 1000), freq=F)
f- function(x) exp(-(x-5000)^2/1800)/sqrt(1800*pi) 
x- seq(4, 6, 1000)
lines(x,f(x))
 
The code works when  its like this:
 
H-rnorm(100, mean=5000, sd=1000)
par(las=1)
hist(H, breaks=seq(2000, 8000, 100), freq=F)
f- function(x) exp(-(x-5000)^2/200)/sqrt(200*pi) 
x- seq(2000, 8000, 50)
lines(x,f(x))
 
Please tell me or advice of an easier or understandable code

 

 


  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] (no subject)

2009-09-12 Thread David Freedman

A better subject for your question might have been helpful.  There are many
options for hist and truehist in the MASS package, but this might help:

x=rnorm(100, mean=5, sd=3000)
hist(x, prob=T)
x2=density(x)
lines(x2$x,x2$y)


KABELI MEFANE wrote:
 
 Dear All
  
 I hope you can help me with this small problem. I want to draw a normal
 distribution line to this data: 
 p-rnorm(100, mean=5, sd=3000)
 hist(p)
  
 Kabeli
 
 
   
   [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/%28no-subject%29-tp25418417p25418513.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] (no subject)

2009-09-12 Thread KABELI MEFANE
Thank you Sir
 
I have been trying to come up with the code for 6 hours thats why i ended up 
forgetting the title.
 
Kabeli

--- On Sat, 12/9/09, David Freedman 3.14da...@gmail.com wrote:


From: David Freedman 3.14da...@gmail.com
Subject: Re: [R] (no subject)
To: r-help@r-project.org
Date: Saturday, 12 September, 2009, 10:49 PM



A better subject for your question might have been helpful.  There are many
options for hist and truehist in the MASS package, but this might help:

x=rnorm(100, mean=5, sd=3000)
hist(x, prob=T)
x2=density(x)
lines(x2$x,x2$y)


KABELI MEFANE wrote:
 
 Dear All
  
 I hope you can help me with this small problem. I want to draw a normal
 distribution line to this data: 
 p-rnorm(100, mean=5, sd=3000)
 hist(p)
  
 Kabeli
 
 
       
     [[alternative HTML version deleted]]
 
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/%28no-subject%29-tp25418417p25418513.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Normal distribution

2009-09-12 Thread jim holtman
Why don't you just do this:

H-rnorm(100, mean=5, sd=3000)
par(las=1)
hist(H, breaks=seq(4, 6, 1000), freq=F)
f- function(x) exp(-(x-5000)^2/1800)/sqrt(1800*pi)
x- seq(4, 6, 100)
lines(x, dnorm(x, 5, 3000))



On Sat, Sep 12, 2009 at 5:47 PM, KABELI MEFANEkabelimef...@yahoo.co.uk wrote:
  Dear All

 let me go one step further by asking you if you could help me show that the 
 distribution of this data in normal.  have a little idea (by trial and 
 error) but i seem to not fully understand how its done.

 H-rnorm(100, mean=5, sd=3000)
 par(las=1)
 hist(H, breaks=seq(4, 6, 1000), freq=F)
 f- function(x) exp(-(x-5000)^2/1800)/sqrt(1800*pi)
 x- seq(4, 6, 1000)
 lines(x,f(x))

 The code works when  its like this:

 H-rnorm(100, mean=5000, sd=1000)
 par(las=1)
 hist(H, breaks=seq(2000, 8000, 100), freq=F)
 f- function(x) exp(-(x-5000)^2/200)/sqrt(200*pi)
 x- seq(2000, 8000, 50)
 lines(x,f(x))

 Please tell me or advice of an easier or understandable code







        [[alternative HTML version deleted]]


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.





-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Normal distribution

2009-09-12 Thread KABELI MEFANE

Thank You 
 
It really works fine and i do understand it. Now i can sleep, its 0200 hours 
here.

Why don't you just do this:

H-rnorm(100, mean=5, sd=3000)
par(las=1)
hist(H, breaks=seq(4, 6, 1000), freq=F)
f- function(x) exp(-(x-5000)^2/1800)/sqrt(1800*pi)
x- seq(4, 6, 100)
lines(x, dnorm(x, 5, 3000))



On Sat, Sep 12, 2009 at 5:47 PM, KABELI MEFANEkabelimef...@yahoo.co.uk wrote:
  Dear All

 let me go one step further by asking you if you could help me show that the 
 distribution of this data in normal.  have a little idea (by trial and 
 error) but i seem to not fully understand how its done.

 H-rnorm(100, mean=5, sd=3000)
 par(las=1)
 hist(H, breaks=seq(4, 6, 1000), freq=F)
 f- function(x) exp(-(x-5000)^2/1800)/sqrt(1800*pi)
 x- seq(4, 6, 1000)
 lines(x,f(x))

 The code works when  its like this:

 H-rnorm(100, mean=5000, sd=1000)
 par(las=1)
 hist(H, breaks=seq(2000, 8000, 100), freq=F)
 f- function(x) exp(-(x-5000)^2/200)/sqrt(200*pi)
 x- seq(2000, 8000, 50)
 lines(x,f(x))

 Please tell me or advice of an easier or understandable code







        [[alternative HTML version deleted]]


 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.





-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?



  
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] the integer of a given location

2009-09-12 Thread darkhorn

I have a huge number such as 78923698701
z-78923698701
I want to find the integer of a given location, for example here, what is
the 2nd number? 8.

Thanks in advance!
-- 
View this message in context: 
http://www.nabble.com/the-integer-of-a-given-location-tp25418729p25418729.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] the integer of a given location

2009-09-12 Thread jim holtman
Is this what you want:

 z-78923698701
 substring(as.character(z), 2, 2)
[1] 8



On Sat, Sep 12, 2009 at 6:16 PM, darkhorn darkh...@gmail.com wrote:

 I have a huge number such as 78923698701
 z-78923698701
 I want to find the integer of a given location, for example here, what is
 the 2nd number? 8.

 Thanks in advance!
 --
 View this message in context: 
 http://www.nabble.com/the-integer-of-a-given-location-tp25418729p25418729.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] the integer of a given location

2009-09-12 Thread Jorge Ivan Velez
Hi darkhorn,
Here are two suggestions:

# Suggestion 1
z - 78923698701
foo - function(x, pos) strsplit(as.character(x),)[[1]][pos]
foo(z,2)
# [1] 8

# Suggestion 2
foo2 - function(x, pos) substr(x,pos,pos)
foo2(z,2)
# [1] 8

See ?strsplit and ?substr for more details.

HTH,
Jorge

On Sat, Sep 12, 2009 at 6:16 PM, darkhorn darkh...@gmail.com wrote:


 I have a huge number such as 78923698701
 z-78923698701
 I want to find the integer of a given location, for example here, what is
 the 2nd number? 8.

 Thanks in advance!
 --
 View this message in context:
 http://www.nabble.com/the-integer-of-a-given-location-tp25418729p25418729.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] the integer of a given location

2009-09-12 Thread darkhorn

Thank you very much. :-)

 as.integer(substring(as.character(z), 2, 2))
[1] 8

 as.integer(foo2(z,2))
[1] 8
-- 
View this message in context: 
http://www.nabble.com/the-integer-of-a-given-location-tp25418729p25419555.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Barplot+Table

2009-09-12 Thread gunksta



Marc Schwartz-3 wrote:
 
 Using the data that is in the online plot rather than the above, here  
 is a first go. Note that I am not drawing the background grid in the  
 barplot or the lines for table below it. These could be added if you  
 really need them.
 
 snip
 
 HTH,
 
 Marc Schwartz
 

Wow. That looks absolutely amazing. I really can't thank you enough. This
not only gives me the layout for what I am trying to do, it gives me a much
better understanding of how the graphcs systems in R fit together.

-- 
View this message in context: 
http://www.nabble.com/Barplot%2BTable-tp25406046p25419738.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Manage an unknown and variable number of data frames

2009-09-12 Thread Mark Knecht
Hi,
   In the code below I create a small data.frame (dat) and then cut it
into different groups using CutList. The lists in CutList allow to me
choose whatever columns I want from dat and allow me to cut it into
any number of groups by changing the lists. It seems to work OK but
when I'm done I have a variable number of data frames what I need to
do further operations on and I don't know how to manage them as a
collection.

   How do experience R coders handle keeping all this straight so that
if I add another column from dat and more groups in the cuts it all
stays straight? I need to send each dataf rame to another function to
add columns of specific data calcuations to each of them.

   Best for me (I think) would be to enumerate each data frame using
the row.name number from CutTable if possible, but that's just my
thought. If each data frame became an element of CutTable then I'd
always know where they are. Really I'm needing to get a handle on
keeping a variable and unknown number of these things straight.

Thanks,
Mark






dat = data.frame(
a=round(runif(100,-20,30),2),
b=round(runif(100,-40,50),2)
)

# Give each cut list a name matching the column in dat that you
# want to use as criteria for making the cut.
# Create any number of cuts in each row.

CutList = list(
a=c(-Inf,-10,10,Inf),
b=c(-Inf,0,20,Inf)
)

CutResults = mapply(cut,x=dat[,names(CutList)],CutList,SIMPLIFY=FALSE)
CutTable = as.data.frame(table(CutResults))

CutResultsDF = as.data.frame(CutResults)
head(CutResultsDF, n=15)

dat$aRange = CutResultsDF$a
dat$bRange = CutResultsDF$b
head(dat, 15)


# I don't want to do the following as it doesn't
# get managed automatically.

Subset1 = subset(subset(dat, aRange==CutTable$a[1]), bRange==CutTable$b[1])[1:2]
Subset2 = subset(subset(dat, aRange==CutTable$a[2]), bRange==CutTable$b[2])[1:2]
Subset3 = subset(subset(dat, aRange==CutTable$a[3]), bRange==CutTable$b[3])[1:2]
Subset4 = subset(subset(dat, aRange==CutTable$a[4]), bRange==CutTable$b[4])[1:2]

Subset1
Subset2
Subset3
Subset4

CutTable

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] zoo plot: yearly marks on X-Axis

2009-09-12 Thread lanczos
On Sun, 2009-07-26 at 13:17 +0200, Poersching wrote:
 stvienna wiener schrieb:
  Hi all,
 
  I am plotting a financial time series, but I need a more detailed X-Axis.
 
  Example:
  x - zoo(rnorm(1:6000), as.Date(1992-11-11)+c(1:6000))
  plot(x)
 
  The X-Axis is labeled 1995, 2000 and 2005.
  I would need either 1995, 1997, etc. or maybe yearly
 
 
  I used google first, then look at ?plot.zoo but could't get it working.
 
 
  Regards,
  Steve
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 Hey,

 try something like the following:

 plot(x, y, xaxt=n)
 axis.Date(1, at=seq(as.Date(1960-01-01), max(as.Date(x)), years),
 labels = FALSE, tcl = -0.2)
 axis.Date(1, at=seq(as.Date(1960-01-01), max(as.Date(x)), 5 years),
 labels = TRUE, las=3, tcl = -0.2)

 Regards,
 Christian

Hello,

I'm actually struggling with the similar problem. I applied Your script
into mine like this:
-
library(Rdbi)
library(RdbiPgSQL)
conn - dbConnect(PgSQL(), host=localhost, dbname=BVS,
user=postgres, password = **)

query_duj_kal - dbSendQuery(conn, select zdroj as well, cas as date,
fe2, fe3, mn, nh4, no2, no3, o2, teplota as temperature from analystats
where zdroj like 'Dunaj Kalinkovo' order by date)
watchem_duj_kal - dbGetResult(query_duj_kal)

date - (watchem_duj_kal$date)
date_p - strptime(date, %m-%d-%Y)
no3 - (watchem_duj_kal$no3)
nh4 - (watchem_duj_kal$nh4)

par(mfrow=c(3,1), ylog = TRUE, yaxp = c(0.01, 100, 3))
maxy - 100
miny - 0.005
plot(date_p, no3,log = y, type = l, ylim  = c(miny, maxy), col =
darkred, main = Dunaj Kalinkovo, xlab = time, ylab = log(NO3-,NH4
+), xaxt=n)
axis.Date(1, at=seq(as.Date(1972-01-01),max(as.Date(date_p))),
years), labels = FALSE, tcl = -0.2)
axis.Date(1, at=seq(as.Date(1970-01-01),max(as.Date(date_p))),
5 years), labels = TRUE, las=3, tcl = -0.2)
-

Everything goes well, except that I cannot get no tickles nor labels at
the moment and I cannot find what I did wrong.

Many thanks for any advice

Tomas

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] zoo plot: yearly marks on X-Axis

2009-09-12 Thread Gabor Grothendieck
Try this:

library(zoo)
x - zoo(rnorm(1:6000), as.Date(1992-11-11)+c(1:6000))
plot(x, xaxt = n)
# cut time into years, remove duplicate years and convert back to Date
yy - as.Date(unique(cut(time(x), year)))
axis(1, yy, format(yy, %y))

There are a number of examples of custom X axes in the
examples section of ?plot.zoo

On Sat, Sep 12, 2009 at 10:33 PM,  lanc...@fns.uniba.sk wrote:
 On Sun, 2009-07-26 at 13:17 +0200, Poersching wrote:
 stvienna wiener schrieb:
  Hi all,
 
  I am plotting a financial time series, but I need a more detailed X-Axis.
 
  Example:
  x - zoo(rnorm(1:6000), as.Date(1992-11-11)+c(1:6000))
  plot(x)
 
  The X-Axis is labeled 1995, 2000 and 2005.
  I would need either 1995, 1997, etc. or maybe yearly
 
 
  I used google first, then look at ?plot.zoo but could't get it working.
 
 
  Regards,
  Steve
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 Hey,

 try something like the following:

 plot(x, y, xaxt=n)
 axis.Date(1, at=seq(as.Date(1960-01-01), max(as.Date(x)), years),
 labels = FALSE, tcl = -0.2)
 axis.Date(1, at=seq(as.Date(1960-01-01), max(as.Date(x)), 5 years),
 labels = TRUE, las=3, tcl = -0.2)

 Regards,
 Christian

 Hello,

 I'm actually struggling with the similar problem. I applied Your script
 into mine like this:
 -
 library(Rdbi)
 library(RdbiPgSQL)
 conn - dbConnect(PgSQL(), host=localhost, dbname=BVS,
 user=postgres, password = **)

 query_duj_kal - dbSendQuery(conn, select zdroj as well, cas as date,
 fe2, fe3, mn, nh4, no2, no3, o2, teplota as temperature from analystats
 where zdroj like 'Dunaj Kalinkovo' order by date)
 watchem_duj_kal - dbGetResult(query_duj_kal)

 date - (watchem_duj_kal$date)
 date_p - strptime(date, %m-%d-%Y)
 no3 - (watchem_duj_kal$no3)
 nh4 - (watchem_duj_kal$nh4)

 par(mfrow=c(3,1), ylog = TRUE, yaxp = c(0.01, 100, 3))
 maxy - 100
 miny - 0.005
 plot(date_p, no3,log = y, type = l, ylim  = c(miny, maxy), col =
 darkred, main = Dunaj Kalinkovo, xlab = time, ylab = log(NO3-,NH4
 +), xaxt=n)
 axis.Date(1, at=seq(as.Date(1972-01-01),max(as.Date(date_p))),
 years), labels = FALSE, tcl = -0.2)
 axis.Date(1, at=seq(as.Date(1970-01-01),max(as.Date(date_p))),
 5 years), labels = TRUE, las=3, tcl = -0.2)
 -

 Everything goes well, except that I cannot get no tickles nor labels at
 the moment and I cannot find what I did wrong.

 Many thanks for any advice

 Tomas

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Manage an unknown and variable number of data frames

2009-09-12 Thread David Winsemius


On Sep 12, 2009, at 10:13 PM, Mark Knecht wrote:


Hi,
  In the code below I create a small data.frame (dat) and then cut it
into different groups using CutList. The lists in CutList allow to me
choose whatever columns I want from dat and allow me to cut it into
any number of groups by changing the lists. It seems to work OK but
when I'm done I have a variable number of data frames what I need to
do further operations on and I don't know how to manage them as a
collection.


List processing.



  How do experience R coders handle keeping all this straight so that
if I add another column from dat and more groups in the cuts it all
stays straight? I need to send each dataf rame to another function to
add columns of specific data calcuations to each of them.

  Best for me (I think) would be to enumerate each data frame using
the row.name number from CutTable if possible, but that's just my
thought. If each data frame became an element of CutTable then I'd
always know where they are. Really I'm needing to get a handle on
keeping a variable and unknown number of these things straight.

Thanks,
Mark

dat = data.frame(
a=round(runif(100,-20,30),2),
b=round(runif(100,-40,50),2)
)

# Give each cut list a name matching the column in dat that you
# want to use as criteria for making the cut.
# Create any number of cuts in each row.

CutList = list(
a=c(-Inf,-10,10,Inf),
b=c(-Inf,0,20,Inf)
)

CutResults = mapply(cut,x=dat[,names(CutList)],CutList,SIMPLIFY=FALSE)
CutTable = as.data.frame(table(CutResults))

CutResultsDF = as.data.frame(CutResults)
head(CutResultsDF, n=15)

dat$aRange = CutResultsDF$a
dat$bRange = CutResultsDF$b
head(dat, 15)


You could have gotten the same labeling of columns into categories  
with a combination of ave and cut.


 dat$arng2 - ave(dat$a, FUN=function(x) cut(x, breaks=CutList$a) )
 dat
 a  b aRangebRange arng2
1   -10.45  43.30 (-Inf,-10] (20, Inf] 1
2 9.09 -33.66   (-10,10]  (-Inf,0] 2
329.27  18.34  (10, Inf](0,20] 3
428.92  46.55  (10, Inf] (20, Inf] 3
5 2.07  -8.23   (-10,10]  (-Inf,0] 2
618.28 -35.13  (10, Inf]  (-Inf,0] 3
7   -16.26  40.59 (-Inf,-10] (20, Inf] 1
snip





# I don't want to do the following as it doesn't
# get managed automatically.



It is possibly unclear what you are hoping to accomplish with that  
subset(subset(.)) construction. Are you trying to accomplish what a  
logical conjunction for subset= , coupled with a select= parameter  
would do inside a single subset?


 subset(dat, aRange==CutTable$a[1]  bRange==CutTable$b[1],  
select=c(a,b) )

a  b
26 -17.50 -18.46
28 -15.48 -34.37
31 -10.04 -21.55
38 -11.73 -29.40
46 -18.28 -17.42
95 -11.62 -22.94
96 -12.16  -1.57
97 -15.44 -19.89


Subset1 = subset(subset(dat, ,
Subset2 = subset(subset(dat, aRange==CutTable$a[2]), bRange==CutTable 
$b[2])[1:2]
Subset3 = subset(subset(dat, aRange==CutTable$a[3]), bRange==CutTable 
$b[3])[1:2]
Subset4 = subset(subset(dat, aRange==CutTable$a[4]), bRange==CutTable 
$b[4])[1:2]


You could automate that with
 work.list - lapply(1:4, function(x) subset(dat, aRange==CutTable 
$a[x]  bRange==CutTable$b[x], select=c(a,b)  )  )

 work.list[[1]]  # first element of a 4 element list
a  b
26 -17.50 -18.46
28 -15.48 -34.37
31 -10.04 -21.55
38 -11.73 -29.40
46 -18.28 -17.42
95 -11.62 -22.94
96 -12.16  -1.57
97 -15.44 -19.89



Subset1
Subset2
Subset3
Subset4

CutTable



David Winsemius, MD
Heritage Laboratories
West Hartford, CT

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re : stack overflow when loading workspace

2009-09-12 Thread Prof Brian Ripley

There is a command-line flag for this:

tystie% R --help
...
  --max-ppsize=NSet max size of protect stack to N

so you do not need to re-compile. It is not uncommon to need more 
space to load objects than to save them, and the need to raise this 
limit to re-load a worskpace has come up before on R-help (it is why 
there is a command-line flag).


The PP stack is not the only stack that can overflow; it is not even 
the commonest one.  So we could not have guessed without the error 
message, and if you raise this limit you may hit others.


I don't think 63000 objects is large, but 63000 named objects would
be.  Remember that each character string etc is an object (see
memory.profile() for a real count).


On Sat, 12 Sep 2009, Duncan Murdoch wrote:


On 12/09/2009 5:04 PM, sebed1110-div...@yahoo.fr wrote:

Hi,

the error message is Error: protect(): protection stack overflow


63000 objects is far more than most people would use, so you may have hit an 
internal limit.  The protection stack is used internally by R to 
temporarily mark objects as in use even if they haven't been assigned 
anywhere; overflows usually signal a bug in some code.  By default, it is 
limited to 5 entries, and it's very rare that any code would generate 
more than that number of temporary objects. However, if you have 63000 
objects, it's conceivable that they are all protected at some point during 
loading.


The easiest way to fix this may be not to produce so many objects.  I suspect 
that they aren't all meaningful to you, you probably produced them 
automatically.  So why not store them within a list, or some other structure? 
That's the normal way to program in R.


If you can't do that, you may be able to read your file by recompiling R with 
a larger stack limit.  The line to change is in src/include/Defn.h around 
line 214, currently


#define R_PPSSIZE   5L

Change that to a larger number and you might get lucky.

Duncan Murdoch




Edwige.



Dear all,

I can't load my workspace of 25Mo on R version 2.9.2, because of 
But I saved it normally (save.image()), and I didn't get any 
notification...
Does anyone know what that can be due to? Is there any limitation of 
number of objects (+/-63000)?


At least, the error message would be helpful.

Uwe Ligges


Thanks

Edwige Polus.


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.