Re: [R] pvals.fnc in lme4 and languageR

2008-10-02 Thread Dieter Menne
Daniela Reicheneder  tz.agrar.tu-muenchen.de> writes:

> I was using the function pvals.fnc from package 'languageR' until April. 
> I do not know which version. Yesterday I updated all my packages
> and tried to run my loop again. Now I get the following error message:
> 
> error in pvals.fnc(mm, nsim = 1000) :
> MCMC sampling is not yet implemented in lme4_0.999375-27
> for models with random correlation parameters
> 

Does the example coming with pvals.fnc still run for you? 

Dieter

__
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] An AIC model selection question

2008-10-02 Thread Christoph Scherber

Dear R users,

Assume I have three models with the following AIC values:

model   AIC df
model1  -10 2
model2  -12 5
model3  -11 2

Obviously, model2 would be preferred, but it "wastes" 5 df compared to the 
other models.

Would it be allowed to select model3 instead, simply because it uses up less df and the delta-AIC 
between model2 and model3 is just 1?


Many thanks for any suggestions/comments!
Best wishes
Christoph





--
Dr. rer.nat. Christoph Scherber
University of Goettingen
DNPW, Agroecology
Waldweg 26
D-37073 Goettingen
Germany

phone +49 (0)551 39 8807
fax   +49 (0)551 39 8806

Homepage http://www.gwdg.de/~cscherb1

__
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] Multiple hist(ograms) - One plot

2008-10-02 Thread ONKELINX, Thierry
Dear Michael,

Try ggplot2. Use something like

install.packages("ggplot2")
library(ggplot2)
recov <- 0:2
n <- 1000
all <- data.frame(bbED = rnorm(3 * n, mean = recov), recov =
factor(rep(recov, n)))
ggplot(data = all, aes(x = bbED)) + geom_histogram() + facet_grid(. ~
recov)
ggplot(data = all, aes(x = bbED)) + geom_histogram() + facet_grid(recov
~ .)
ggplot(data = all, aes(x = bbED, colour = recov)) + geom_density()

You'll find more information on ggplot2 at http://had.co.nz/ggplot2/

HTH,

Thierry



ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Michael Just
Verzonden: donderdag 2 oktober 2008 7:29
Aan: r-help@r-project.org
Onderwerp: [R] Multiple hist(ograms) - One plot

Hello,
I am trying to plot multiple histograms with the same scales, etc into
one
plot. The commands below produce a 3 page PDF with each histogram
occupying
the upper right quadrant. And use slightly different scales on the X and
Y
axes.

> s21 <- dat[dat$sc_recov=="21",]
> s21.ED <- subset(s21, select=(bbED))
> s31 <- all[all$sc_recov=="31",]
> s31.ED <- subset(s31, select=(bbED))
> s41 <- all[all$sc_recov=="41",]
> s41.ED <- subset(s41, select=(bbED))
> pdf("234_1_ED.pdf")
> par(mfrow = c(2, 2), oma = c(0, 0, 2, 0))
> hist(s21.ED) + hist(s31.ED) + hist(s41.ED)
> dev.off()

Also, for example if I add something like col="x", or main="x" to the
hist(x, ...) nothing appears on the plot.  ?

Please advise,
Thank you kindly,
M Just

[[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.

Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer 
en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is
door een geldig ondertekend document. The views expressed in  this message 
and any annex are purely those of the writer and may not be regarded as stating 
an official position of INBO, as long as the message is not confirmed by a duly 
signed document.

__
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] question about working with workspaces

2008-10-02 Thread Patrick Burns

Duncan Murdoch wrote:

Daniel Rabczenko wrote:

Hello everybody,

Two - I hope Simple questions about working with workspaces.

Is there a way to force R to start in "clean" workspace / avoid 
"previously

saved workspace restored"?
  


Start with --no-restore.  (Start with --help for the full list of 
command line options.)



When I load workspace"2" working in workspace"1" everything from "1" is
written into "2" is there a way to avoid it?
 


If I understand the question correctly, then the
answer is to use 'attach' rather than 'load'.  'load'
puts everything in the file into the global environment.
'attach' creates a new item in the search list containing
the objects in the file.

Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")


Nothing is written into 2 until you save the workspace. I think you 
mean loading one workspace doesn't delete existing items.  That's 
true.  You can use the rm() function first to delete the things you 
don't want to keep.   Use rm(list=ls(all=TRUE)) to do that --- but use 
it carefully, it's irreversible.


Duncan Murdoch

__
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] An AIC model selection question

2008-10-02 Thread Uwe Ligges



Christoph Scherber wrote:

Dear R users,

Assume I have three models with the following AIC values:

modelAICdf
model1 -102
model2-125
model3-112

Obviously, model2 would be preferred, but it "wastes" 5 df compared to 
the other models.


Would it be allowed to select model3 instead, simply because it uses up 
less df and the delta-AIC between model2 and model3 is just 1?


Well, on the one hand, the degrees of freedom are already part of the 
AIC calculation. So if you say you really want to apply model selection 
based on AIC, the answer is `no'.
On the other hand, AIC is just one possible way to penalize the 
Likelihood values by the used number of degrees of freedom. You can 
choose some different criterion, if you think the amount of penalization 
in AIC is too weak for you.


Best,
Uwe Ligges



Many thanks for any suggestions/comments!
Best wishes
Christoph







__
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] Error: cannot allocate vector of size 117.3 Mb

2008-10-02 Thread Uwe Ligges



ram basnet wrote:

Dear R users,
 
I am using RandomForest package. While using this package, i got 
"Error: cannot allocate vector of size 117.3 Mb" .message.

I had this problem earlier too but could not manage. Is there any way to solve 
this problem or to increase vector size ? My data set is of 163 samples and 
5546 variables.
I tried through "? Memory" function to solve this problem, still could not 
manage. I am hopeful to get solution from this R-help forum.
Thanks in advance.


So what did you do exactly? What kind of data are your variables? 
Factors (how many levels), numerical values? And what are the parameters 
of your hardware?


Uwe Ligges

 
Regards,

Ram Kumar Basnet.


  
	[[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] Bug or feature with finding a list element?

2008-10-02 Thread Patrick Burns

I think you will find that this follows the partial
matching rules:

* exact match
* unique partial match
* take evasive action if non-unique partial match

Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

B Fox wrote:

This seems odd.  When I try to look up a list element which has a space in
the name using just the first word (i.e. no spaces), it will sometimes
return the element with a space in the name and sometimes it will return
NULL.

Try this:

alist <- list( 'hello'=10, bye=20, 'hello world'=30, 'goodbye world'=40, 'hi
world'=50, 'goodbye foo'=60, 'goodbye bar'=70)
Then try fetching some list elements:
  

alist[['goodbye']]


NULL
  

alist[['hi']]


[1] 50
  

alist[['hello']]


[1] 10
With "goodbye" there were a couple list elements with spaces in the name, so
it didn't return any of them.

With "hi" there was one (and only one) element which had "hi" as the first
word: "hi world"

With "hello" there was an actual element named "hello"

This seems messed up and non-intuitive to say the least.

I am doing this on R version 2.5.0 (2007-04-23) compiled on a itanium64
and I also tried it on R version 2.5.1 (2007-06-27) on an pentium 4 ubuntu
linux

[[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] lapply where each list object has multiple parts

2008-10-02 Thread Patrick Burns

The function in 'lapply' gets each component, so
write a function that does what you want given a
component of the list:

lapply(BigList, function(x) mean(x$label1))

Patrick Burns
[EMAIL PROTECTED]
+44 (0)20 8525 0696
http://www.burns-stat.com
(home of S Poetry and "A Guide for the Unwilling S User")

eric lee wrote:

Hi.  I have a list where each object in the list has multiple parts.  I'd
like to take the mean of just one part of each object.  Is it possible to do
this with lapply?  If not, can you recommend another function?  Thanks.

eric

  

x1 <- c(0,1,2,3)
x2 <- c(7,8)
x3 <- c(2,6,6,8)
x4 <- c(4,8)

Lst1 <- list(label1 = x1,label2 = x2)
Lst2 <- list(label1 = x3, label2 = x4)

BigList <- list(Lst1, Lst2)

lapply(BigList$label1, mean)


list()
  


[[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] Hexagon border in plotrix's math2D.plot

2008-10-02 Thread john
Hi there,

I'm attempting to use 

color2D.matplot(x,cellcolors=cellcol, do.hex=TRUE)

from the plotrix package, but do not want to have borders around the hexagons. 
I've tried various approaches such as
 fg="white", col="white", lty=0, lwd=0 and border=NULL/FALSE/"white", but none 
of them works.

I'd appreciate any ideas.

Thanks,
John
-- 
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196

__
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] contingency table, several variables from dataframe

2008-10-02 Thread Birgitle

Hello R-Users!

I need a little help to build up a contingency table out of several
variables.

  A<-c("F","M","M","F","F","F","F","M","F","M","F","F")
  B<-c(0,0,0,0,0,0,1,1,1,1,0,1)
  C<-c(0,1,1,1,1,1,1,1,1,0,0,0)

  ABC<-as.data.frame(cbind(A,B,C))

  ABC

   A B C
1  F 0 0
2  M 0 1
3  M 0 1
4  F 0 1
5  F 0 1
6  F 0 1
7  F 1 1
8  M 1 1
9  F 1 1
10 M 1 0
11 F 0 0
12 F 1 0

I would like to count in each variable B and C the frequencies for M and F
(variable A) and finally get the following table:

 B   C
F   3   5

M  2   3

Is there a function that can do that in one step?
Tried ?structable, ?ftable, ?xtabs, ?table but could not get what I would
like to have.

Maybe I did not use the tried functions in the right way.

Many thanks in advance for any help.

B.



-
The art of living is more like wrestling than dancing.
(Marcus Aurelius)
-- 
View this message in context: 
http://www.nabble.com/contingency-table%2C-several-variables-from-dataframe-tp19775083p19775083.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] Lattice: don't draw unlabled tick marks

2008-10-02 Thread Philipp Pagel
On Wed, Oct 01, 2008 at 01:19:04PM +, Dieter Menne wrote:
> > I also would like to get rid of the unlabeled tick marks (top and
> > right). How can I do that?
> > 
> 
> Reminds me of a problem with a journal editor... See parameter tck under 
> scales
> in xyplot documentation.

Thanks! Aparently I didn't read the manual page carefully enough...

cu
Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
http://mips.gsf.de/staff/pagel

__
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] Multiple hist(ograms) - One plot

2008-10-02 Thread Michael Just
Hello,
If I use:

p <- ggplot(dat, aes(x=bbContag, y=..density..)) + geom_histogram()

and then:

p + facet_grid(. ~ sc_recov)

Its a little crazy because I have 48 different values in 'sc_recov'.
Instead I want to select cases from 'sc_recov' and only use three at a time:

I tried:
> p + facet_grid(sc_recov=="21" ~.)
Error in check_formula(formula, varnames) :
  Formula contains variables not in list of known variables

How can I select cases?

Any ideas or suggestions?
Thanks,
M Just

On Thu, Oct 2, 2008 at 2:42 AM, ONKELINX, Thierry
<[EMAIL PROTECTED]>wrote:

> Dear Michael,
>
> Try ggplot2. Use something like
>
> install.packages("ggplot2")
> library(ggplot2)
> recov <- 0:2
> n <- 1000
> all <- data.frame(bbED = rnorm(3 * n, mean = recov), recov =
> factor(rep(recov, n)))
> ggplot(data = all, aes(x = bbED)) + geom_histogram() + facet_grid(. ~
> recov)
> ggplot(data = all, aes(x = bbED)) + geom_histogram() + facet_grid(recov
> ~ .)
> ggplot(data = all, aes(x = bbED, colour = recov)) + geom_density()
>
> You'll find more information on ggplot2 at http://had.co.nz/ggplot2/
>
> HTH,
>
> Thierry
>
> 
> 
> ir. Thierry Onkelinx
> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
> and Forest
> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
> methodology and quality assurance
> Gaverstraat 4
> 9500 Geraardsbergen
> Belgium
> tel. + 32 54/436 185
> [EMAIL PROTECTED]
> www.inbo.be
>
> To call in the statistician after the experiment is done may be no more
> than asking him to perform a post-mortem examination: he may be able to
> say what the experiment died of.
> ~ Sir Ronald Aylmer Fisher
>
> The plural of anecdote is not data.
> ~ Roger Brinner
>
> The combination of some data and an aching desire for an answer does not
> ensure that a reasonable answer can be extracted from a given body of
> data.
> ~ John Tukey
>
> -Oorspronkelijk bericht-
> Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Namens Michael Just
> Verzonden: donderdag 2 oktober 2008 7:29
> Aan: r-help@r-project.org
> Onderwerp: [R] Multiple hist(ograms) - One plot
>
> Hello,
> I am trying to plot multiple histograms with the same scales, etc into
> one
> plot. The commands below produce a 3 page PDF with each histogram
> occupying
> the upper right quadrant. And use slightly different scales on the X and
> Y
> axes.
>
> > s21 <- dat[dat$sc_recov=="21",]
> > s21.ED <- subset(s21, select=(bbED))
> > s31 <- all[all$sc_recov=="31",]
> > s31.ED <- subset(s31, select=(bbED))
> > s41 <- all[all$sc_recov=="41",]
> > s41.ED <- subset(s41, select=(bbED))
> > pdf("234_1_ED.pdf")
> > par(mfrow = c(2, 2), oma = c(0, 0, 2, 0))
> > hist(s21.ED) + hist(s31.ED) + hist(s41.ED)
> > dev.off()
>
> Also, for example if I add something like col="x", or main="x" to the
> hist(x, ...) nothing appears on the plot.  ?
>
> Please advise,
> Thank you kindly,
> M Just
>
> [[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.
>
> Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver
> weer
> en binden het INBO onder geen enkel beding, zolang dit bericht niet
> bevestigd is
> door een geldig ondertekend document. The views expressed in  this message
> and any annex are purely those of the writer and may not be regarded as
> stating
> an official position of INBO, as long as the message is not confirmed by a
> duly
> signed document.
>

[[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] R Training Courses

2008-10-02 Thread Sharon Lazenby
There are still places available on the following courses. For more
detailed information and a registration form please contact
[EMAIL PROTECTED], or visit our website at
www.mango-solutions.com  .

 

 

R for Finance



Dates: 21st to 23rd October 2008.  Duration: 3 days.  Location: London.



The R Language



Dates: 11th to 12th November.  Duration: 2 days.  Location: New York.



The R Language



Dates: 2nd to 3rd December. Duration: 2 days.  Location: London.





*   mangosolutions  
*   Tel   +44 (0)1249 767700 
*   Mob +44 (0)7966 062462  
*   Fax  +44 (0)1249 767707 

data analysis that delivers



Mango have moved - our new address is Ground Floor, Unit 2 Greenways
Business Park, Chippenham SN15 1BN




[[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] Multiple hist(ograms) - One plot

2008-10-02 Thread Michael Just
Dieter Menne:
Thanks for the suggestion and link, it looks good. I think my trouble now is
lack of basic R knowledge.

Cheers,
Michael

For example,

I tried:
histogram(~bbContag | sc_recov, data=dat)

This would work fine if I could select cases from sc_recov. How can I select
more than one case? I know I can do:

sc_recov.21 <- dat[dat$sc_recov=21,]

but how could I select all cases where sc_recov = 21, 31 or 41?


On Thu, Oct 2, 2008 at 3:33 AM, Michael Just <[EMAIL PROTECTED]> wrote:

> Hello,
> If I use:
>
> p <- ggplot(dat, aes(x=bbContag, y=..density..)) + geom_histogram()
>
> and then:
>
> p + facet_grid(. ~ sc_recov)
>
> Its a little crazy because I have 48 different values in 'sc_recov'.
> Instead I want to select cases from 'sc_recov' and only use three at a time:
>
> I tried:
> > p + facet_grid(sc_recov=="21" ~.)
> Error in check_formula(formula, varnames) :
>   Formula contains variables not in list of known variables
>
> How can I select cases?
>
> Any ideas or suggestions?
> Thanks,
> M Just
>
> On Thu, Oct 2, 2008 at 2:42 AM, ONKELINX, Thierry <
> [EMAIL PROTECTED]> wrote:
>
>> Dear Michael,
>>
>> Try ggplot2. Use something like
>>
>> install.packages("ggplot2")
>> library(ggplot2)
>> recov <- 0:2
>> n <- 1000
>> all <- data.frame(bbED = rnorm(3 * n, mean = recov), recov =
>> factor(rep(recov, n)))
>> ggplot(data = all, aes(x = bbED)) + geom_histogram() + facet_grid(. ~
>> recov)
>> ggplot(data = all, aes(x = bbED)) + geom_histogram() + facet_grid(recov
>> ~ .)
>> ggplot(data = all, aes(x = bbED, colour = recov)) + geom_density()
>>
>> You'll find more information on ggplot2 at http://had.co.nz/ggplot2/
>>
>> HTH,
>>
>> Thierry
>>
>> 
>> 
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for Nature
>> and Forest
>> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
>> methodology and quality assurance
>> Gaverstraat 4
>> 9500 Geraardsbergen
>> Belgium
>> tel. + 32 54/436 185
>> [EMAIL PROTECTED]
>> www.inbo.be
>>
>> To call in the statistician after the experiment is done may be no more
>> than asking him to perform a post-mortem examination: he may be able to
>> say what the experiment died of.
>> ~ Sir Ronald Aylmer Fisher
>>
>> The plural of anecdote is not data.
>> ~ Roger Brinner
>>
>> The combination of some data and an aching desire for an answer does not
>> ensure that a reasonable answer can be extracted from a given body of
>> data.
>> ~ John Tukey
>>
>> -Oorspronkelijk bericht-
>> Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> Namens Michael Just
>> Verzonden: donderdag 2 oktober 2008 7:29
>> Aan: r-help@r-project.org
>> Onderwerp: [R] Multiple hist(ograms) - One plot
>>
>> Hello,
>> I am trying to plot multiple histograms with the same scales, etc into
>> one
>> plot. The commands below produce a 3 page PDF with each histogram
>> occupying
>> the upper right quadrant. And use slightly different scales on the X and
>> Y
>> axes.
>>
>> > s21 <- dat[dat$sc_recov=="21",]
>> > s21.ED <- subset(s21, select=(bbED))
>> > s31 <- all[all$sc_recov=="31",]
>> > s31.ED <- subset(s31, select=(bbED))
>> > s41 <- all[all$sc_recov=="41",]
>> > s41.ED <- subset(s41, select=(bbED))
>> > pdf("234_1_ED.pdf")
>> > par(mfrow = c(2, 2), oma = c(0, 0, 2, 0))
>> > hist(s21.ED) + hist(s31.ED) + hist(s41.ED)
>> > dev.off()
>>
>> Also, for example if I add something like col="x", or main="x" to the
>> hist(x, ...) nothing appears on the plot.  ?
>>
>> Please advise,
>> Thank you kindly,
>> M Just
>>
>> [[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.
>>
>> Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver
>> weer
>> en binden het INBO onder geen enkel beding, zolang dit bericht niet
>> bevestigd is
>> door een geldig ondertekend document. The views expressed in  this message
>> and any annex are purely those of the writer and may not be regarded as
>> stating
>> an official position of INBO, as long as the message is not confirmed by a
>> duly
>> signed document.
>>
>
>

[[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] possible bug in function 'var' in R 2.7.2?

2008-10-02 Thread klaus . steenberg . larsen
Dear R-Help,

 

I have used R2.6.0 until I recently installed also R2.7.2 (see details below)

 

In R 2.6.0, the following script using the function 'var' (cor(stats)):

 

x.test <- c(NA, NA, NA, NA)

var(x.test, na.rm=T)

 

gives the output: 

 

NA

 

In R2.7.2 the output of the same script generates an error message and stops R:

 

 'Error in var(x.test, na.rm = T) : no complete element pairs'

 

R2.7.2 can handle it if there is just one non-NA value in the list but not if 
they are all NA.

 

I prefer the output of 2.6.0. Is this a bug in 2.7.2 or is it a deliberate 
change compare to previous versions? Or is there a way to make R2.7.2 give NA 
as output?

 

Thank you for any helo/comments!

 

Best regards,

 

Klaus

 

Details on R versions installed and platform:

Platform: Windows XP Prof, English, ver. 5.1

R2.6.0:

"LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252"

R2.7.2:

"LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252"

 

Klaus Steenberg Larsen
Scientist
Phone direct +45 4677 4157
[EMAIL PROTECTED]
 

Biosystems Division
Risø National Lab. for sustainable Energy
Risø DTU
Building 309, P.O. Box 49
DK-4000 Roskilde, Denmark
Tel +45 4677 4100
Fax +45 4677 4160
www.risoe.dk 

>From 1 January 2007, Risø National Laboratory, the Danish Institute for Food 
>and Veterinary Research,
the Danish Institute for Fisheries Research, the Danish National Space Center 
and
the Danish Transport Research Institute have been merged with
the Technical University of Denmark (DTU) with DTU as the continuing unit.













 


[[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] error message documentation: "Error: no function to return from, jumping to top level"

2008-10-02 Thread tolga . i . uzuner
Dear R Users,

Are error messages in R documented somewhere ? I am getting the following 
error message and would like to track down what it means and which 
specific routine triggers it:

Error: no function to return from, jumping to top level

Once I figure out which snippet of code triggers it, I can submit to the 
list a working example in case I cannot get to the bottom of the problem 
myself.

Thanks in advance,
Tolga

Generally, this communication is for informational purposes only
and it is not intended as an offer or solicitation for the purchase
or sale of any financial instrument or as an official confirmation
of any transaction. In the event you are receiving the offering
materials attached below related to your interest in hedge funds or
private equity, this communication may be intended as an offer or
solicitation for the purchase or sale of such fund(s).  All market
prices, data and other information are not warranted as to
completeness or accuracy and are subject to change without notice.
Any comments or statements made herein do not necessarily reflect
those of JPMorgan Chase & Co., its subsidiaries and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
[[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] error message documentation: "Error: no function to return from, jumping to top level"

2008-10-02 Thread bartjoosen

I think you wrote a function, but pass only snippets of code from your script
to your R-console.
The part which return the error is the following:
return()

return can only be used to return from a function and not as a command in
the R-console.

Bart

TU wrote:
> 
> Dear R Users,
> 
> Are error messages in R documented somewhere ? I am getting the following 
> error message and would like to track down what it means and which 
> specific routine triggers it:
> 
> Error: no function to return from, jumping to top level
> 
> Once I figure out which snippet of code triggers it, I can submit to the 
> list a working example in case I cannot get to the bottom of the problem 
> myself.
> 
> Thanks in advance,
> Tolga
> 
> Generally, this communication is for informational purposes only
> and it is not intended as an offer or solicitation for the purchase
> or sale of any financial instrument or as an official confirmation
> of any transaction. In the event you are receiving the offering
> materials attached below related to your interest in hedge funds or
> private equity, this communication may be intended as an offer or
> solicitation for the purchase or sale of such fund(s).  All market
> prices, data and other information are not warranted as to
> completeness or accuracy and are subject to change without notice.
> Any comments or statements made herein do not necessarily reflect
> those of JPMorgan Chase & Co., its subsidiaries and affiliates.
> 
> This transmission may contain information that is privileged,
> confidential, legally privileged, and/or exempt from disclosure
> under applicable law. If you are not the intended recipient, you
> are hereby notified that any disclosure, copying, distribution, or
> use of the information contained herein (including any reliance
> thereon) is STRICTLY PROHIBITED. Although this transmission and any
> attachments are believed to be free of any virus or other defect
> that might affect any computer system into which it is received and
> opened, it is the responsibility of the recipient to ensure that it
> is virus free and no responsibility is accepted by JPMorgan Chase &
> Co., its subsidiaries and affiliates, as applicable, for any loss
> or damage arising in any way from its use. If you received this
> transmission in error, please immediately contact the sender and
> destroy the material in its entirety, whether in electronic or hard
> copy format. Thank you.
> Please refer to http://www.jpmorgan.com/pages/disclosures for
> disclosures relating to UK legal entities.
>   [[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/error-message-documentation%3A-%22Error%3A-no-function-to-return-from%2C-jumping-to-top-level%22-tp19776107p19776262.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] Multiple hist(ograms) - One plot

2008-10-02 Thread Dieter Menne
Michael Just  gmail.com> writes:

> 
> sc_recov.21 <- dat[dat$sc_recov=21,]


Be careful: it should be "==", not "=" when want a comparison.

df = data.frame(grp = letters[1:5],val=rnorm(100))
dfab = df[df$grp=="a" | df$grp=="b",] # The simple way with "or"
dfcde = df[df$grp %in% c("c","d","e"),] # The flexible was

Or use the subset parameter in lattice plot

Dieter

__
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] Multiple hist(ograms) - One plot

2008-10-02 Thread ONKELINX, Thierry
Michael,

Use %in% to select multiple cases:

dat[dat$sc_recov %in% c(21, 31, 41), ] 




ir. Thierry Onkelinx
Instituut voor natuur- en bosonderzoek / Research Institute for Nature
and Forest
Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
methodology and quality assurance
Gaverstraat 4
9500 Geraardsbergen
Belgium 
tel. + 32 54/436 185
[EMAIL PROTECTED] 
www.inbo.be 

To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to
say what the experiment died of.
~ Sir Ronald Aylmer Fisher

The plural of anecdote is not data.
~ Roger Brinner

The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of
data.
~ John Tukey

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Michael Just
Verzonden: donderdag 2 oktober 2008 10:59
Aan: r-help@r-project.org
CC: [EMAIL PROTECTED]
Onderwerp: Re: [R] Multiple hist(ograms) - One plot

Dieter Menne:
Thanks for the suggestion and link, it looks good. I think my trouble
now is
lack of basic R knowledge.

Cheers,
Michael

For example,

I tried:
histogram(~bbContag | sc_recov, data=dat)

This would work fine if I could select cases from sc_recov. How can I
select
more than one case? I know I can do:

sc_recov.21 <- dat[dat$sc_recov=21,]

but how could I select all cases where sc_recov = 21, 31 or 41?


On Thu, Oct 2, 2008 at 3:33 AM, Michael Just <[EMAIL PROTECTED]> wrote:

> Hello,
> If I use:
>
> p <- ggplot(dat, aes(x=bbContag, y=..density..)) + geom_histogram()
>
> and then:
>
> p + facet_grid(. ~ sc_recov)
>
> Its a little crazy because I have 48 different values in 'sc_recov'.
> Instead I want to select cases from 'sc_recov' and only use three at a
time:
>
> I tried:
> > p + facet_grid(sc_recov=="21" ~.)
> Error in check_formula(formula, varnames) :
>   Formula contains variables not in list of known variables
>
> How can I select cases?
>
> Any ideas or suggestions?
> Thanks,
> M Just
>
> On Thu, Oct 2, 2008 at 2:42 AM, ONKELINX, Thierry <
> [EMAIL PROTECTED]> wrote:
>
>> Dear Michael,
>>
>> Try ggplot2. Use something like
>>
>> install.packages("ggplot2")
>> library(ggplot2)
>> recov <- 0:2
>> n <- 1000
>> all <- data.frame(bbED = rnorm(3 * n, mean = recov), recov =
>> factor(rep(recov, n)))
>> ggplot(data = all, aes(x = bbED)) + geom_histogram() + facet_grid(. ~
>> recov)
>> ggplot(data = all, aes(x = bbED)) + geom_histogram() +
facet_grid(recov
>> ~ .)
>> ggplot(data = all, aes(x = bbED, colour = recov)) + geom_density()
>>
>> You'll find more information on ggplot2 at http://had.co.nz/ggplot2/
>>
>> HTH,
>>
>> Thierry
>>
>>

>> 
>> ir. Thierry Onkelinx
>> Instituut voor natuur- en bosonderzoek / Research Institute for
Nature
>> and Forest
>> Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
>> methodology and quality assurance
>> Gaverstraat 4
>> 9500 Geraardsbergen
>> Belgium
>> tel. + 32 54/436 185
>> [EMAIL PROTECTED]
>> www.inbo.be
>>
>> To call in the statistician after the experiment is done may be no
more
>> than asking him to perform a post-mortem examination: he may be able
to
>> say what the experiment died of.
>> ~ Sir Ronald Aylmer Fisher
>>
>> The plural of anecdote is not data.
>> ~ Roger Brinner
>>
>> The combination of some data and an aching desire for an answer does
not
>> ensure that a reasonable answer can be extracted from a given body of
>> data.
>> ~ John Tukey
>>
>> -Oorspronkelijk bericht-
>> Van: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
>> Namens Michael Just
>> Verzonden: donderdag 2 oktober 2008 7:29
>> Aan: r-help@r-project.org
>> Onderwerp: [R] Multiple hist(ograms) - One plot
>>
>> Hello,
>> I am trying to plot multiple histograms with the same scales, etc
into
>> one
>> plot. The commands below produce a 3 page PDF with each histogram
>> occupying
>> the upper right quadrant. And use slightly different scales on the X
and
>> Y
>> axes.
>>
>> > s21 <- dat[dat$sc_recov=="21",]
>> > s21.ED <- subset(s21, select=(bbED))
>> > s31 <- all[all$sc_recov=="31",]
>> > s31.ED <- subset(s31, select=(bbED))
>> > s41 <- all[all$sc_recov=="41",]
>> > s41.ED <- subset(s41, select=(bbED))
>> > pdf("234_1_ED.pdf")
>> > par(mfrow = c(2, 2), oma = c(0, 0, 2, 0))
>> > hist(s21.ED) + hist(s31.ED) + hist(s41.ED)
>> > dev.off()
>>
>> Also, for example if I add something like col="x", or main="x" to the
>> hist(x, ...) nothing appears on the plot.  ?
>>
>> Please advise,
>> Thank you kindly,
>> M Just
>>
>> [[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-gu

[R] Problem with read.table()

2008-10-02 Thread Joan-Josep Vallbé
Hello everybody,

I'm a new user and I'm trying to use read.table with a tab delimited  
file but the system tells me (i) that there are more columns than  
column names, and (ii) that headers and col.names are of different  
lengths. I have already checked my variable names and there's no blank  
spaces. However, some variables have quite long names such as  
"valoracion.experiencias.segundo.year". Could it be the problem? If  
that is the case, I still don't understand why I have more columns  
that column names. Could anyone help me with that?

Thank you very much!


Joan-Josep Vallbé
Institute of Law and Technology
Political Science Department
Autonomous University of Barcelona (UAB)
[EMAIL PROTECTED]






[[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] RBloomberg :: blpConnect crash.

2008-10-02 Thread Gopi Goswami
Hi there,

How are you? I'm having some issues with the following set up:

WINDOWS XP
R-2.7.2
RBloomberg-0.1-10
RDCOMClient-0.92-0
zoo-1.5-4
chron-2.3-24


Bloomberg is installed in the machine. The following code crashes R:


library(RBloomberg)
.bbfields <- blpReadFields('C:\\path\\to\\blp\\API')
conn <- blpConnect( )


I investigated the problem using debug(blpConnect) and found out that the
code dies at the following line of the blpConnect function:

conn[["Timeout"]] <<- timeout;



The above problem occurs whether Bloomberg is running or not, whether the
market is open or not. Any help would be much appreciated.



Regards,
gopi.
PhD, Statistics, 2005
http://gopi-goswami.net/index.html


PS: I had sent the above mail to the R-SIG Finance list on SEP 29, but it
was not even posted there for some unknown reason.

[[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] extracting diagonal from dist()

2008-10-02 Thread Tony
Stephen, I think this is what you want:

> diag(as.matrix(d)[-1, ])

the '-1' above means that you ignore row one in the matrix. Given that
it's a square matrix, I suppose you could also also do:

> diag(as.matrix(d)[-1,-19])

the '-19' above mean you ignore the 19th column of hte matrix. Both
give the same answer on my machine.

Hope that helps a little,
Tony

Ps. This is my first attempt at helping someone in this group, so yay
for me!  :-)

stephen sefick wrote:
> h <- structure(list(V1 = c(-0.351714766, 0.188298251, 0.042951816,
> -0.072490327, -0.691885485, -0.816169763, -0.7066502, -0.856286332,
> -0.839723411, -0.427242353, -0.372911996, 0.326707494, 0.07847893,
> 0.687447841, 0.516105863, 0.267076547, 0.727867663, 0.432699191,
> 0.258610632), V2 = c(0.256636068, -0.824072121, -0.149185618,
> 0.153280492, 0.01649528, 0.409410528, 0.286015324, 0.366323539,
> 0.426800995, -0.735712725, -0.767824938, -0.440086289, -0.308010116,
> 0.458001784, 0.592207506, 0.449511677, -0.007212198, -0.046479998,
> -0.19965154), V3 = c(0.033986839, 0.128179407, 0.525683422, 0.330851415,
> 0.800996941, 0.031813218, -0.232375584, -0.261745661, -0.446943818,
> -0.067349584, -0.210142202, 0.288245114, -0.426273652, 0.179351629,
> 0.299167413, -0.45663776, -0.172400654, -0.273902898, -0.393874281
> ), V4 = c(0.65461555, -0.046146226, 0.355091147, 0.201657295,
> -0.032329184, -0.414280507, -0.466305336, -0.207174265, -0.2168161,
> -0.190256903, -0.087694801, -0.366977945, 0.153600027, -0.253544176,
> -0.279933607, 0.323432824, -0.272048254, -0.313094051, -0.033307846
> )), .Names = c("V1", "V2", "V3", "V4"), class = "data.frame",
> row.names = c("1201 dn",
> "0502 dn", "0702 dn", "1002 dn", "1102 dn", "1202 dn", "0103 dn",
> "0203 dn", "0303 dn", "0403 dn", "0503 dn", "0803 dn", "0104 dn",
> "0704 dn", "0804 dn", "1204 dn", "0805 dn", "1005 dn", "0106 dn"
> ))
>
> d <- dist(h)
> diag(as.matrix(d))
>
>
> this is close I just need the diagonal to start one more row down.  In
> other words I just want the diagonal starting below the 0 diagonal.  I
> am having a hard time figuring this one out..
>
> --
> Stephen Sefick
> Research Scientist
> Southeastern Natural Sciences Academy
>
> Let's not spend our time and resources thinking about things that are
> so little or so large that all they really do for us is puff us up and
> make us feel like gods.  We are mammals, and have not exhausted the
> annoying little problems of being mammals.
>
>   -K. Mullis
>
> __
> 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] Problem with read.table()

2008-10-02 Thread Richard . Cotton
> I'm a new user and I'm trying to use read.table with a tab delimited 
> file but the system tells me (i) that there are more columns than 
> column names, and (ii) that headers and col.names are of different 
> lengths. I have already checked my variable names and there's no blank 
> spaces. However, some variables have quite long names such as 
> "valoracion.experiencias.segundo.year". Could it be the problem? If 
> that is the case, I still don't understand why I have more columns 
> that column names. Could anyone help me with that?

It is unlikely to be due to the long variable names.  Without seeing your 
data, it is impossible to say for sure what the problem is, but here are 
some things to check.

Have you set the 'sep' argument to "\t"?  Otherwise read.table may get 
confused and interpret tabs as multiple spaces.  Alternatively, use 
read.delim, which is a wrapper for read.table made especially for tab 
delimited files.

Are there any tabs at the ends of lines?

Are there any text variables with spaces, that aren't enclosed on quotes?

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
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] contingency table, several variables from dataframe

2008-10-02 Thread Eik Vettorazzi
First of all your construction of ABC leads to a structure with 3 factor 
variables due to the way cbind processes the input variables -  which is 
not intended I think.


You can do sth like

ABC<-data.frame(A,B,C)
aggregate(ABC[,2:3],by=list(A),sum)

hth.

Birgitle schrieb:

Hello R-Users!

I need a little help to build up a contingency table out of several
variables.

  A<-c("F","M","M","F","F","F","F","M","F","M","F","F")
  B<-c(0,0,0,0,0,0,1,1,1,1,0,1)
  C<-c(0,1,1,1,1,1,1,1,1,0,0,0)

  ABC<-as.data.frame(cbind(A,B,C))

  ABC

   A B C
1  F 0 0
2  M 0 1
3  M 0 1
4  F 0 1
5  F 0 1
6  F 0 1
7  F 1 1
8  M 1 1
9  F 1 1
10 M 1 0
11 F 0 0
12 F 1 0

I would like to count in each variable B and C the frequencies for M and F
(variable A) and finally get the following table:

 B   C
F   3   5

M  2   3

Is there a function that can do that in one step?
Tried ?structable, ?ftable, ?xtabs, ?table but could not get what I would
like to have.

Maybe I did not use the tried functions in the right way.

Many thanks in advance for any help.

B.



-
The art of living is more like wrestling than dancing.
(Marcus Aurelius)
  


--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790

__
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] lapply where each list object has multiple parts

2008-10-02 Thread Henrique Dallazuanna
Try this:

rapply(BigList, mean)[c(1, 3)]


On Wed, Oct 1, 2008 at 6:29 PM, eric lee <[EMAIL PROTECTED]> wrote:
> Hi.  I have a list where each object in the list has multiple parts.  I'd
> like to take the mean of just one part of each object.  Is it possible to do
> this with lapply?  If not, can you recommend another function?  Thanks.
>
> eric
>
>> x1 <- c(0,1,2,3)
>> x2 <- c(7,8)
>> x3 <- c(2,6,6,8)
>> x4 <- c(4,8)
>>
>> Lst1 <- list(label1 = x1,label2 = x2)
>> Lst2 <- list(label1 = x3, label2 = x4)
>>
>> BigList <- list(Lst1, Lst2)
>>
>> lapply(BigList$label1, mean)
> list()
>>
>
>[[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

__
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] contingency table, several variables from dataframe

2008-10-02 Thread Birgitle

Thanks for your answer.

It is intended, that the variables are treated as class factor, because
these are binary variables with, for example, the presence or the absence of
a plant organ.
As far as I understood, I have to treat them for other calculations as
factor. Therefore I classified these variables as factors in my original
dataframe.

If I do what you suggested, I have to change the classes of all my
variables. Is there a possibility to do something similar without changing
the classes?

B.


Eik Vettorazzi wrote:
> 
> First of all your construction of ABC leads to a structure with 3 factor 
> variables due to the way cbind processes the input variables -  which is 
> not intended I think.
> 
> You can do sth like
> 
> ABC<-data.frame(A,B,C)
> aggregate(ABC[,2:3],by=list(A),sum)
> 
> hth.
> 
> Birgitle schrieb:
>> Hello R-Users!
>>
>> I need a little help to build up a contingency table out of several
>> variables.
>>
>>   A<-c("F","M","M","F","F","F","F","M","F","M","F","F")
>>   B<-c(0,0,0,0,0,0,1,1,1,1,0,1)
>>   C<-c(0,1,1,1,1,1,1,1,1,0,0,0)
>>
>>   ABC<-as.data.frame(cbind(A,B,C))
>>
>>   ABC
>>
>>A B C
>> 1  F 0 0
>> 2  M 0 1
>> 3  M 0 1
>> 4  F 0 1
>> 5  F 0 1
>> 6  F 0 1
>> 7  F 1 1
>> 8  M 1 1
>> 9  F 1 1
>> 10 M 1 0
>> 11 F 0 0
>> 12 F 1 0
>>
>> I would like to count in each variable B and C the frequencies for M and
>> F
>> (variable A) and finally get the following table:
>>
>>  B   C
>> F   3   5
>>
>> M  2   3
>>
>> Is there a function that can do that in one step?
>> Tried ?structable, ?ftable, ?xtabs, ?table but could not get what I would
>> like to have.
>>
>> Maybe I did not use the tried functions in the right way.
>>
>> Many thanks in advance for any help.
>>
>> B.
>>
>>
>>
>> -
>> The art of living is more like wrestling than dancing.
>> (Marcus Aurelius)
>>   
> 
> -- 
> Eik Vettorazzi
> Institut für Medizinische Biometrie und Epidemiologie
> Universitätsklinikum Hamburg-Eppendorf
> 
> Martinistr. 52
> 20246 Hamburg
> 
> T ++49/40/42803-8243
> F ++49/40/42803-7790
> 
> __
> 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.
> 
> 


-
The art of living is more like wrestling than dancing.
(Marcus Aurelius)
-- 
View this message in context: 
http://www.nabble.com/contingency-table%2C-several-variables-from-dataframe-tp19775083p19777611.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] function in R

2008-10-02 Thread bartjoosen

you can see the different methods of mean by: methods(mean)
Then you can type mean.default and you will see the complete code.

Bart


Alphonse Monkamg wrote:
> 
> 
> 
> 
> 
> Dear ALL,
> 
> Does anyone know how to get the complete code program for any build-in
> function
> in R, e.g. when I tape mean in the R-console, I get the following: 
> 
>  mean
> 
> function (x, ...) 
> 
> UseMethod("mean")
> 
> 
> 
> but I need the full mean function.
> 
> 
> 
> Thank in advance,
> 
> 
> 
> Alphonse.
> 
> 
>   
>   [[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/function-in-R-tp19777553p19777674.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] function in R

2008-10-02 Thread Gustaf Rydevik
On Thu, Oct 2, 2008 at 1:34 PM, Alphonse Monkamg <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Dear ALL,
>
> Does anyone know how to get the complete code program for any build-in 
> function
> in R, e.g. when I tape mean in the R-console, I get the following:
>
>  mean
>
> function (x, ...)
>
> UseMethod("mean")
>
> 
>
> but I need the full mean function.
>
>
>
> Thank in advance,
>
>
>
> Alphonse.
>
>
>
>[[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.
>
>

Hi Alphonse,

"mean" is a so-called "generic function", that behaves differently
depending on what class it's argument is.

writing:

?UseMethod

,explains a bit of this, and points you to:

?methods

So you can write

methods(mean)

, and see which functions exist. For example mean.default, or
mean.data.frame, for which you can have a look at the code. An added
complication is that these functions are calling C-code by using
".Internal". This C-code can be found in cran, but as I don't know C,
I've never tried it out more than having a quick look. But it's there
if you want it.

Regards,

Gustaf Rydevik



-- 
Gustaf Rydevik, M.Sci.
tel: +46(0)703 051 451
address:Essingetorget 40,112 66 Stockholm, SE
skype:gustaf_rydevik

__
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] Adding plane in a 3D scatterplot

2008-10-02 Thread Megh Dal
I have drawn a 3D scatter plot :

library(mnormt)
library(scatterplot3d)
dat = cbind(rmnorm(3, rep(0,2), diag(2)), 1:3)
scatterplot3d(dat)

Now I want to do 2 things :

1 : In the Z-axis (i.e. height), I want to see only numbers 1,2,3, etc NOT, 
1,1.5,2,2.5.

2. I want to add two Horizontal planes at hight z=2 and z=3. Those two planes 
should look like "bottom" of that 3D plot [i.e. like Grid-lines].I already gone 
through "$plane3d" but could not get through. In the help page, a description 
is given with a regression line, however I could not understand how I can 
implement that in my problem. 

Any help will be highly appreciate. 

Regards,

__
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] Problem with read.table()

2008-10-02 Thread Dieter Menne
Joan-Josep Vallbé  uab.cat> writes:

> I'm a new user and I'm trying to use read.table with a tab delimited  
> file but the system tells me (i) that there are more columns than  
> column names, and (ii) that headers and col.names are of different  
> lengths. I have already checked my variable names and there's no blank  
> spaces. 
> However, some variables have quite long names such as  
> "valoracion.experiencias.segundo.year". Could it be the problem? 

I am sure you tried removing the first line and using header =FALSE, because
that is faster than writing a message

> If  that is the case, I still don't understand why I have more columns  
> that column names.

Use an editor that shows tabs explicitly. Often, there is a TRAILING tab in the
data rows. 

Dieter

__
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] nls with plinear and function on RHS

2008-10-02 Thread Keith Jewell
Dear R gurus,

As part of finding initial values for a much more complicated fit I want to 
fit a function of the form y ~ a + bx + cx^d to fairly "noisy" data and have 
hit some problems.

To demonstrate the specific R-related problem, here is an idealised data 
set, smaller and better fitting than reality:
# idealised data set
aDF <- data.frame( x= c(1.80, 9.27, 6.48, 2.61, 9.86, 5.93, 6.76, 5.52, 
6.06, 8.62),
y= c(24.77, 2775.07, 895.15, 60.73, 3373.57, 677.82, 1021.92, 542.84, 
725.25, 2200.04))

And here are some starting values, far better than I'd have in reality
# good starting values
startL <- list(Ca=4, Cb=3, Cc=3, Cd=3)

In these idealised circumstances nls converges using the default algorithm.
# nls, default algorithm
nls(y ~ Ca + Cb*x + Cc*x^Cd, data=aDF, start=startL)

Unfortunately, in reality it often fails to converge. This model is linear 
in a, b and c so I've used the plinear algorithm.
# nls, plinear algorithm, explicit RHS
nls(y ~ cbind(Ca=1,Cb=x, Cc=x^Cd), data=aDF, start=startL["Cd"], 
algorithm="plinear")

This converges much more often but sometimes crashes with the error message
"Error in numericDeriv(form[[3]], names(ind), env) :
  Missing value or an infinity produced when evaluating the model"

I deduce that it is failing in the numerical differentiation of x^Cd (but 
don't know why), so I thought I'd avoid the numerical differentiation by 
putting the RHS in a function to which I could (later) add a 'gradient' 
attribute
# function to provide RHS
bFunc <- function(x, Ca, Cb, Cc, Cd) cbind(Ca=1,Cb=x, Cc=x^Cd)

# nls, plinear algorithm, RHS from function
nls(y ~ bFunc(x, Ca, Cb, Cc, Cd), data=aDF, start=startL["Cd"], 
algorithm="plinear")

However, this gives me
"Error in nls(y ~ bFunc(x, Ca, Cb, Cc, Cd), data = aDF, start = 
startL["Cd"],  :
  parameters without starting value in 'data': Ca, Cb, Cc"

Can anyone tell me
a) why putting the RHS into a function "broke" the plinear algorithm
b) if there's a better approach to my problem

Thanks in advance,

Keith Jewell
-
I'm using V2.7.2...
> sessionInfo()
R version 2.7.2 (2008-08-25)
i386-pc-mingw32

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

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

other attached packages:
[1] xlsReadWrite_1.3.2 svSocket_0.9-5 TinnR_1.0.2R2HTML_1.59 
Hmisc_3.4-3

loaded via a namespace (and not attached):
[1] cluster_1.11.11 grid_2.7.2  lattice_0.17-14 svMisc_0.9-5 
VGAM_0.7-7

... but have also tried todays V2.7.2 patched and V2.8.0alpha, both of which 
give the same behaviour

__
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] contingency table, several variables from dataframe

2008-10-02 Thread Eik Vettorazzi
Ok, then treat them as factors - but if they are really binary and coded 
0 and 1, which kind of calculation would lead to different results for a 
"factor" instead of a numeric variable?


Anyway,

ABC<-as.data.frame(cbind(A,B,C))
aggregate(ABC[,2:3],by=list(A),FUN=function(x)sum(x=='1'))  # '1' is 
here the level of the corresponding factor to be counted.


will work. A more sophisticated version could include some "factor to 
numeric" conversion, see FAQ 7.10.

hth.

Birgitle schrieb:

Thanks for your answer.

It is intended, that the variables are treated as class factor, because
these are binary variables with, for example, the presence or the absence of
a plant organ.
As far as I understood, I have to treat them for other calculations as
factor. Therefore I classified these variables as factors in my original
dataframe.

If I do what you suggested, I have to change the classes of all my
variables. Is there a possibility to do something similar without changing
the classes?

B.


Eik Vettorazzi wrote:
  
First of all your construction of ABC leads to a structure with 3 factor 
variables due to the way cbind processes the input variables -  which is 
not intended I think.


You can do sth like

ABC<-data.frame(A,B,C)
aggregate(ABC[,2:3],by=list(A),sum)

hth.

Birgitle schrieb:


Hello R-Users!

I need a little help to build up a contingency table out of several
variables.

  A<-c("F","M","M","F","F","F","F","M","F","M","F","F")
  B<-c(0,0,0,0,0,0,1,1,1,1,0,1)
  C<-c(0,1,1,1,1,1,1,1,1,0,0,0)

  ABC<-as.data.frame(cbind(A,B,C))

  ABC

   A B C
1  F 0 0
2  M 0 1
3  M 0 1
4  F 0 1
5  F 0 1
6  F 0 1
7  F 1 1
8  M 1 1
9  F 1 1
10 M 1 0
11 F 0 0
12 F 1 0

I would like to count in each variable B and C the frequencies for M and
F
(variable A) and finally get the following table:

 B   C
F   3   5

M  2   3

Is there a function that can do that in one step?
Tried ?structable, ?ftable, ?xtabs, ?table but could not get what I would
like to have.

Maybe I did not use the tried functions in the right way.

Many thanks in advance for any help.

B.



-
The art of living is more like wrestling than dancing.
(Marcus Aurelius)
  
  

--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790

__
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.






-
The art of living is more like wrestling than dancing.
(Marcus Aurelius)
  


--
Eik Vettorazzi
Institut für Medizinische Biometrie und Epidemiologie
Universitätsklinikum Hamburg-Eppendorf

Martinistr. 52
20246 Hamburg

T ++49/40/42803-8243
F ++49/40/42803-7790

__
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] contingency table, several variables from dataframe

2008-10-02 Thread Birgitle

I think it makes a difference if I want to use a classification method like
rpart () or if I use a modelling approach like glm().

Many thanks for the kind and fast help. I am still very untrained and it is
difficult for me to create such codes.

B.


Eik Vettorazzi wrote:
> 
> Ok, then treat them as factors - but if they are really binary and coded 
> 0 and 1, which kind of calculation would lead to different results for a 
> "factor" instead of a numeric variable?
> 
> Anyway,
> 
> ABC<-as.data.frame(cbind(A,B,C))
> aggregate(ABC[,2:3],by=list(A),FUN=function(x)sum(x=='1'))  # '1' is 
> here the level of the corresponding factor to be counted.
> 
> will work. A more sophisticated version could include some "factor to 
> numeric" conversion, see FAQ 7.10.
> hth.
> 
> Birgitle schrieb:
>> Thanks for your answer.
>>
>> It is intended, that the variables are treated as class factor, because
>> these are binary variables with, for example, the presence or the absence
>> of
>> a plant organ.
>> As far as I understood, I have to treat them for other calculations as
>> factor. Therefore I classified these variables as factors in my original
>> dataframe.
>>
>> If I do what you suggested, I have to change the classes of all my
>> variables. Is there a possibility to do something similar without
>> changing
>> the classes?
>>
>> B.
>>
>>
>> Eik Vettorazzi wrote:
>>   
>>> First of all your construction of ABC leads to a structure with 3 factor 
>>> variables due to the way cbind processes the input variables -  which is 
>>> not intended I think.
>>>
>>> You can do sth like
>>>
>>> ABC<-data.frame(A,B,C)
>>> aggregate(ABC[,2:3],by=list(A),sum)
>>>
>>> hth.
>>>
>>> Birgitle schrieb:
>>> 
 Hello R-Users!

 I need a little help to build up a contingency table out of several
 variables.

   A<-c("F","M","M","F","F","F","F","M","F","M","F","F")
   B<-c(0,0,0,0,0,0,1,1,1,1,0,1)
   C<-c(0,1,1,1,1,1,1,1,1,0,0,0)

   ABC<-as.data.frame(cbind(A,B,C))

   ABC

A B C
 1  F 0 0
 2  M 0 1
 3  M 0 1
 4  F 0 1
 5  F 0 1
 6  F 0 1
 7  F 1 1
 8  M 1 1
 9  F 1 1
 10 M 1 0
 11 F 0 0
 12 F 1 0

 I would like to count in each variable B and C the frequencies for M
 and
 F
 (variable A) and finally get the following table:

  B   C
 F   3   5

 M  2   3

 Is there a function that can do that in one step?
 Tried ?structable, ?ftable, ?xtabs, ?table but could not get what I
 would
 like to have.

 Maybe I did not use the tried functions in the right way.

 Many thanks in advance for any help.

 B.



 -
 The art of living is more like wrestling than dancing.
 (Marcus Aurelius)
   
   
>>> -- 
>>> Eik Vettorazzi
>>> Institut für Medizinische Biometrie und Epidemiologie
>>> Universitätsklinikum Hamburg-Eppendorf
>>>
>>> Martinistr. 52
>>> 20246 Hamburg
>>>
>>> T ++49/40/42803-8243
>>> F ++49/40/42803-7790
>>>
>>> __
>>> 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.
>>>
>>>
>>> 
>>
>>
>> -
>> The art of living is more like wrestling than dancing.
>> (Marcus Aurelius)
>>   
> 
> -- 
> Eik Vettorazzi
> Institut für Medizinische Biometrie und Epidemiologie
> Universitätsklinikum Hamburg-Eppendorf
> 
> Martinistr. 52
> 20246 Hamburg
> 
> T ++49/40/42803-8243
> F ++49/40/42803-7790
> 
> __
> 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.
> 
> 


-
The art of living is more like wrestling than dancing.
(Marcus Aurelius)
-- 
View this message in context: 
http://www.nabble.com/contingency-table%2C-several-variables-from-dataframe-tp19775083p19778153.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] function in R

2008-10-02 Thread Alphonse Monkamg




Dear ALL,

Does anyone know how to get the complete code program for any build-in function
in R, e.g. when I tape mean in the R-console, I get the following: 

 mean

function (x, ...) 

UseMethod("mean")



but I need the full mean function.



Thank in advance,



Alphonse.


  
[[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] Problem with read.table()

2008-10-02 Thread Joan-Josep Vallbé

Hi, I've tried it with read.delim:

ayuso <- read.delim("/Users/user/Rwork/ayusotriada.txt")

and now the error message is "Error with make.names(col.names, unique  
= TRUE) :

  string multibyte 187 invalid"

thanks!



On 02/10/2008, at 12:21, Joan-Josep Vallbé wrote:


Hello everybody,

I'm a new user and I'm trying to use read.table with a tab delimited
file but the system tells me (i) that there are more columns than
column names, and (ii) that headers and col.names are of different
lengths. I have already checked my variable names and there's no blank
spaces. However, some variables have quite long names such as
"valoracion.experiencias.segundo.year". Could it be the problem? If
that is the case, I still don't understand why I have more columns
that column names. Could anyone help me with that?

Thank you very much!


Joan-Josep Vallbé
Institute of Law and Technology
Political Science Department
Autonomous University of Barcelona (UAB)
[EMAIL PROTECTED]






[[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.


Joan-Josep Vallbé
Institute of Law and Technology
Political Science Department
Autonomous University of Barcelona (UAB)
[EMAIL PROTECTED]

__
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] Problem with read.table()

2008-10-02 Thread Gabor Grothendieck
Look at ?count.fields to diagnose this.

On Thu, Oct 2, 2008 at 8:05 AM, Joan-Josep Vallbé <[EMAIL PROTECTED]> wrote:
> Hi, I've tried it with read.delim:
>
> ayuso <- read.delim("/Users/user/Rwork/ayusotriada.txt")
>
> and now the error message is "Error with make.names(col.names, unique =
> TRUE) :
>  string multibyte 187 invalid"
>
> thanks!
>
>
>
> On 02/10/2008, at 12:21, Joan-Josep Vallbé wrote:
>
>> Hello everybody,
>>
>> I'm a new user and I'm trying to use read.table with a tab delimited
>> file but the system tells me (i) that there are more columns than
>> column names, and (ii) that headers and col.names are of different
>> lengths. I have already checked my variable names and there's no blank
>> spaces. However, some variables have quite long names such as
>> "valoracion.experiencias.segundo.year". Could it be the problem? If
>> that is the case, I still don't understand why I have more columns
>> that column names. Could anyone help me with that?
>>
>> Thank you very much!
>>
>>
>> Joan-Josep Vallbé
>> Institute of Law and Technology
>> Political Science Department
>> Autonomous University of Barcelona (UAB)
>> [EMAIL PROTECTED]
>>
>>
>>
>>
>>
>>
>>[[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.
>
> Joan-Josep Vallbé
> Institute of Law and Technology
> Political Science Department
> Autonomous University of Barcelona (UAB)
> [EMAIL PROTECTED]
>
> __
> 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] constructing appropriate non-intercept formula

2008-10-02 Thread Ben Bolker
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1


Trying to work out a model formula that will do what I want ... suppose
I want to model

 y = b_i x + epsilon

(i.e. a linear model with zero intercept and with slopes differing
by groups), and I want to parameterize the slopes
in the "usual" way of having a baseline slope value
for the first level of the factor b and (n-1) values
representing the differences of every other level from
the first.

x = rep(1:10,2)
f = factor(rep(1:2,each=10))
b = c(2,3)
y = rnorm(20,b[f]*x,1)
dat = data.frame(f,x,y)

lm(y~f:x-1,data=dat)

   gives values for the slope of each group independently

lm(y~f*x-f-1,data=dat)

   gives a coefficient for x which is actually the slope
of group 2, a coefficient for f1:x which is (slope 1 - slope 2),
and NA for f2:x

For a subset of data

 f x
 1 1
 1 2
 2 1
 2 2

I would want the model matrix

x  f2:x
10
20
11
22

Is there any elegant way to do this?
(I could get the estimates I wanted in this case by
switching the order of the levels or the contrasts,
but I would still get an overspecified model/NA coefficient.)
Or am I missing a reason that I just shouldn't do it?

  Ben Bolker
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFI5Dh/c5UpGjwzenMRAqGGAJ9Da6s9m+w/ArX4tvMsmvSedw1QeACeM48E
tLcHlnqDHRDHUCXFDW4ScRg=
=47J/
-END PGP SIGNATURE-

__
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] function in R

2008-10-02 Thread hadley wickham
On Thu, Oct 2, 2008 at 6:34 AM, Alphonse Monkamg <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Dear ALL,
>
> Does anyone know how to get the complete code program for any build-in 
> function
> in R, e.g. when I tape mean in the R-console, I get the following:
>
>  mean
>
> function (x, ...)
>
> UseMethod("mean")
>
> 
>
> but I need the full mean function.
>
>
>
> Thank in advance,

Have a look at Uwe Ligges' "R Help Desk: Accessing the Sources" in
http://cran.r-project.org/doc/Rnews/Rnews_2006-4.pdf

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] Problem with read.table()

2008-10-02 Thread Joan-Josep Vallbé
Hi, I've done ?count.fields and it helped me identify a blank space  
that I had not noticed (thanks!), but when I try to upload the table  
again with


ayuso <- read.table("/Users/user/Rwork/ayusotriada.txt", header=TRUE,  
sep="\t", na.strings="NA", dec=".", strip.white=TRUE)


or with read.delim, the error message "Error with  
make.names(col.names, unique =



TRUE) :
string multibyte 187 invalid


still appears. thanks!



On 02/10/2008, at 14:30, Gabor Grothendieck wrote:


Look at ?count.fields to diagnose this.

On Thu, Oct 2, 2008 at 8:05 AM, Joan-Josep Vallbé  
<[EMAIL PROTECTED]> wrote:

Hi, I've tried it with read.delim:

ayuso <- read.delim("/Users/user/Rwork/ayusotriada.txt")

and now the error message is "Error with make.names(col.names,  
unique =

TRUE) :
string multibyte 187 invalid"

thanks!



On 02/10/2008, at 12:21, Joan-Josep Vallbé wrote:


Hello everybody,

I'm a new user and I'm trying to use read.table with a tab delimited
file but the system tells me (i) that there are more columns than
column names, and (ii) that headers and col.names are of different
lengths. I have already checked my variable names and there's no  
blank

spaces. However, some variables have quite long names such as
"valoracion.experiencias.segundo.year". Could it be the problem? If
that is the case, I still don't understand why I have more columns
that column names. Could anyone help me with that?

Thank you very much!


Joan-Josep Vallbé
Institute of Law and Technology
Political Science Department
Autonomous University of Barcelona (UAB)
[EMAIL PROTECTED]






  [[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.


Joan-Josep Vallbé
Institute of Law and Technology
Political Science Department
Autonomous University of Barcelona (UAB)
[EMAIL PROTECTED]

__
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.



Joan-Josep Vallbé
Institute of Law and Technology
Political Science Department
Autonomous University of Barcelona (UAB)
[EMAIL PROTECTED]

__
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 do one suggest a patch for the Foreign package

2008-10-02 Thread Duncan Murdoch
In answer to your subject heading question:  to suggest a patch, send an 
email to the package maintainer (as listed in the DESCRIPTION file).  
Your suggestion will get a better reception if you offer sample 
code/data to illustrate the problem, and a nicely written patch to the 
sources to fix it.  (From your description below, it sounds as though
you want to change the args to a function, so you'll need to patch the 
.Rd file for that function too.)


Pay attention to the effect of your changes on existing code.  Code that 
works now should not be broken by your change if it is at all possible 
to avoid that.


Duncan Murdoch

fsando wrote:
Hi I believe I have long time solution to the problems with the 
read.spss() funtion.


In non-ascii locales the import of spss files into R  has consistently 
   produced errors and sometimes wouldn't allow import at all.


I've made a custom version of the read.spss() function that appear to 
solve the problem for good. I may of course be wrong here.


I believe the problem is that read.spss() tries to guess the codepage of 
the incoming spss file. In some (many?) non-ascii locales it mostly gets 
it wrong. The simple solution is to give the user the option to 
specifically tell read.spss() which codepage to expect and which 
codepage to translate to.



  



__
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] possible bug in function 'var' in R 2.7.2?

2008-10-02 Thread Ben Bolker
  risoe.dk> writes:

> 
> Dear R-Help,
> 
> I have used R2.6.0 until I recently installed also R2.7.2 (see details below)
> 
> In R 2.6.0, the following script using the function 'var' (cor(stats)):
> 
> x.test <- c(NA, NA, NA, NA)
> 
> var(x.test, na.rm=T)
> 
> gives the output: 
> 
> NA
> 
> In R2.7.2 the output of the same script generates an error message and stops 
> R:
> 
>  'Error in var(x.test, na.rm = T) : no complete element pairs'
> 
> R2.7.2 can handle it if there is just one non-NA value in the list but not if
they are all NA.
> 
> I prefer the output of 2.6.0. Is this a bug in 2.7.2 or is it a deliberate
change compare to previous versions?
> Or is there a way to make R2.7.2 give NA as output?
> 
> Thank you for any helo/comments! 
> 
> Best regards,
> 
> Klaus

   This is a deliberate change, but the behavior will
(more or less) revert in version 2.8.0.  

 From the NEWS file for 2.7 (in bug fixes):

 o  co[rv](use = "complete.obs") now always gives an error if there
are no complete cases: they used to give NA if
method = "pearson" but an error for the other two methods.
(Note that this is pretty arbitrary, but zero-length vectors
always give an error so it is at least consistent.)

Since sd(na.rm=TRUE) and var(na.rm=TRUE) both call cov(use =
"complete.obs"), this applies also to them.

cor(use="pair") used to give diagonal 1 even if the variable
was completely missing for the rank methods but NA for the
Pearson method: it now gives NA in all cases.

cor(use="pair") for the rank methods gave a matrix result with
dimensions > 0 even if one of the inputs had 0 columns.


  From the NEWS file for the development version

   o   var(),cov(),cor() etc now by default (when 'use' is not specified)
return NA in many cases where they signalled an error before.

I don't know of a really easy way to make the behavior revert, perhaps
the easiest workaround is to make a 'my.var' function that first
tests if(all(is.na(x))) -- if you want to live really dangerously
you could even call it 'var' and have it mask the built-in function,
but that's probably a bad idea.

  Ben Bolker

__
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] error message documentation: "Error: no function to return from, jumping to top level"

2008-10-02 Thread Duncan Murdoch

[EMAIL PROTECTED] wrote:

Dear R Users,

Are error messages in R documented somewhere ? I am getting the following 
error message and would like to track down what it means and which 
specific routine triggers it:


Error: no function to return from, jumping to top level

Once I figure out which snippet of code triggers it, I can submit to the 
list a working example in case I cannot get to the bottom of the problem 
myself.
  


There is no listing of error messages other than the source to R.  But 
you can often find where the error happened by using traceback().  
Search Google for "debugging R" for more hints.


Duncan Murdoch

Thanks in advance,
Tolga

Generally, this communication is for informational purposes only
and it is not intended as an offer or solicitation for the purchase
or sale of any financial instrument or as an official confirmation
of any transaction. In the event you are receiving the offering
materials attached below related to your interest in hedge funds or
private equity, this communication may be intended as an offer or
solicitation for the purchase or sale of such fund(s).  All market
prices, data and other information are not warranted as to
completeness or accuracy and are subject to change without notice.
Any comments or statements made herein do not necessarily reflect
those of JPMorgan Chase & Co., its subsidiaries and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
[[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] An AIC model selection question

2008-10-02 Thread Ben Bolker
Uwe Ligges  statistik.tu-dortmund.de> writes:

> 
> 
> Christoph Scherber wrote:
> > Dear R users,
> > 
> > Assume I have three models with the following AIC values:
> > 
> > modelAICdf
> > model1 -102
> > model2-125
> > model3-112
> > 
> > Obviously, model2 would be preferred, but it "wastes" 5 df compared to 
> > the other models.
> > 
> > Would it be allowed to select model3 instead, simply because it uses up 
> > less df and the delta-AIC between model2 and model3 is just 1?
> 
> Well, on the one hand, the degrees of freedom are already part of the 
> AIC calculation. So if you say you really want to apply model selection 
> based on AIC, the answer is `no'.
> On the other hand, AIC is just one possible way to penalize the 
> Likelihood values by the used number of degrees of freedom. You can 
> choose some different criterion, if you think the amount of penalization 
> in AIC is too weak for you.
> 
> Best,
> Uwe Ligges

   (Actually, it looks like model2 only wastes 3 df.)
AIC is telling you that those 3 df are worth it in
terms of improved model fit (and expected predictive
capability). Given that these models are (as you say)
all more or less equivalent in terms of expected
predictive ability, other factors (biological realism,
etc.) *might* come into play. However, you should
be very careful and very explicit when you start
introducing other factors. Especially if the models
tell different stories or have different predictions,
you should consider model-averaging or refusing to
select a single model to describe the data.

  To speak to Uwe's comment, if your data sets are
small you might want to consider "corrected" AIC
(which increases the penalty term for complexity).

  Ben Bolker

__
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] matrix with different type of column [SEC=UNCLASSIFIED]

2008-10-02 Thread John Kane
?data.frame

Lists and data.frames allow mixed components, matrices do not


--- On Thu, 10/2/08, ZHU, Justin <[EMAIL PROTECTED]> wrote:

> From: ZHU, Justin <[EMAIL PROTECTED]>
> Subject: [R] matrix with different type of column [SEC=UNCLASSIFIED]
> To: r-help@r-project.org
> Received: Thursday, October 2, 2008, 1:34 AM
> Hi,
> I would like to create a matrix. Say 5*4.
> The first column is integer, the second column is date, the
> third column
> is character and the rest columns are integers.
> So it's a combination of different types.
> I am wondering how can I do that? "matrix"
> command only allow one type.
> 
>  
> 
> *
> This e-mail message (along with any attachments) is
> intended only for the named addressee and could contain
> information that is confidential or privileged.  If you are
> not the intended recipient you are notified that any
> dissemination, copying or use of any of the information is
> prohibited.  Please notify us immediately by return e-mail
> if you are not the intended recipient and delete all copies
> of the original message and attachments.
> 
> This footnote also confirms that this message has been
> checked for computer viruses.
> 
> *
> 
> 
>   [[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.


  __
[[elided Yahoo spam]]

__
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] Aggregate issues with subset

2008-10-02 Thread John Kane
I don't have R on this machine to check but are you sure that sc_recov still 
exists in s.all?

Otherwise do str(s.all) and see what the object looks like.



--- On Wed, 10/1/08, Michael Just <[EMAIL PROTECTED]> wrote:

> From: Michael Just <[EMAIL PROTECTED]>
> Subject: [R] Aggregate issues with subset
> To: "r-help@r-project.org" 
> Received: Wednesday, October 1, 2008, 6:28 PM
> Hello,
> I used the aggregate function with success on my data frame
> "all".
> 
> > aggregate(all, list(sc_recov), mean)
> 
> I then made a subset of this data frame:
> 
> >s.all <-subset(all, select=
> c(3,4,5,6,7,8,9,10,11,23))
> 
> but when I tried to to run the aggregate function on this
> subset:
> 
> > aggregate(s.all, list(sc_recov), mean)
> 
> The result is garbage (i.e. its not grouping the data). So
> then I took my
> "all.csv", removed the unwanted columns and
> imported it into R as "small".
> 
> > aggregate(small, list(sc_recov), mean)
> Error in FUN(X[[1L]], ...) : arguments must have same
> length
> 
> Any thoughts?
> 
> Thank you kindly,
> M Just
> 
>   [[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.


  __
[[elided Yahoo spam]]

__
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] Problem with read.table()

2008-10-02 Thread Gabor Grothendieck
Did you try skipping the header as one respondent mentioned?
read.table(..., skip = 1, header = FALSE)

On Thu, Oct 2, 2008 at 9:05 AM, Joan-Josep Vallbé <[EMAIL PROTECTED]> wrote:
> Hi, I've done ?count.fields and it helped me identify a blank space that I
> had not noticed (thanks!), but when I try to upload the table again with
>
> ayuso <- read.table("/Users/user/Rwork/ayusotriada.txt", header=TRUE,
> sep="\t", na.strings="NA", dec=".", strip.white=TRUE)
>
> or with read.delim, the error message "Error with make.names(col.names,
> unique =
>>
>>> TRUE) :
>>> string multibyte 187 invalid
>
> still appears. thanks!
>
>
>
> On 02/10/2008, at 14:30, Gabor Grothendieck wrote:
>
>> Look at ?count.fields to diagnose this.
>>
>> On Thu, Oct 2, 2008 at 8:05 AM, Joan-Josep Vallbé <[EMAIL PROTECTED]>
>> wrote:
>>>
>>> Hi, I've tried it with read.delim:
>>>
>>> ayuso <- read.delim("/Users/user/Rwork/ayusotriada.txt")
>>>
>>> and now the error message is "Error with make.names(col.names, unique =
>>> TRUE) :
>>> string multibyte 187 invalid"
>>>
>>> thanks!
>>>
>>>
>>>
>>> On 02/10/2008, at 12:21, Joan-Josep Vallbé wrote:
>>>
 Hello everybody,

 I'm a new user and I'm trying to use read.table with a tab delimited
 file but the system tells me (i) that there are more columns than
 column names, and (ii) that headers and col.names are of different
 lengths. I have already checked my variable names and there's no blank
 spaces. However, some variables have quite long names such as
 "valoracion.experiencias.segundo.year". Could it be the problem? If
 that is the case, I still don't understand why I have more columns
 that column names. Could anyone help me with that?

 Thank you very much!


 Joan-Josep Vallbé
 Institute of Law and Technology
 Political Science Department
 Autonomous University of Barcelona (UAB)
 [EMAIL PROTECTED]






  [[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.
>>>
>>> Joan-Josep Vallbé
>>> Institute of Law and Technology
>>> Political Science Department
>>> Autonomous University of Barcelona (UAB)
>>> [EMAIL PROTECTED]
>>>
>>> __
>>> 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.
>>>
>
> Joan-Josep Vallbé
> Institute of Law and Technology
> Political Science Department
> Autonomous University of Barcelona (UAB)
> [EMAIL PROTECTED]
>
>
>
>
>
>

__
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] error message documentation: "Error: no function to return from, jumping to top level"

2008-10-02 Thread Peter Dalgaard
Duncan Murdoch wrote:
> [EMAIL PROTECTED] wrote:
>> Dear R Users,
>>
>> Are error messages in R documented somewhere ? I am getting the
>> following error message and would like to track down what it means
>> and which specific routine triggers it:
>>
>> Error: no function to return from, jumping to top level
>>
>> Once I figure out which snippet of code triggers it, I can submit to
>> the list a working example in case I cannot get to the bottom of the
>> problem myself.
>>   
>
> There is no listing of error messages other than the source to R.  But
> you can often find where the error happened by using traceback(). 
> Search Google for "debugging R" for more hints.
The easiest way to get that message is to execute return() from the top
level:

> return(1)
Error: no function to return from, jumping to top level

so a good guess is that you (Tolga) might be trying to return() from
source()d file. Or maybe source()ing something that was intended to be
inside a function body (extraneous '}' characters can do that).

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
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] error message documentation: "Error: no function to return from, jumping to top level"

2008-10-02 Thread tolga . i . uzuner
Many thanks, that is very helpful Peter.
Regards,
Tolga




Peter Dalgaard <[EMAIL PROTECTED]> 
02/10/2008 14:24

To
Duncan Murdoch <[EMAIL PROTECTED]>
cc
[EMAIL PROTECTED], r-help@r-project.org
Subject
Re: [R] error message documentation: "Error: no function to return from, 
jumping to top level"






Duncan Murdoch wrote:
> [EMAIL PROTECTED] wrote:
>> Dear R Users,
>>
>> Are error messages in R documented somewhere ? I am getting the
>> following error message and would like to track down what it means
>> and which specific routine triggers it:
>>
>> Error: no function to return from, jumping to top level
>>
>> Once I figure out which snippet of code triggers it, I can submit to
>> the list a working example in case I cannot get to the bottom of the
>> problem myself.
>> 
>
> There is no listing of error messages other than the source to R.  But
> you can often find where the error happened by using traceback(). 
> Search Google for "debugging R" for more hints.
The easiest way to get that message is to execute return() from the top
level:

> return(1)
Error: no function to return from, jumping to top level

so a good guess is that you (Tolga) might be trying to return() from
source()d file. Or maybe source()ing something that was intended to be
inside a function body (extraneous '}' characters can do that).

-- 
   O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907






Generally, this communication is for informational purposes only
and it is not intended as an offer or solicitation for the purchase
or sale of any financial instrument or as an official confirmation
of any transaction. In the event you are receiving the offering
materials attached below related to your interest in hedge funds or
private equity, this communication may be intended as an offer or
solicitation for the purchase or sale of such fund(s).  All market
prices, data and other information are not warranted as to
completeness or accuracy and are subject to change without notice.
Any comments or statements made herein do not necessarily reflect
those of JPMorgan Chase & Co., its subsidiaries and affiliates.

This transmission may contain information that is privileged,
confidential, legally privileged, and/or exempt from disclosure
under applicable law. If you are not the intended recipient, you
are hereby notified that any disclosure, copying, distribution, or
use of the information contained herein (including any reliance
thereon) is STRICTLY PROHIBITED. Although this transmission and any
attachments are believed to be free of any virus or other defect
that might affect any computer system into which it is received and
opened, it is the responsibility of the recipient to ensure that it
is virus free and no responsibility is accepted by JPMorgan Chase &
Co., its subsidiaries and affiliates, as applicable, for any loss
or damage arising in any way from its use. If you received this
transmission in error, please immediately contact the sender and
destroy the material in its entirety, whether in electronic or hard
copy format. Thank you.
Please refer to http://www.jpmorgan.com/pages/disclosures for
disclosures relating to UK legal entities.
[[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 with aggregation

2008-10-02 Thread Michael Pearmain
Hi All,
I seem to be having a few troubles with aggregating data back onto the the
dataframe,
I want to take the max value of a user, and then apply this max value back
against all id's that match (i.e a one to many matching)
Can anyone offer any advice?  is there a better way of doing this?
Dummy data and code are listed below:-

dataset is called Mcookie

user_idc_we_conversion
1 1
1 0
1 0
2 1
2 1
3 0
3 0

new data

user_idc_we_conversionc_we_conversion
1 1  1
1 0  1
1 0  1
2 1  1
2 1  1
3 0  0
3 0  0

library(Hmisc)
myAgg<-summarize(Mcookie$c_we_conversion, by=Mcookie$user_id, FUN=max,
na.rm=TRUE)
names(myAgg)<- c("user_id","c_we_converter")
Mcookie <- merge(Mcookie, myAgg, by.x = "user_id", by.y = "user_id")


Thanks in advance,

Mike

[[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] Problem with read.table()

2008-10-02 Thread Joan-Josep Vallbé
Sorry, I didn't, and removing the first row it effectively works.  
Thank you very much for your help.


On 02/10/2008, at 15:20, Gabor Grothendieck wrote:


Did you try skipping the header as one respondent mentioned?
read.table(..., skip = 1, header = FALSE)

On Thu, Oct 2, 2008 at 9:05 AM, Joan-Josep Vallbé  
<[EMAIL PROTECTED]> wrote:
Hi, I've done ?count.fields and it helped me identify a blank space  
that I
had not noticed (thanks!), but when I try to upload the table again  
with


ayuso <- read.table("/Users/user/Rwork/ayusotriada.txt", header=TRUE,
sep="\t", na.strings="NA", dec=".", strip.white=TRUE)

or with read.delim, the error message "Error with  
make.names(col.names,

unique =



TRUE) :
string multibyte 187 invalid


still appears. thanks!



On 02/10/2008, at 14:30, Gabor Grothendieck wrote:


Look at ?count.fields to diagnose this.

On Thu, Oct 2, 2008 at 8:05 AM, Joan-Josep Vallbé <[EMAIL PROTECTED] 
>

wrote:


Hi, I've tried it with read.delim:

ayuso <- read.delim("/Users/user/Rwork/ayusotriada.txt")

and now the error message is "Error with make.names(col.names,  
unique =

TRUE) :
string multibyte 187 invalid"

thanks!



On 02/10/2008, at 12:21, Joan-Josep Vallbé wrote:


Hello everybody,

I'm a new user and I'm trying to use read.table with a tab  
delimited

file but the system tells me (i) that there are more columns than
column names, and (ii) that headers and col.names are of different
lengths. I have already checked my variable names and there's no  
blank

spaces. However, some variables have quite long names such as
"valoracion.experiencias.segundo.year". Could it be the problem?  
If

that is the case, I still don't understand why I have more columns
that column names. Could anyone help me with that?

Thank you very much!


Joan-Josep Vallbé
Institute of Law and Technology
Political Science Department
Autonomous University of Barcelona (UAB)
[EMAIL PROTECTED]






[[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.


Joan-Josep Vallbé
Institute of Law and Technology
Political Science Department
Autonomous University of Barcelona (UAB)
[EMAIL PROTECTED]

__
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.



Joan-Josep Vallbé
Institute of Law and Technology
Political Science Department
Autonomous University of Barcelona (UAB)
[EMAIL PROTECTED]








__
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.


Joan-Josep Vallbé
Institute of Law and Technology
Political Science Department
Autonomous University of Barcelona (UAB)
[EMAIL PROTECTED]

__
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] Help with aggregation

2008-10-02 Thread Hans Gardfjell
See ?ave (in package stats)

/hans

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Michael Pearmain
Sent: den 2 oktober 2008 15:28
To: r-help@r-project.org
Subject: [R] Help with aggregation

Hi All,
I seem to be having a few troubles with aggregating data back onto the the
dataframe,
I want to take the max value of a user, and then apply this max value back
against all id's that match (i.e a one to many matching)
Can anyone offer any advice?  is there a better way of doing this?
Dummy data and code are listed below:-

dataset is called Mcookie

user_idc_we_conversion
1 1
1 0
1 0
2 1
2 1
3 0
3 0

new data

user_idc_we_conversionc_we_conversion
1 1  1
1 0  1
1 0  1
2 1  1
2 1  1
3 0  0
3 0  0

library(Hmisc)
myAgg<-summarize(Mcookie$c_we_conversion, by=Mcookie$user_id, FUN=max,
na.rm=TRUE)
names(myAgg)<- c("user_id","c_we_converter")
Mcookie <- merge(Mcookie, myAgg, by.x = "user_id", by.y = "user_id")


Thanks in advance,

Mike

[[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] Time conversion

2008-10-02 Thread Michael Pearmain
I'm trying to convert a variable that is imported from CSV into a datetime,I'm
trying to use the strptime function but with no joy, can anyone offer any
advise?

i have a vector
timestamp
07-07-2008-21:03:55
07-07-2008-19:52:55
07-07-2008-19:54:14
07-07-2008-15:24:01
07-07-2008-13:39:17
07-07-2008-13:39:55


timestamp<-strptime(timestamp,"%d-%m-%y-%H:%M:%S")
## then filter on the datetime
time<-ifelse(timestamp> "07-08-2008-00:00:00", TRUE, FALSE)



-- 
Michael Pearmain
Senior Statistical Analyst


Google UK Ltd
Belgrave House
76 Buckingham Palace Road
London SW1W 9TQ
United Kingdom
t +44 (0) 2032191684
[EMAIL PROTECTED]

If you received this communication by mistake, please don't forward it to
anyone else (it may contain confidential or privileged information), please
erase all copies of it, including all attachments, and please let the sender
know it went to the wrong person. 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] non-mouse-sensitive pause between showing plots

2008-10-02 Thread Jaan Vajakas
Hello,

I am using R version 2.7.2 on Windows. I would like to create a script
that draws many plots and pauses before drawing a new plot, so that I
could copy each plot consecutively to clipboard ("Copy as metafile" from
context menu) or save it to a file ("Save as metafile" from context
menu).

I know that par(ask=TRUE) or devAskNewPage(TRUE) can be used to achieve
something like that, but unfortunately they also accept mouse click as a
confirmation by the user, so that I cannot use the right mouse button to
open the context menu.

Using readline() is also not a good idea because when I execute the
script with Ctrl-R, readline() just eats the subsequent line in the
script instead of waiting until the user presses  (See e.g. post
http://tolstoy.newcastle.edu.au/R/help/04/11/8089.html which also says
that pause() in package DAAG has similar behaviour because it uses uses
readline()).

I would be satisfied if devAskNewPage had an option that asking new page
would accept keyboard input only, e.g. devAskNewPage("keyboardOnly").


Jaan

__
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] Time conversion

2008-10-02 Thread Richard . Cotton
> I'm trying to convert a variable that is imported from CSV into a 
datetime,I'm
> trying to use the strptime function but with no joy, can anyone offer 
any
> advise?
> 
> i have a vector
> timestamp
> 07-07-2008-21:03:55
> 07-07-2008-19:52:55
> 07-07-2008-19:54:14
> 07-07-2008-15:24:01
> 07-07-2008-13:39:17
> 07-07-2008-13:39:55
> 
> 
> timestamp<-strptime(timestamp,"%d-%m-%y-%H:%M:%S")
> ## then filter on the datetime
> time<-ifelse(timestamp> "07-08-2008-00:00:00", TRUE, FALSE)

1. Since the years are of the form , your format vector should be 
"%d-%m-%Y-%H:%M:%S".

2. You don't need the ifelse call if you the last two arguments are just 
TRUE, FALSE

3. You do need to call strptime on your comparision date.

timestamp <- c("07-07-2008-21:03:55",
   "07-07-2008-19:52:55",
   "07-07-2008-19:54:14",
   "07-07-2008-15:24:01",
   "07-07-2008-13:39:17",
   "07-07-2008-13:39:55")
timestamp <- strptime(timestamp,"%d-%m-%Y-%H:%M:%S")
time <- timestamp > strptime("07-08-2008-00:00:00","%d-%m-%Y-%H:%M:%S")

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
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] non-mouse-sensitive pause between showing plots

2008-10-02 Thread Richard . Cotton
> I am using R version 2.7.2 on Windows. I would like to create a script
> that draws many plots and pauses before drawing a new plot, so that I
> could copy each plot consecutively to clipboard ("Copy as metafile" from
> context menu) or save it to a file ("Save as metafile" from context
> menu).
> 
> I know that par(ask=TRUE) or devAskNewPage(TRUE) can be used to achieve
> something like that, but unfortunately they also accept mouse click as a
> confirmation by the user, so that I cannot use the right mouse button to
> open the context menu.
> 
> Using readline() is also not a good idea because when I execute the
> script with Ctrl-R, readline() just eats the subsequent line in the
> script instead of waiting until the user presses  (See e.g. post
> http://tolstoy.newcastle.edu.au/R/help/04/11/8089.html which also says
> that pause() in package DAAG has similar behaviour because it uses uses
> readline()).
> 
> I would be satisfied if devAskNewPage had an option that asking new page
> would accept keyboard input only, e.g. devAskNewPage("keyboardOnly").

You can use Sys.sleep to pause, but you may be better off writing the 
plots to file directly, rather than having to interact with them, e.g.

win.metafile("myplot.wmf")
plot(1:10)
dev.off()

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential inform...{{dropped:20}}

__
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] nls with plinear and function on RHS

2008-10-02 Thread Katharine Mullen
a) you should put values for Ca, Cb, Cc directly into the data list as
data=list(Ca=1, 

b) you can simplify the call to

# idealised data set
aDF <- data.frame( x= c(1.80, 9.27, 6.48, 2.61, 9.86, 5.93, 6.76, 5.52,
6.06, 8.62),
y= c(24.77, 2775.07, 895.15, 60.73, 3373.57, 677.82, 1021.92, 542.84,
725.25, 2200.04))

bFunc <- function(x, Cd) cbind(Ca=1,Cb=x, Cc=x^Cd)

# nls, plinear algorithm, RHS from function
nls(y ~ bFunc(x, Cd), data=list(x=aDF$x, y=aDF$y),
start=list(Cd=3), algorithm="plinear")

On Thu, 2 Oct 2008, Keith Jewell wrote:

> Dear R gurus,
>
> As part of finding initial values for a much more complicated fit I want to
> fit a function of the form y ~ a + bx + cx^d to fairly "noisy" data and have
> hit some problems.
>
> To demonstrate the specific R-related problem, here is an idealised data
> set, smaller and better fitting than reality:
> # idealised data set
> aDF <- data.frame( x= c(1.80, 9.27, 6.48, 2.61, 9.86, 5.93, 6.76, 5.52,
> 6.06, 8.62),
> y= c(24.77, 2775.07, 895.15, 60.73, 3373.57, 677.82, 1021.92, 542.84,
> 725.25, 2200.04))
>
> And here are some starting values, far better than I'd have in reality
> # good starting values
> startL <- list(Ca=4, Cb=3, Cc=3, Cd=3)
>
> In these idealised circumstances nls converges using the default algorithm.
> # nls, default algorithm
> nls(y ~ Ca + Cb*x + Cc*x^Cd, data=aDF, start=startL)
>
> Unfortunately, in reality it often fails to converge. This model is linear
> in a, b and c so I've used the plinear algorithm.
> # nls, plinear algorithm, explicit RHS
> nls(y ~ cbind(Ca=1,Cb=x, Cc=x^Cd), data=aDF, start=startL["Cd"],
> algorithm="plinear")
>
> This converges much more often but sometimes crashes with the error message
> "Error in numericDeriv(form[[3]], names(ind), env) :
>   Missing value or an infinity produced when evaluating the model"
>
> I deduce that it is failing in the numerical differentiation of x^Cd (but
> don't know why), so I thought I'd avoid the numerical differentiation by
> putting the RHS in a function to which I could (later) add a 'gradient'
> attribute
> # function to provide RHS
> bFunc <- function(x, Ca, Cb, Cc, Cd) cbind(Ca=1,Cb=x, Cc=x^Cd)
>
> # nls, plinear algorithm, RHS from function
> nls(y ~ bFunc(x, Ca, Cb, Cc, Cd), data=aDF, start=startL["Cd"],
> algorithm="plinear")
>
> However, this gives me
> "Error in nls(y ~ bFunc(x, Ca, Cb, Cc, Cd), data = aDF, start =
> startL["Cd"],  :
>   parameters without starting value in 'data': Ca, Cb, Cc"
>
> Can anyone tell me
> a) why putting the RHS into a function "broke" the plinear algorithm
> b) if there's a better approach to my problem
>
> Thanks in advance,
>
> Keith Jewell
> -
> I'm using V2.7.2...
> > sessionInfo()
> R version 2.7.2 (2008-08-25)
> i386-pc-mingw32
>
> locale:
> LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
> Kingdom.1252;LC_MONETARY=English_United
> Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252
>
> attached base packages:
> [1] stats graphics  grDevices datasets  tcltk utils methods
> base
>
> other attached packages:
> [1] xlsReadWrite_1.3.2 svSocket_0.9-5 TinnR_1.0.2R2HTML_1.59
> Hmisc_3.4-3
>
> loaded via a namespace (and not attached):
> [1] cluster_1.11.11 grid_2.7.2  lattice_0.17-14 svMisc_0.9-5
> VGAM_0.7-7
>
> ... but have also tried todays V2.7.2 patched and V2.8.0alpha, both of which
> give the same behaviour
>
> __
> 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] specifying x-axis scale on random forest variable importance plot

2008-10-02 Thread A Van Dyke

i am new to R and using the random forest package.  is there a way to specify
the x-axis scale range for the variable importance plot?  many thanks.

-alison
-- 
View this message in context: 
http://www.nabble.com/specifying-x-axis-scale-on-random-forest-variable-importance-plot-tp19780560p19780560.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] fft inverse display help

2008-10-02 Thread rkevinburton
My question is how does 'plot' know to implicilty call the plot.ts (in the case 
of the full "exact" spectrum being fed back into the inverse?

Kevin

 Dieter Menne <[EMAIL PROTECTED]> wrote: 
>   charter.net> writes:
> 
> > 
> > ff <- complex(length(fs))
> > ff[9] <- fs[9]
> > ff[5] <- fs[5]
> > 
> > Include the DC component:
> > 
> > ff[1] <- fs[1]
> > 
> > Take the inverse
> > 
> > fi <- fft(ff, inverse=TRUE) / length(ff)
> > 
> > Plot
> > 
> > plot(fi)
> > 
> > Notice that the plot is the Re vs. Im on the x and y axis' respectively.
> 
> In one case, you plot a complex vector (gives points in complex plane), in the
> other case a time series, where default assumption with a warning is to plot 
> the
> real part only.
> 
> Try 
> 
> plot(as.ts(fi))
> 
> and you see the latter, where implicitely plot.ts is called.
> 
> Dieter
> 
> __
> 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] fft inverse display help

2008-10-02 Thread Dieter Menne
  charter.net> writes:

> 
> My question is how does 'plot' know to implicilty call the plot.ts (in the
case of the full "exact" spectrum
> being fed back into the inverse?

So the title should be "How does the specific incarnation of object orientation
in R work?" Try, for example, section 3.4 and the "generic" classes in the
R-intro.pdf

Dieter

__
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] Running source() on a file in another directory

2008-10-02 Thread Gang Chen
Thanks a lot! It seems to work fine now with what you suggested. I
also tried another approach by running the following on the terminal

R -f ~dir1/prog.R

and it read in some lines in prog.R, but then the execution halted at
one point for some reason I could not figure out. Any way I could get
"R -f ..." working?

Thanks,
Gang


On Wed, Oct 1, 2008 at 11:49 PM, Gabor Grothendieck
<[EMAIL PROTECTED]> wrote:
> Suppose p is a vector of paths, e.g., p <- c("~/dir1", "~/dir2/dir3")
> Then the following will return the full pathname of the first found
> location:
>
>   Find(file.exists, file.path(p, "prog.R"))
>
> so you can source that.
>
> On Wed, Oct 1, 2008 at 6:09 PM, Gang Chen <[EMAIL PROTECTED]> wrote:
>> Suppose I have a file prog.R stored in a directory under ~/dirname,
>> and ~/dirname is set in a shell script file (e.g. .cshrc) as one of
>> the accessible paths on terminal. On a different directory I could run
>> prog.R interactively by executing
>>
>> source("~/dirname/prog.R")
>>
>> It seems that source() does not search for all the paths set in the
>> shell script. So, is there a better and more elegant way to do this,
>> for example without explicitly typing the directory?
>>
>> TIA,
>> Gang

__
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] namespaces

2008-10-02 Thread Alexy Khrabrov
I'd like to control my namespace thoroughly, separated by task.  Is  
there a way, in R session, to introduce namespaces for tasks  
dynamically and switch them as needed?  Or, is there a combination of  
load/save workspace steps which can facilitate this?


Cheers,
Alexy

__
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] [solutions] "tapply versus by" in function with more than 1 arguments

2008-10-02 Thread Cézar Freitas
Thanks to all.
I summarized (in order to thank the list) the solutions to help future workers 
searching subjects like this at R help.
 
# Number of rows
nr = 10
# Data set
dataf = 
as.data.frame(matrix(c(rnorm(nr),rnorm(nr)*2,runif(nr),sort(c(1,1,2,2,3,3,sample(1:3,nr-6,replace=TRUE,ncol=4))
names(dataf)[4] = "class"
#-
#Solution 1:
#works, but need space to allocate the new data: splidata
 
# Splitting your data
splitdata = split(dataf,dataf$class)
# Correlations
correl=lapply(splitdata,function(x) cor.test(x[,1],x[,2])$estimate)
res=do.call(c,correl)
names(res)=paste('class',unique(dataf[,4]),sep="")
res

#-
#Solution 2:
sapply(by(dataf[,c("V1","V2")], dataf$class, cor), '[', 3)
 
#works, and I can specify parameters like
sapply(by(dataf[,c("V1","V2")], dataf$class, cor, method="pearson"), '[', 3)

#-
#Solution(s) 3:
tapply(rownames(dataf), dataf$class, function(r) cor(dataf[r, "V1"],dataf[r, 
"V2"]))
#or tapply(rownames(dataf), dataf$class, function(r) with(dataf[r, ], cor(V1, 
V2)))
 
#works good; I can directly specify parameters at "function()" like
tapply(rownames(dataf), dataf$class, function(r) with(dataf[r, ], cor(V1, V2, 
method="kendall")))
 
#but, in a 100 thousand rows data, it is TEN times slower than sapply (I 
surprised)
#note that tapply(rownames(dataf), dataf$class, function(r) with(dataf[r, ], 
cor(V1, V2))) is SIX times slower than sapply

#-
#Solution(s) 4:
install.packages("plyr")
library(plyr)
 
ddply(dataf, .(class), function(df) data.frame(cor(df[, 1:2])))
daply(dataf, .(class), function(df) cor(df[, 1:2]))
dlply(dataf, .(class), function(df) cor(df[, 1:2]))
 
#Interesting library, but not good to my example - I need a vector with results 
#[only cor(V1,V2) and not cor(V1,V1)], that is, I don't want rectangular objects



  Novos endereços, o Yahoo! que você conhece. Crie um email novo com a sua 
cara @ymail.com ou @rocketmail.com.
http://br.new.mail.yahoo.com/addresses
[[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] SAS enterprise guide in R?

2008-10-02 Thread Hanek Martin
Hello,

Our company has been looking at "SAS enterprise guide 4" (Insightful Miner is a 
similar product from Insightful, I believe) which seems to provide a nice 
graphical way of displaying/managing a process or project. It is also 
accessible to non-programmers.

Does any of the R GUIs provide similar functionality please? Can you point me 
in the right direction?

Thanks in advance

Best Regards


___
Martin Hanek
Actuary
[EMAIL PROTECTED]

Glacier Group
+
Churerstrasse 78
8808 Pfäffikon SZ
Switzerland
www.GlacierGroup.com
T: +41 (0)55 417 3431 | F: +41 (0)55 417 3434 | M: +41 (0)79 833 3431
___
This e-mail, including any attachments, is for the inten...{{dropped:11}}

__
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] namespaces

2008-10-02 Thread Alexy Khrabrov
Yes, I could prefix everything with taskN$, but that's boring!  Can I  
now attach and detach tasks to have one prefix-less, since they look  
like dataframes?  What does proto buy us?


To respond to Uwe here as well, I want dynamic task switching and  
*also* an ability to load and save task from their workspaces into  
their namespaces in the same R session.


Cheers,
Alexy

On Oct 2, 2008, at 11:19 AM, Gabor Grothendieck wrote:


You could have an environment for each task and place your objects for
each task in its environment.

Note that this is getting close to object oriented ideas where each
enviroment/task
is an object containing your R variables and methods and the proto  
package

can be used to facilitate that:

library(proto)
task1 <- proto(var = 0, addx = function(this, x) this$var <- this 
$var + x)

task1$var # 0
task1$addx(3)
task1$var # 3

On Thu, Oct 2, 2008 at 11:03 AM, Alexy Khrabrov  
<[EMAIL PROTECTED]> wrote:
I'd like to control my namespace thoroughly, separated by task.  Is  
there a
way, in R session, to introduce namespaces for tasks dynamically  
and switch
them as needed?  Or, is there a combination of load/save workspace  
steps

which can facilitate this?

Cheers,
Alexy

__
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] namespaces

2008-10-02 Thread Gabor Grothendieck
You could have an environment for each task and place your objects for
each task in its environment.

Note that this is getting close to object oriented ideas where each
enviroment/task
is an object containing your R variables and methods and the proto package
can be used to facilitate that:

library(proto)
task1 <- proto(var = 0, addx = function(this, x) this$var <- this$var + x)
task1$var # 0
task1$addx(3)
task1$var # 3

On Thu, Oct 2, 2008 at 11:03 AM, Alexy Khrabrov <[EMAIL PROTECTED]> wrote:
> I'd like to control my namespace thoroughly, separated by task.  Is there a
> way, in R session, to introduce namespaces for tasks dynamically and switch
> them as needed?  Or, is there a combination of load/save workspace steps
> which can facilitate this?
>
> Cheers,
> Alexy
>
> __
> 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] namespaces

2008-10-02 Thread Uwe Ligges

What you mean is probably that you can have different workspaces.
A Workspace is associated to the current R session and is saved/loaded 
in the directory from which R is started.

Note that Namespaces (for packages) in R have a different meaning.

Best,
Uwe Ligges


Alexy Khrabrov wrote:
I'd like to control my namespace thoroughly, separated by task.  Is 
there a way, in R session, to introduce namespaces for tasks dynamically 
and switch them as needed?  Or, is there a combination of load/save 
workspace steps which can facilitate this?


Cheers,
Alexy

__
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] namespaces

2008-10-02 Thread Duncan Murdoch

On 02/10/2008 11:03 AM, Alexy Khrabrov wrote:
I'd like to control my namespace thoroughly, separated by task.  Is  
there a way, in R session, to introduce namespaces for tasks  
dynamically and switch them as needed?  Or, is there a combination of  
load/save workspace steps which can facilitate this?


"namespace" has a specific meaning in R associated with packages, but I 
think you are using it more generally.


The search() list in R controls what is visible when executing commands 
in the console.  You can attach and detach things from there to control 
visibility.


You can also control the environment of a function, so that searches for 
non-local variables go where you want.


Duncan Murdoch

__
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] namespaces

2008-10-02 Thread Gabor Grothendieck
On Thu, Oct 2, 2008 at 11:26 AM, Alexy Khrabrov <[EMAIL PROTECTED]> wrote:
> Yes, I could prefix everything with taskN$, but that's boring!  Can I now
> attach and detach tasks to have one prefix-less, since they look like
> dataframes?

Read the proto vignette and other info to get a better understanding
of the prototype model
of object oriented programming.  See the home page at
http://r-proto.googlecode.com

Certainly one can attach and detach objects although its not clear
whether that is
desirable or its effect on delegation/inheritance (if you use those
facilities).  If you
are going to use them simply as modules then it would likely be ok:

attach(task1)
var
detach(task1)

> What does proto buy us?

What do namespaces buy us?  Namespaces are environments and so
are proto objects.  proto objects give you the facitilites of object oriented
programming including delegation (like inheritance) although based on
your description you only intend to  use them as modules (but if you
think about your modules as objects the OO approach might further simplify
and organize your project).

>
> To respond to Uwe here as well, I want dynamic task switching and *also* an
> ability to load and save task from their workspaces into their namespaces in
> the same R session.
>
> Cheers,
> Alexy
>
> On Oct 2, 2008, at 11:19 AM, Gabor Grothendieck wrote:
>
>> You could have an environment for each task and place your objects for
>> each task in its environment.
>>
>> Note that this is getting close to object oriented ideas where each
>> enviroment/task
>> is an object containing your R variables and methods and the proto package
>> can be used to facilitate that:
>>
>> library(proto)
>> task1 <- proto(var = 0, addx = function(this, x) this$var <- this$var + x)
>> task1$var # 0
>> task1$addx(3)
>> task1$var # 3
>>
>> On Thu, Oct 2, 2008 at 11:03 AM, Alexy Khrabrov <[EMAIL PROTECTED]>
>> wrote:
>>>
>>> I'd like to control my namespace thoroughly, separated by task.  Is there
>>> a
>>> way, in R session, to introduce namespaces for tasks dynamically and
>>> switch
>>> them as needed?  Or, is there a combination of load/save workspace steps
>>> which can facilitate this?
>>>
>>> Cheers,
>>> Alexy
>>>
>>> __
>>> 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] nls with plinear and function on RHS

2008-10-02 Thread Keith Jewell
Wonderful, great! That solves my problem nicely (on to the next one!).

Thanks a lot,

Keith Jewell
"Katharine Mullen" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> a) you should put values for Ca, Cb, Cc directly into the data list as
> data=list(Ca=1, 
>
> b) you can simplify the call to
>
> # idealised data set
> aDF <- data.frame( x= c(1.80, 9.27, 6.48, 2.61, 9.86, 5.93, 6.76, 5.52,
> 6.06, 8.62),
> y= c(24.77, 2775.07, 895.15, 60.73, 3373.57, 677.82, 1021.92, 542.84,
> 725.25, 2200.04))
>
> bFunc <- function(x, Cd) cbind(Ca=1,Cb=x, Cc=x^Cd)
>
> # nls, plinear algorithm, RHS from function
> nls(y ~ bFunc(x, Cd), data=list(x=aDF$x, y=aDF$y),
>start=list(Cd=3), algorithm="plinear")
>
> On Thu, 2 Oct 2008, Keith Jewell wrote:
>
>> Dear R gurus,
>>
>> As part of finding initial values for a much more complicated fit I want 
>> to
>> fit a function of the form y ~ a + bx + cx^d to fairly "noisy" data and 
>> have
>> hit some problems.
>>
>> To demonstrate the specific R-related problem, here is an idealised data
>> set, smaller and better fitting than reality:
>> # idealised data set
>> aDF <- data.frame( x= c(1.80, 9.27, 6.48, 2.61, 9.86, 5.93, 6.76, 5.52,
>> 6.06, 8.62),
>> y= c(24.77, 2775.07, 895.15, 60.73, 3373.57, 677.82, 1021.92, 542.84,
>> 725.25, 2200.04))
>>
>> And here are some starting values, far better than I'd have in reality
>> # good starting values
>> startL <- list(Ca=4, Cb=3, Cc=3, Cd=3)
>>
>> In these idealised circumstances nls converges using the default 
>> algorithm.
>> # nls, default algorithm
>> nls(y ~ Ca + Cb*x + Cc*x^Cd, data=aDF, start=startL)
>>
>> Unfortunately, in reality it often fails to converge. This model is 
>> linear
>> in a, b and c so I've used the plinear algorithm.
>> # nls, plinear algorithm, explicit RHS
>> nls(y ~ cbind(Ca=1,Cb=x, Cc=x^Cd), data=aDF, start=startL["Cd"],
>> algorithm="plinear")
>>
>> This converges much more often but sometimes crashes with the error 
>> message
>> "Error in numericDeriv(form[[3]], names(ind), env) :
>>   Missing value or an infinity produced when evaluating the model"
>>
>> I deduce that it is failing in the numerical differentiation of x^Cd (but
>> don't know why), so I thought I'd avoid the numerical differentiation by
>> putting the RHS in a function to which I could (later) add a 'gradient'
>> attribute
>> # function to provide RHS
>> bFunc <- function(x, Ca, Cb, Cc, Cd) cbind(Ca=1,Cb=x, Cc=x^Cd)
>>
>> # nls, plinear algorithm, RHS from function
>> nls(y ~ bFunc(x, Ca, Cb, Cc, Cd), data=aDF, start=startL["Cd"],
>> algorithm="plinear")
>>
>> However, this gives me
>> "Error in nls(y ~ bFunc(x, Ca, Cb, Cc, Cd), data = aDF, start =
>> startL["Cd"],  :
>>   parameters without starting value in 'data': Ca, Cb, Cc"
>>
>> Can anyone tell me
>> a) why putting the RHS into a function "broke" the plinear algorithm
>> b) if there's a better approach to my problem
>>
>> Thanks in advance,
>>
>> Keith Jewell
>> -
>> I'm using V2.7.2...
>> > sessionInfo()
>> R version 2.7.2 (2008-08-25)
>> i386-pc-mingw32
>>
>> locale:
>> LC_COLLATE=English_United Kingdom.1252;LC_CTYPE=English_United
>> Kingdom.1252;LC_MONETARY=English_United
>> Kingdom.1252;LC_NUMERIC=C;LC_TIME=English_United Kingdom.1252
>>
>> attached base packages:
>> [1] stats graphics  grDevices datasets  tcltk utils methods
>> base
>>
>> other attached packages:
>> [1] xlsReadWrite_1.3.2 svSocket_0.9-5 TinnR_1.0.2R2HTML_1.59
>> Hmisc_3.4-3
>>
>> loaded via a namespace (and not attached):
>> [1] cluster_1.11.11 grid_2.7.2  lattice_0.17-14 svMisc_0.9-5
>> VGAM_0.7-7
>>
>> ... but have also tried todays V2.7.2 patched and V2.8.0alpha, both of 
>> which
>> give the same behaviour
>>
>> __
>> 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.


[R] combining bar and line plots with multiple axes

2008-10-02 Thread Schreiber, Stefan
Hey list,

I have a barplot with a line plot overlayed (on the 2nd  y axis) and it
looks fine except that the origin (0) on the 2nd  y axis (side=4) is not
lining up with the origin on the 1st y-axis (side=2, from the barplot).
Is there a way to either shift the 2nd y-axis (line plot) down or
readjust the barplot axis?

Just as a reference, here is the code:

barplot2(temp$precip, names.arg=temp$year, ylim=c(0,300),axes=F)
axis(2)
par(new=T)
plot(temp$year, temp$mat, axes=F, type="l", ylim=(0,25))
axis(4)


Thanks!!

Stefan

[[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] namespaces

2008-10-02 Thread Greg Snow
Here is what I do:

I have a different folder/directory for each of my different projects, then I 
start a new R session for each project that I am working on.  If you start R 
with the folder/directory as the current working directory then the workspace 
for that project is loaded (and the script files in that directory show up when 
I want to load them).  This means that I often have multiple copies of R 
running at the same time (which works fine), and switching between the projects 
just means switching which R window I am in.  The workspace saving between 
sessions pretty much takes care of itself (but still keep the script files to 
recreate data if needed).

If you are using windows, then the website:
http://research.stowers-institute.org/efg/R/TechNote/WindowsExplorerWorkingDirectory/index.htm

shows a way to set up windows so that you can run R from a given folder using a 
right click.

  I also have the line:

utils::setWindowTitle(getwd())

in my .Rprofile so that the working folder name shows up in the window title.

Not exactly what you asked for, but it works well for me.  Hope it helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Alexy Khrabrov
> Sent: Thursday, October 02, 2008 9:03 AM
> To: [EMAIL PROTECTED]
> Subject: [R] namespaces
>
> I'd like to control my namespace thoroughly, separated by task.  Is
> there a way, in R session, to introduce namespaces for tasks
> dynamically and switch them as needed?  Or, is there a combination of
> load/save workspace steps which can facilitate this?
>
> Cheers,
> Alexy
>
> __
> 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] combining bar and line plots with multiple axes

2008-10-02 Thread Greg Snow
The updateusr function in the TeachingDemos package can be used to change the 
user coordinates of the current plot and may do what you want.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


> -Original Message-
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> project.org] On Behalf Of Schreiber, Stefan
> Sent: Thursday, October 02, 2008 10:04 AM
> To: r-help@r-project.org
> Subject: [R] combining bar and line plots with multiple axes
>
> Hey list,
>
> I have a barplot with a line plot overlayed (on the 2nd  y axis) and it
> looks fine except that the origin (0) on the 2nd  y axis (side=4) is
> not
> lining up with the origin on the 1st y-axis (side=2, from the barplot).
> Is there a way to either shift the 2nd y-axis (line plot) down or
> readjust the barplot axis?
>
> Just as a reference, here is the code:
>
> barplot2(temp$precip, names.arg=temp$year, ylim=c(0,300),axes=F)
> axis(2)
> par(new=T)
> plot(temp$year, temp$mat, axes=F, type="l", ylim=(0,25))
> axis(4)
>
>
> Thanks!!
>
> Stefan
>
> [[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] spec.pgram help?

2008-10-02 Thread rkevinburton
Hopefully this will not seem too ignorant of a question. I am having a hard 
time picking out the sources of the differences between: 

abs(fft(x))^2/length(x)

and 

spec.pgram(x, taper=0, log="no", plot=FALSE)

Also from the limited testing that I have done since the DC "frequency" is not 
returned from spec.pgram how can I tell what has happened to the series when I 
specify demean = TRUE or detrend = TRUE?

Any help?

Thank you.

Kevin

__
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] namespaces

2008-10-02 Thread Gabor Grothendieck
The trick about setting the windows title is quite nifty and I've just
added that to my profile.

Just wanted to add two additional ways to start up R in the current directory
on Windows.  They are provided in the batchfiles distribution.  See home
page at:
   http://batchfiles.googlecode.com

1. If you tend to work from the Windows console then starting R via the
Rgui.bat command will do it and

2. if you tend to use Windows explorer right clicking a folder, choosing SendTo
and then choosing RguiStart.bat will also do it.

Installing Rgui.bat consists only of copying that file to any folder
on your PATH
and installing RguiStart.bat consists of the single line:

copy RguiStart.bat %APPDATA%\Microsoft\Windows\SendTo

Both Rgui.bat and RguiStart.bat automatically find the current
version of R in the registry which is why there is no additional
setup needed.  More info is in the README.

On Thu, Oct 2, 2008 at 12:11 PM, Greg Snow <[EMAIL PROTECTED]> wrote:
> Here is what I do:
>
> I have a different folder/directory for each of my different projects, then I 
> start a new R session for each project that I am working on.  If you start R 
> with the folder/directory as the current working directory then the workspace 
> for that project is loaded (and the script files in that directory show up 
> when I want to load them).  This means that I often have multiple copies of R 
> running at the same time (which works fine), and switching between the 
> projects just means switching which R window I am in.  The workspace saving 
> between sessions pretty much takes care of itself (but still keep the script 
> files to recreate data if needed).
>
> If you are using windows, then the website:
> http://research.stowers-institute.org/efg/R/TechNote/WindowsExplorerWorkingDirectory/index.htm
>
> shows a way to set up windows so that you can run R from a given folder using 
> a right click.
>
>  I also have the line:
>
> utils::setWindowTitle(getwd())
>
> in my .Rprofile so that the working folder name shows up in the window title.
>
> Not exactly what you asked for, but it works well for me.  Hope it helps,
>
> --
> Gregory (Greg) L. Snow Ph.D.
> Statistical Data Center
> Intermountain Healthcare
> [EMAIL PROTECTED]
> 801.408.8111
>
>
>> -Original Message-
>> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>> project.org] On Behalf Of Alexy Khrabrov
>> Sent: Thursday, October 02, 2008 9:03 AM
>> To: [EMAIL PROTECTED]
>> Subject: [R] namespaces
>>
>> I'd like to control my namespace thoroughly, separated by task.  Is
>> there a way, in R session, to introduce namespaces for tasks
>> dynamically and switch them as needed?  Or, is there a combination of
>> load/save workspace steps which can facilitate this?
>>
>> Cheers,
>> Alexy
>>
>> __
>> 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.


[R] StructTS hang?

2008-10-02 Thread rkevinburton
I was wondering if I could get some advice on how best to diagnose a problem 
that I am having with StructTS. To illlustrate the problem I have generated a 
rigged time series:

genseq <- function()
{
  x <- numeric(4*365)
  s <- seq(as.Date("2005-01-01"), as.Date("2008-12-31"), by="month")
  ob <- as.vector(s[c(10,22,34,46)] - as.Date("2005-01-01"))
  oe <- as.vector(s[c(11,23,35,47)] - as.Date("2005-01-01"))
  for(.index in 1:length(ob))
  {
x[ob[.index]:(oe[.index] - 1)] <- 1 
  }
  return(ts(x, frequency=365))
}


series <- genseq()
series <- ts(c(series, rep(0, nextn(length(series)) - length(series))), 
frequency = 365)
fit <- StructTS(series)
plot(cbind(fitted(fit), resids=resid(fit)), main = "StructTS decomposition")


This call to StructTS seems to hang indefinitely. 

Any ideas?

Thank you.

Kevin

__
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] time segments intersection

2008-10-02 Thread John Kane
help("%in%") may be of use. However I don't see any overlap in your example.


--- On Wed, 10/1/08, [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]> 
wrote:

> From: [Ricardo Rodriguez] Your XEN ICT Team <[EMAIL PROTECTED]>
> Subject: [R] time segments intersection
> To: r-help@r-project.org
> Cc: "Antonio Martinez Cortizas" <[EMAIL PROTECTED]>
> Received: Wednesday, October 1, 2008, 12:48 PM
> Hi all,
> 
> Please, how could I calculate the time that two time
> segments has in 
> common? Is there any function to perform this calculation?
> 
> For instance, given four POSIXlt objects...
> 
> endPeriod<-as.POSIXlt("2008-09-30")
> startPeriod<-as.POSIXlt("2007-10-01")
> endProject<-as.POSIXlt("2007-05-31")
> startProject<-as.POSIXlt("2006-12-01")
> 
> that limit two time segments...
> 
> project <- as.numeric(endProject-startProject)
> period <- as.numeric(endPeriod-startPeriod)
> 
> How could I calculate the time project and period overlap?
> 
> Thanks for your help!
> 
> Ricardo
> 
> 
> 
> -- 
> Ricardo Rodríguez
> Your XEN ICT Team
> 
> __
> 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.


  __
Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your 
favourite sites. Download it now at
http://ca.toolbar.yahoo.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] missing output in summary() and anova()

2008-10-02 Thread Jordan Wong
> y<-c(131.79, 131.79, 135.02, 135.55, 136.46, 136.83, 137.82, 138.00,
138.06, 138.04, 140.04, 142.44, 145.47, 144.34, 146.30, 147.54, 147.80)
> x<-c(194.5, 194.3, 197.9, 198.4, 199.4, 199.9, 200.9, 201.1, 201.4, 201.3,
203.6, 204.6, 209.5,208.6, 210.7, 211.9, 212.2)
> fitted.results<-lm(y~x)
> summary(fitted.results)
Call:
lm(formula = y ~ x)
Residuals:
Min 1Q Median 3Q Max
-0.32220 -0.14473 -0.06664 0.02184 1.35978
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -42.13778 3.34020 -12.62 2.18e-09 ***
x 0.89549 0.01645 54.43 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 0.379 on 15 degrees of freedom
Multiple R-squared: 0.995, Adjusted R-squared: 0.9946
F-statistic: 2963 on 1 and 15 DF, p-value: < 2.2e-16
> anova(fitted.results)
Analysis of Variance Table
Response: y
Df Sum Sq Mean Sq F value Pr(>F)
x 1 425.64 425.64 2962.8 < 2.2e-16 ***
Residuals 15 2.15 0.14
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

---

The above is the expected result. But when I did that in my computer, the
result became:

---

> summary(fitted.results)

Call:
lm(formula = y ~ x)

Residuals:
 Min   1Q   Median   3Q  Max
-0.32220 -0.14473 -0.06664  0.02184  1.35978

Coefficients:
> anova(fitted.results)
Analysis of Variance Table

Response: y

--

The parts below coefficients of summary() and the parts below response of
anova() were missing. I have tried on another two computers with older
versions(2.6,2.6,2) and the problem still exist. Please help me, 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] back transforming output from negative binomial

2008-10-02 Thread Adaikalavan Ramasamy

Dear all,

I used the glm.nb with the default values from the MASS package to run a 
negative binomial regression. Here is a simple example:



   set.seed(123)
   y <- c( rep(0, 30), rpois(70, lambda=2) )
   smoke  <- factor( sample( c("NO", "YES"), 100, replace=T ) )
   height <- c( rnorm(30, mean=100, sd=20), rnorm(70, mean=150, sd=20) )

   fit <- glm.nb( y ~ smoke + height )
   coef(summary(fit))
  Estimate  Std. Errorz value Pr(>|z|)
   (Intercept) -2.34907191 0.537610710 -4.3694664 1.245505e-05
   smokeYES-0.03479730 0.197627539 -0.1760751 8.602349e-01
   height   0.01942373 0.003527538  5.5063142 3.664243e-08


The question now is how do I report the results, say, for height? Do I 
simply take the anti logs. i.e. 1.019613 = exp(0.019423) ?


I have seen one paper where they report using anti log base 10 instead 
of natural base but they use STATA though.


Please kindly advise. Thank you.

Regards, Adai

__
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] fft inverse display help

2008-10-02 Thread rkevinburton
Sorry, I must be looking at a different section but when I look at 3.4 in 
r-intro.pdf I see:

3.4 The class of an object
All objects in R have a class, reported by the function class. For simple 
vectors this is just the
mode, for example "numeric", "logical", "character" or "list", but "matrix", 
"array",
"factor" and "data.frame" are other possible values.
. . . .

This doesn't seem to indicate how/why plot shows a time series for the "exact" 
inverse fft yet shows Re vs. Im in a filtered version.

Thank you.

Kevin

 Dieter Menne <[EMAIL PROTECTED]> wrote: 
>   charter.net> writes:
> 
> > 
> > My question is how does 'plot' know to implicilty call the plot.ts (in the
> case of the full "exact" spectrum
> > being fed back into the inverse?
> 
> So the title should be "How does the specific incarnation of object 
> orientation
> in R work?" Try, for example, section 3.4 and the "generic" classes in the
> R-intro.pdf
> 
> Dieter
> 
> __
> 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] re moving a vector from a list.

2008-10-02 Thread Rajasekaramya

Hi there

I have 386 list of vectors.In that i want to delete 23 vector in the 53 list
element.

[[1]]
"abc" "dfg" "dft" "err"

[[2]]
"elm" "erg"" trr" "rtt"

similarly i have [[386]]

now i want to delete or avoid trr in the [[2]].

i just tried something like this
list[-list[[53]][3]]

-- 
View this message in context: 
http://www.nabble.com/removing-a-vector-from-a-list.-tp19783565p19783565.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] missing output in summary() and anova()

2008-10-02 Thread John Kane

What version are you running? Under what OS.  I don't seem to see the problem 
with 2.7.2 under Windows XP.


--- On Thu, 10/2/08, Jordan Wong <[EMAIL PROTECTED]> wrote:

> From: Jordan Wong <[EMAIL PROTECTED]>
> Subject: [R] missing output in summary() and anova()
> To: r-help@r-project.org
> Received: Thursday, October 2, 2008, 12:59 PM
> > y<-c(131.79, 131.79, 135.02, 135.55, 136.46, 136.83,
> 137.82, 138.00,
> 138.06, 138.04, 140.04, 142.44, 145.47, 144.34, 146.30,
> 147.54, 147.80)
> > x<-c(194.5, 194.3, 197.9, 198.4, 199.4, 199.9,
> 200.9, 201.1, 201.4, 201.3,
> 203.6, 204.6, 209.5,208.6, 210.7, 211.9, 212.2)
> > fitted.results<-lm(y~x)
> > summary(fitted.results)
> Call:
> lm(formula = y ~ x)
> Residuals:
> Min 1Q Median 3Q Max
> -0.32220 -0.14473 -0.06664 0.02184 1.35978
> Coefficients:
> Estimate Std. Error t value Pr(>|t|)
> (Intercept) -42.13778 3.34020 -12.62 2.18e-09 ***
> x 0.89549 0.01645 54.43 < 2e-16 ***
> ---
> Signif. codes: 0 '***' 0.001 '**' 0.01
> '*' 0.05 '.' 0.1 ' ' 1
> Residual standard error: 0.379 on 15 degrees of freedom
> Multiple R-squared: 0.995, Adjusted R-squared: 0.9946
> F-statistic: 2963 on 1 and 15 DF, p-value: < 2.2e-16
> > anova(fitted.results)
> Analysis of Variance Table
> Response: y
> Df Sum Sq Mean Sq F value Pr(>F)
> x 1 425.64 425.64 2962.8 < 2.2e-16 ***
> Residuals 15 2.15 0.14
> ---
> Signif. codes: 0 '***' 0.001 '**' 0.01
> '*' 0.05 '.' 0.1 ' ' 1
> 
> ---
> 
> The above is the expected result. But when I did that in my
> computer, the
> result became:
> 
> ---
> 
> > summary(fitted.results)
> 
> Call:
> lm(formula = y ~ x)
> 
> Residuals:
>  Min   1Q   Median   3Q  Max
> -0.32220 -0.14473 -0.06664  0.02184  1.35978
> 
> Coefficients:
> > anova(fitted.results)
> Analysis of Variance Table
> 
> Response: y
> 
> --
> 
> The parts below coefficients of summary() and the parts
> below response of
> anova() were missing. I have tried on another two computers
> with older
> versions(2.6,2.6,2) and the problem still exist. Please
> help me, 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.


  __
[[elided Yahoo spam]]

__
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] back transforming output from negative binomial

2008-10-02 Thread Ben Bolker
Adaikalavan Ramasamy  imperial.ac.uk> writes:

> 
> Dear all,
> 
> I used the glm.nb with the default values from the MASS package to run a 
> negative binomial regression. Here is a simple example:
[snip -- thanks for the example!]
> The question now is how do I report the results, say, for height? Do I 
> simply take the anti logs. i.e. 1.019613 = exp(0.019423) ?
> 
> I have seen one paper where they report using anti log base 10 instead 
> of natural base but they use STATA though.
> 

  Yes, exactly. If you look at ?glm.nb you
will see that it uses a log link function, and therefore
you should exponentiate (anti-log) to back-transform.
Natural, not base-10 logs, are used.
Don't forget that back-transforming standard errors
by themselves is meaningless, you have to back-transform
lower and upper confidence limits ...

  Ben Bolker

__
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] back transforming output from negative binomial

2008-10-02 Thread Adaikalavan Ramasamy

Ben, fantastic. Thank you for confirming it.

One more question. What do you call the back transformed variable?

In my domain, people use something called the ratio of mean but I am not 
sure if it is the same. I am not what the "ratio" is between.


Regards, Adai



Ben Bolker wrote:

Adaikalavan Ramasamy  imperial.ac.uk> writes:


Dear all,

I used the glm.nb with the default values from the MASS package to run a 
negative binomial regression. Here is a simple example:

[snip -- thanks for the example!]
The question now is how do I report the results, say, for height? Do I 
simply take the anti logs. i.e. 1.019613 = exp(0.019423) ?


I have seen one paper where they report using anti log base 10 instead 
of natural base but they use STATA though.




  Yes, exactly. If you look at ?glm.nb you
will see that it uses a log link function, and therefore
you should exponentiate (anti-log) to back-transform.
Natural, not base-10 logs, are used.
Don't forget that back-transforming standard errors
by themselves is meaningless, you have to back-transform
lower and upper confidence limits ...

  Ben Bolker

__
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] missing output in summary() and anova()

2008-10-02 Thread Jordan Wong
It is 2.7.2 under Windows XP SP3. I have tried 2.6.1,2.6.2 in another
computer under Windows XP SP3 also and the problem still occur.

2008/10/3 John Kane <[EMAIL PROTECTED]>

>
> What version are you running? Under what OS.  I don't seem to see the
> problem with 2.7.2 under Windows XP.
>
>
> --- On Thu, 10/2/08, Jordan Wong <[EMAIL PROTECTED]> wrote:
>
> > From: Jordan Wong <[EMAIL PROTECTED]>
> > Subject: [R] missing output in summary() and anova()
> > To: r-help@r-project.org
> > Received: Thursday, October 2, 2008, 12:59 PM
> > > y<-c(131.79, 131.79, 135.02, 135.55, 136.46, 136.83,
> > 137.82, 138.00,
> > 138.06, 138.04, 140.04, 142.44, 145.47, 144.34, 146.30,
> > 147.54, 147.80)
> > > x<-c(194.5, 194.3, 197.9, 198.4, 199.4, 199.9,
> > 200.9, 201.1, 201.4, 201.3,
> > 203.6, 204.6, 209.5,208.6, 210.7, 211.9, 212.2)
> > > fitted.results<-lm(y~x)
> > > summary(fitted.results)
> > Call:
> > lm(formula = y ~ x)
> > Residuals:
> > Min 1Q Median 3Q Max
> > -0.32220 -0.14473 -0.06664 0.02184 1.35978
> > Coefficients:
> > Estimate Std. Error t value Pr(>|t|)
> > (Intercept) -42.13778 3.34020 -12.62 2.18e-09 ***
> > x 0.89549 0.01645 54.43 < 2e-16 ***
> > ---
> > Signif. codes: 0 '***' 0.001 '**' 0.01
> > '*' 0.05 '.' 0.1 ' ' 1
> > Residual standard error: 0.379 on 15 degrees of freedom
> > Multiple R-squared: 0.995, Adjusted R-squared: 0.9946
> > F-statistic: 2963 on 1 and 15 DF, p-value: < 2.2e-16
> > > anova(fitted.results)
> > Analysis of Variance Table
> > Response: y
> > Df Sum Sq Mean Sq F value Pr(>F)
> > x 1 425.64 425.64 2962.8 < 2.2e-16 ***
> > Residuals 15 2.15 0.14
> > ---
> > Signif. codes: 0 '***' 0.001 '**' 0.01
> > '*' 0.05 '.' 0.1 ' ' 1
> >
> >
> ---
> >
> > The above is the expected result. But when I did that in my
> > computer, the
> > result became:
> >
> >
> ---
> >
> > > summary(fitted.results)
> >
> > Call:
> > lm(formula = y ~ x)
> >
> > Residuals:
> >  Min   1Q   Median   3Q  Max
> > -0.32220 -0.14473 -0.06664  0.02184  1.35978
> >
> > Coefficients:
> > > anova(fitted.results)
> > Analysis of Variance Table
> >
> > Response: y
> >
> >
> --
> >
> > The parts below coefficients of summary() and the parts
> > below response of
> > anova() were missing. I have tried on another two computers
> > with older
> > versions(2.6,2.6,2) and the problem still exist. Please
> > help me, 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.
>
>
>  __
> Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your
> favourite sites. Download it now at
> http://ca.toolbar.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] back transforming output from negative binomial

2008-10-02 Thread Ben Bolker
Adaikalavan Ramasamy wrote:
> Ben, fantastic. Thank you for confirming it.
> 
> One more question. What do you call the back transformed variable?
> 
> In my domain, people use something called the ratio of mean but I am not
> sure if it is the same. I am not what the "ratio" is between.

  It depends.  For the intercept, the back-transformed parameter
is essentially the geometric mean of the baseline group (assuming
you're using treatment contrasts).  For factors, the back-transf
parameters are the ratios between the means of observations at one
factor level and the mean at the baseline level.  For continuous
covariates, it's the proportional increase per unit of increase
in the covariate.

> 
> Regards, Adai
> 
> 
> 
> Ben Bolker wrote:
>> Adaikalavan Ramasamy  imperial.ac.uk> writes:
>>
>>> Dear all,
>>>
>>> I used the glm.nb with the default values from the MASS package to
>>> run a negative binomial regression. Here is a simple example:
>> [snip -- thanks for the example!]
>>> The question now is how do I report the results, say, for height? Do
>>> I simply take the anti logs. i.e. 1.019613 = exp(0.019423) ?
>>>
>>> I have seen one paper where they report using anti log base 10
>>> instead of natural base but they use STATA though.
>>>
>>
>>   Yes, exactly. If you look at ?glm.nb you
>> will see that it uses a log link function, and therefore
>> you should exponentiate (anti-log) to back-transform.
>> Natural, not base-10 logs, are used.
>> Don't forget that back-transforming standard errors
>> by themselves is meaningless, you have to back-transform
>> lower and upper confidence limits ...
>>
>>   Ben Bolker
>>
>> __
>> 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] time segments intersection

2008-10-02 Thread Gabor Grothendieck
Try this:

> library(zoo)
> # create two time series to test with
> z1 <- zooreg(0:10, Sys.Date())
> z2 <- lag(z1, 5)
>
> z1
2008-10-02 2008-10-03 2008-10-04 2008-10-05 2008-10-06 2008-10-07
2008-10-08 2008-10-09 2008-10-10 2008-10-11 2008-10-12
 0  1  2  3  4  5
6  7  8  9 10
> z2
2008-09-27 2008-09-28 2008-09-29 2008-09-30 2008-10-01 2008-10-02
2008-10-03 2008-10-04 2008-10-05 2008-10-06 2008-10-07
 0  1  2  3  4  5
6  7  8  9 10
>
> # intersect them
> merge(z1, z2, all = FALSE)
   z1 z2
2008-10-02  0  5
2008-10-03  1  6
2008-10-04  2  7
2008-10-05  3  8
2008-10-06  4  9
2008-10-07  5 10
> range(time(merge(z1, z2, all = FALSE)))
[1] "2008-10-02" "2008-10-07"

On Wed, Oct 1, 2008 at 12:48 PM, [Ricardo Rodriguez] Your XEN ICT Team
<[EMAIL PROTECTED]> wrote:
> Hi all,
>
> Please, how could I calculate the time that two time segments has in common?
> Is there any function to perform this calculation?
>
> For instance, given four POSIXlt objects...
>
> endPeriod<-as.POSIXlt("2008-09-30")
> startPeriod<-as.POSIXlt("2007-10-01")
> endProject<-as.POSIXlt("2007-05-31")
> startProject<-as.POSIXlt("2006-12-01")
>
> that limit two time segments...
>
> project <- as.numeric(endProject-startProject)
> period <- as.numeric(endPeriod-startPeriod)
>
> How could I calculate the time project and period overlap?
>
> Thanks for your help!
>
> Ricardo
>
>
>
> --
> Ricardo Rodríguez
> Your XEN ICT Team
>
> __
> 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] 3 curves / 1 plot

2008-10-02 Thread Michel PETITJEAN
I am a new user of R.
Please does somebody knows how to plot 3 datasets
(x1,a1),...,(xn,an), (x1,b1),...,(xn,bn), and (x1,c1),...,(xn,cn)
on a single x,y plot, each of the three datasets being plotted with
its own character pch() ?
(three calls to plot() erase the two first datasets).
Thank you very much.

Michel Petitjean,
DSV/iBiTec-S/SB2SM (CNRS URA 2096), CEA Saclay, bat. 528,
91191 Gif-sur-Yvette Cedex, France.
Phone: +331 6908 4006 / Fax: +331 6908 4007
E-mail: [EMAIL PROTECTED]
http://petitjeanmichel.free.fr/itoweb.petitjean.html

__
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] Adding plane in a 3D scatterplot

2008-10-02 Thread Uwe Ligges



Megh Dal wrote:

I have drawn a 3D scatter plot :

library(mnormt)
library(scatterplot3d)
dat = cbind(rmnorm(3, rep(0,2), diag(2)), 1:3)
scatterplot3d(dat)

Now I want to do 2 things :

1 : In the Z-axis (i.e. height), I want to see only numbers 1,2,3, etc NOT, 
1,1.5,2,2.5.

2. I want to add two Horizontal planes at hight z=2 and z=3. Those two planes should look like "bottom" of that 3D plot [i.e. like Grid-lines].I already gone through "$plane3d" but could not get through. In the help page, a description is given with a regression line, however I could not understand how I can implement that in my problem. 


Example:

 s3d <- scatterplot3d(dat, lab.z=2, scale.y=0.7, angle=20)
 s3d$plane3d(2,0,0, "solid", col="grey")

Uwe Ligges


Any help will be highly appreciate. 


Regards,

__
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] 3 curves / 1 plot

2008-10-02 Thread Kingsford Jones
example(matplot)

or

?points

On Thu, Oct 2, 2008 at 11:43 AM, Michel PETITJEAN
<[EMAIL PROTECTED]> wrote:
> I am a new user of R.
> Please does somebody knows how to plot 3 datasets
> (x1,a1),...,(xn,an), (x1,b1),...,(xn,bn), and (x1,c1),...,(xn,cn)
> on a single x,y plot, each of the three datasets being plotted with
> its own character pch() ?
> (three calls to plot() erase the two first datasets).
> Thank you very much.
>
> Michel Petitjean,
> DSV/iBiTec-S/SB2SM (CNRS URA 2096), CEA Saclay, bat. 528,
> 91191 Gif-sur-Yvette Cedex, France.
> Phone: +331 6908 4006 / Fax: +331 6908 4007
> E-mail: [EMAIL PROTECTED]
> http://petitjeanmichel.free.fr/itoweb.petitjean.html
>
> __
> 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] 3 curves / 1 plot

2008-10-02 Thread Bert Gunter
imho better: ?xyplot  using the groups argument.

-- Bert
 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Kingsford Jones
Sent: Thursday, October 02, 2008 11:17 AM
To: Michel PETITJEAN
Cc: r-help@r-project.org
Subject: Re: [R] 3 curves / 1 plot

example(matplot)

or

?points

On Thu, Oct 2, 2008 at 11:43 AM, Michel PETITJEAN
<[EMAIL PROTECTED]> wrote:
> I am a new user of R.
> Please does somebody knows how to plot 3 datasets
> (x1,a1),...,(xn,an), (x1,b1),...,(xn,bn), and (x1,c1),...,(xn,cn)
> on a single x,y plot, each of the three datasets being plotted with
> its own character pch() ?
> (three calls to plot() erase the two first datasets).
> Thank you very much.
>
> Michel Petitjean,
> DSV/iBiTec-S/SB2SM (CNRS URA 2096), CEA Saclay, bat. 528,
> 91191 Gif-sur-Yvette Cedex, France.
> Phone: +331 6908 4006 / Fax: +331 6908 4007
> E-mail: [EMAIL PROTECTED]
> http://petitjeanmichel.free.fr/itoweb.petitjean.html
>
> __
> 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.


[R] Shadowed Plot

2008-10-02 Thread segun ogundimu
Hello R-users
 
 
Kindly assist me with the following plot problem in R-
My data looks like this (shortened because I have about 5000 observations).
 
dat <- read.table(textConnection("Id  Time Y  
1 0   194
1 5.22 179
1 5.97 190 
2 1.61 265 
2 2.1  234
2 16.4 300 
2 29.5 345 
3 0    212
3 0.36 213 
4 0    199
4 1.23  203
5  0   212
5  13.5 216
6  0    222
6  1.6 234" ), header = TRUE)
closeAllConnections()
 
The measurements are not taken at equal time points.  I want to avoid overly 
cluttered plots in making individual profile. So, I will like the profile plot 
to appear grey (not completely visible) and about 30 randomly selected 'lucky 
subjects' to appear dark(very visible).
 
The code below was proposed but failed to do the job right!
 
attach(dat) 
plot(Time, Y, type="n")
subjects <- unique(Id)
dark <- subjects %in% sample(subjects, 3)
for (subject in subjects){ 
    which <- subject == Id
    lines(Time[which], Y[which], pch=as.character(subject), type="b",
col=if(dark[subject]) "black" else "gray50")
    }
 
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.


Re: [R] 3 curves / 1 plot

2008-10-02 Thread Chunhao Tu



Michel PETITJEAN-2 wrote:
> 
> I am a new user of R.
> Please does somebody knows how to plot 3 datasets
> (x1,a1),...,(xn,an), (x1,b1),...,(xn,bn), and (x1,c1),...,(xn,cn)
> on a single x,y plot, each of the three datasets being plotted with
> its own character pch() ?
> (three calls to plot() erase the two first datasets).
> Thank you very much.
> Hi Michel,
> Have you check ?plot. You could plot 1st data set then plot (2nd data set,
> lty="b", add=TRUE) and then plot (3rd data set, lty="b", add=TRUE) then
> you could get what you want. I believe.
> 
> Hope it helps
> Chunhao
> 
>  
> Michel Petitjean,
> DSV/iBiTec-S/SB2SM (CNRS URA 2096), CEA Saclay, bat. 528,
> 91191 Gif-sur-Yvette Cedex, France.
> Phone: +331 6908 4006 / Fax: +331 6908 4007
> E-mail: [EMAIL PROTECTED]
> http://petitjeanmichel.free.fr/itoweb.petitjean.html
> 
> __
> 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/3-curves---1-plot-tp19784236p19784604.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] t.test() on a list

2008-10-02 Thread Gang Chen
I have a list, myList, with each of its 9 components being a 15X15
matrix. I want to run a t-test across the list for each component in
the matrix. For example, the first t-test is on myList[[1]][1, 1],
myList[[2]][1, 1], ..., myList[[9]][1, 1]; and there are totally 15X15
t-tests. How can I run these t-tests in a simple way?

TIA,
Gang

__
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] Adding plane in a 3D scatterplot

2008-10-02 Thread Megh Dal
I got following error :
> library(mnormt)
> library(scatterplot3d)
> dat = cbind(rmnorm(3, rep(0,2), diag(2)), 1:3)
> s3d <- scatterplot3d(dat, lab.z=2, scale.y=0.7, angle=20)
> s3d$plane3d(2,0,0, "solid", col="grey")
Error in object$coefficients : $ operator is invalid for atomic vectors

I am using following version:
> R.Version()
$platform
[1] "i386-pc-mingw32"

$arch
[1] "i386"

$os
[1] "mingw32"

$system
[1] "i386, mingw32"

$status
[1] ""

$major
[1] "2"

$minor
[1] "7.1"

$year
[1] "2008"

$month
[1] "06"

$day
[1] "23"

$`svn rev`
[1] "45970"

$language
[1] "R"

$version.string
[1] "R version 2.7.1 (2008-06-23)"



--- On Thu, 10/2/08, Uwe Ligges <[EMAIL PROTECTED]> wrote:

> From: Uwe Ligges <[EMAIL PROTECTED]>
> Subject: Re: [R] Adding plane in a 3D scatterplot
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Date: Thursday, October 2, 2008, 11:38 PM
> Megh Dal wrote:
> > I have drawn a 3D scatter plot :
> > 
> > library(mnormt)
> > library(scatterplot3d)
> > dat = cbind(rmnorm(3, rep(0,2), diag(2)), 1:3)
> > scatterplot3d(dat)
> > 
> > Now I want to do 2 things :
> > 
> > 1 : In the Z-axis (i.e. height), I want to see only
> numbers 1,2,3, etc NOT, 1,1.5,2,2.5.
> > 
> > 2. I want to add two Horizontal planes at hight z=2
> and z=3. Those two planes should look like
> "bottom" of that 3D plot [i.e. like Grid-lines].I
> already gone through "$plane3d" but could not get
> through. In the help page, a description is given with a
> regression line, however I could not understand how I can
> implement that in my problem. 
> 
> Example:
> 
>   s3d <- scatterplot3d(dat, lab.z=2, scale.y=0.7,
> angle=20)
>   s3d$plane3d(2,0,0, "solid",
> col="grey")
> 
> Uwe Ligges
> 
> 
> > Any help will be highly appreciate. 
> > 
> > Regards,
> > 
> > __
> > 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] Load a program at the front end

2008-10-02 Thread Gang Chen
I want to run a R program, prog.R,  interactively. My question is, is
there a way I can start prog.R on the shell terminal when invoking R,
instead of using source() inside R?

TIA,
Gang

__
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] specifying x-axis scale on random forest variable importance plot

2008-10-02 Thread Liaw, Andy
The default range is the range of the variable in the data.  It wouldn't
make much sense to extend beyond that.  If you want to restrict the
range, the varImpPlot() function does return the x-y pairs, so you can
construct your own plot from that.

Andy 

From: A Van Dyke
> 
> i am new to R and using the random forest package.  is there 
> a way to specify
> the x-axis scale range for the variable importance plot?  many thanks.
> 
> -alison
> -- 
> View this message in context: 
> http://www.nabble.com/specifying-x-axis-scale-on-random-forest
> -variable-importance-plot-tp19780560p19780560.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.
> 
Notice:  This e-mail message, together with any attachme...{{dropped:12}}

__
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] Contour Plot Aspect Ratio

2008-10-02 Thread Sam Albers
Hello there,

I have a fairly simple request (I hope!)

I have produced a filled contour plot like this:

library(grDevices)
library(gplots)
library(plotrix)

filled.contour(contour, axes=F, frame.plot=TRUE, color=terrain.colors, ylab=
"Length Along Flume (m)", key.title = title(main="Velocity\n(m/s)"),
key.axes = axis(4, seq(0, 0.6, by = 0.1)), asp=2, plot.axes = {
axis.mult(side=1,mult=0.005,mult.label="Width (cm)")
axis(side=2, at=x, labels=colnames(contour)) })

Note the asp=2 argument.

I would like to make this plot twice as long as it is wide. I accomplish
this using asp=2 but the actual box that I am plotting now is too big for
the data contained within.

Here is what it looks like:

http://docs.google.com/Doc?id=ddqdnxbq_30ffthshgk

Does anyone know how I might be able to lengthen this graph without it
looking like this? I want to suck in that vertical axes so that it is snug
with the actual contour plot.

Thanks in advance.

Sam

[[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] Bias in sample - Logistic Regression

2008-10-02 Thread Pedro.Rodriguez
Hi Shiva,

Maybe you are interested in the following paper:

Learning when Training Data are Costly: The Effect of Class Distribution
on Tree Induction. G. Weiss and F. Provost.  Journal of Artificial
Intelligence Research 19 (2003) 315-354.

For validating the models in those enviroments, 

William Elazmeh, Nathalie Japkowicz, Stan Matwin. (2006). A Framework
for Comparative Evaluation of Classifiers in the Presence of Class
Imbalance. Proceedings of the third Workshop on ROC Analysis in Machine
Learning, Pittsburgh, USA.

Regards,

Pedro

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Wensui Liu
Sent: Wednesday, October 01, 2008 7:20 PM
To: [EMAIL PROTECTED]
Cc: r-help@r-project.org
Subject: Re: [R] Bias in sample - Logistic Regression

Hi, Shiva,

The idea of reject inference is very simple. Let's assume a credit card
environment. There are 100 applicants, out of which 50 will be approved
and
booked in. Therefore, we can only observe the adverse behavior, such as
default and delinquency, of 50 booked accounts. Again, let's assume out
of
50 booked cards, 5 are bad(default / delinquency). A normal thought is
to
build a model to "cherry pick" bad guys and then apply the same model to
all
applicants.

However, we can only observed the behavior of the applicants booked,
which
is 50, but not all applicants, which is 100. Therefore, the model result
looks better than what it is supposed to be. This is so-called 'sample
bias'. The same thing can happen to healthcare or direct marketing as
well.

Luckily enough, many people have done some excellent work on this
problem.
Please do some readings by Heckman. Greene in NYU has paper in this area
as
well. And I believe there is also implementation in R. If you use
SAS(large
in industry), take a look at proc qlim.

HTH.

-- 
===
WenSui Liu
Acquisition Risk, Chase
Email : [EMAIL PROTECTED]
Blog   : statcompute.spaces.live.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.

__
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] t.test() on a list

2008-10-02 Thread Bert Gunter
I am sure you will get helpful answers. I am almost as sure that you
shouldn't be doing this. I suggest you consult with your local statistician.

-- Bert Gunter 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Gang Chen
Sent: Thursday, October 02, 2008 11:24 AM
To: [EMAIL PROTECTED]
Subject: [R] t.test() on a list

I have a list, myList, with each of its 9 components being a 15X15
matrix. I want to run a t-test across the list for each component in
the matrix. For example, the first t-test is on myList[[1]][1, 1],
myList[[2]][1, 1], ..., myList[[9]][1, 1]; and there are totally 15X15
t-tests. How can I run these t-tests in a simple way?

TIA,
Gang

__
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 moving a vector from a list.

2008-10-02 Thread jim holtman
Is this what you want to do - it was not clear from your example:

> x
[[1]]
[1] 1

[[2]]
[1] 2

[[3]]
[1] 3

[[4]]
[1] 4

> x <- x[-3]
> x
[[1]]
[1] 1

[[2]]
[1] 2

[[3]]
[1] 4

>
 Or maybe this:

> x <- list(c( 1,2 ,3,4),c(4,5,6,7),c(8,9))
> x
[[1]]
[1] 1 2 3 4

[[2]]
[1] 4 5 6 7

[[3]]
[1] 8 9

> x[[2]] <- x[[2]][-2]
> x
[[1]]
[1] 1 2 3 4

[[2]]
[1] 4 6 7

[[3]]
[1] 8 9

>


On Thu, Oct 2, 2008 at 1:06 PM, Rajasekaramya <[EMAIL PROTECTED]> wrote:
>
> Hi there
>
> I have 386 list of vectors.In that i want to delete 23 vector in the 53 list
> element.
>
> [[1]]
> "abc" "dfg" "dft" "err"
>
> [[2]]
> "elm" "erg"" trr" "rtt"
>
> similarly i have [[386]]
>
> now i want to delete or avoid trr in the [[2]].
>
> i just tried something like this
> list[-list[[53]][3]]
>
> --
> View this message in context: 
> http://www.nabble.com/removing-a-vector-from-a-list.-tp19783565p19783565.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.


  1   2   >