[R] Rpart - best split selection for class method and Gini splitting index

2009-05-20 Thread Paolo Radaelli


Dear R-users,
I'm working with the Rpart package and trying to understand how the 
procedure select the best split in the case the method "class" and the 
splitting index "Gini" are used. In particular I'd like to have look to the 
source code that works out the best split for un unordered predictor.
Does anyone can suggest me which functions in the sources I should consider 
?

Any input would be highly appreciated.

Thank you
Paolo

Paolo Radaelli
Dipartimento di Metodi Quantitativi per le Scienze Economiche ed Aziendali
Facoltà di Economia
Università degli Studi di Milano-Bicocca
Via Bicocca degli Arcimboldi, 8
20126 Milano
Italy
e-mail paolo.radae...@unimib.it
Tel +39 02 6448 3163
Fax +39 02 6448 3105

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problems with sample variance

2009-05-20 Thread milton ruser
to start with same seed:

set.seed(12345)

:-)

On Thu, May 21, 2009 at 1:22 AM, Daniel Nordlund wrote:

> > -Original Message-
> > From: r-help-boun...@r-project.org
> > [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Alspach
> > Sent: Wednesday, May 20, 2009 10:02 PM
> > To: milton ruser; Chloe Smith
> > Cc: r-help@r-project.org
> > Subject: Re: [R] Problems with sample variance
> >
> > Thanks Milton - I misread Chloe's original question.
> >
> > nSims <- 1000
> > sampSiz <- 15
> > myVars <- tapply(rnorm(nSims*sampSiz), rep(1:nSims, sampSiz), var)
> >
> > This is a little more succinct, although I do not know enough about
> > random number generation to be certain about the effect of breaking a
> > single call to rnorm into 1000 bits, rather than having 1000 calls to
> > rnorm (or even if there is such an effect.  Comment anyone?).
>
> It doesn't matter whether you use a single call or multiple calls, the same
> set of numbers will be generated either way (if one starts with the same
> seed).
>
> >
> > It used to be (and I imagine still is) not efficient
> > incrementally grow
> > an object in a loop [as is done in your code with variance.list <-
> > c(variance.list, var(mysample))].  Better to create
> > variance.list at its
> > full size first (filled with NA) and then populate it.  Not that it is
> > likely to make too much difference with these numbers.
> >
> > HTH .
> >
> > Peter Alspach
>
> Hope this is helpful,
>
> Dan
>
> Daniel Nordlund
> Bothell, WA USA
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Problems with sample variance

2009-05-20 Thread Daniel Nordlund
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Alspach
> Sent: Wednesday, May 20, 2009 10:02 PM
> To: milton ruser; Chloe Smith
> Cc: r-help@r-project.org
> Subject: Re: [R] Problems with sample variance
> 
> Thanks Milton - I misread Chloe's original question.
> 
> nSims <- 1000
> sampSiz <- 15
> myVars <- tapply(rnorm(nSims*sampSiz), rep(1:nSims, sampSiz), var)
> 
> This is a little more succinct, although I do not know enough about
> random number generation to be certain about the effect of breaking a
> single call to rnorm into 1000 bits, rather than having 1000 calls to
> rnorm (or even if there is such an effect.  Comment anyone?).

It doesn't matter whether you use a single call or multiple calls, the same
set of numbers will be generated either way (if one starts with the same
seed).

> 
> It used to be (and I imagine still is) not efficient 
> incrementally grow
> an object in a loop [as is done in your code with variance.list <-
> c(variance.list, var(mysample))].  Better to create 
> variance.list at its
> full size first (filled with NA) and then populate it.  Not that it is
> likely to make too much difference with these numbers.
> 
> HTH .
> 
> Peter Alspach

Hope this is helpful,

Dan

Daniel Nordlund
Bothell, WA USA

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problems with sample variance

2009-05-20 Thread Peter Alspach
Thanks Milton - I misread Chloe's original question.

nSims <- 1000
sampSiz <- 15
myVars <- tapply(rnorm(nSims*sampSiz), rep(1:nSims, sampSiz), var)

This is a little more succinct, although I do not know enough about
random number generation to be certain about the effect of breaking a
single call to rnorm into 1000 bits, rather than having 1000 calls to
rnorm (or even if there is such an effect.  Comment anyone?).

It used to be (and I imagine still is) not efficient incrementally grow
an object in a loop [as is done in your code with variance.list <-
c(variance.list, var(mysample))].  Better to create variance.list at its
full size first (filled with NA) and then populate it.  Not that it is
likely to make too much difference with these numbers.

HTH .

Peter Alspach
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of milton ruser
> Sent: Thursday, 21 May 2009 4:30 p.m.
> To: Chloe Smith
> Cc: r-help@r-project.org
> Subject: Re: [R] Problems with sample variance
> 
> Hi Chloe,
> 
> Try this:
> 
> NUMBER.OF.RUNS<-10 #change here
> for (NR in 1:NUMBER.OF.RUNS)
> {
> number.simulation<-1000
> sample.size=15;
> variance.list<-NULL
> for(i in 1:number.simulation)
>{
>mysample<-rnorm(sample.size)
>variance.list<- c(variance.list, var(mysample))
>} #i
> hist(variance.list)
> } #NR
> 
> 
> Bests
> 
> milton
> brazil=toronto
> 
> On Wed, May 20, 2009 at 8:16 PM, Chloe Smith 
>  wrote:
> 
> >
> > Dear R users,
> >
> > I am a beginner to R. I generated 1000 samples with 15 data in each 
> > sample
> >
> > I tried finding the variance for each sample
> >
> > I used the code:
> >
> > m=1000;n=15
> > > r<-rnorm(15000)
> > > for(i in 1:m){
> > x=data[,i]
> > v=var(x)}
> >
> > what I got was just the variance for the last sample i.e. 
> the 1000th 
> > sample
> >
> > but what I want is 1000 variance.
> >
> > Does anyone know what I did wrong?
> >
> > Thanks
> >
> > Chloe Smith
> >
> > --
> > View this message in context:
> > 
> http://www.nabble.com/Problems-with-sample-variance-tp23645919p2364591
> > 9.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 > osting-guide.html> and provide commented, minimal, self-contained, 
> > reproducible code.
> >
> 
>   [[alternative HTML version deleted]]
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 

The contents of this e-mail are confidential and may be subject to legal 
privilege.
 If you are not the intended recipient you must not use, disseminate, 
distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received 
this
 e-mail in error, please notify the sender and delete all material pertaining 
to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the 
individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 order variables in a dataframe

2009-05-20 Thread milton ruser
Following Simon's example

dat <- data.frame(d=rnorm(3), c=rnorm(3), b=rnorm(3), a=rnorm(3))
dat
dat<-subset(dat, select=c(d,a,b,c))
dat
Bests

milton
brazil=toronto

On Thu, May 21, 2009 at 12:02 AM, Simon Blomberg wrote:

> How about to insert a variable a2 inbetween the first and second columns
> of dat:
>
>  dat2 <- cbind(dat[,1], a2=a2, dat[,2:3])
>
> Where a2 is the new variable. This mangles the variable name for column
> 1, unfortunately. Surely someone else will offer a better solution.
>
> Simon.
>
>
> On Wed, 2009-05-20 at 20:39 -0700, pgseye wrote:
> > Thanks Simon,
> >
> > I should have explained myself better (although I didn't know about the
> > order function so that's handy information).
> >
> > I've found a few times, I've added variables to a dataframe that I would
> > like to 'group' with variables earlier in the datset. So I was wondering
> if
> > you could somehow ask R, for example, to take that last variable and
> insert
> > it at a different position in the dataframe.
> >
> > Thanks,
> >
> > Paul
> >
> > Simon Blomberg-4 wrote:
> > >
> > > Alphabetically, like this?:
> > >
> > >> dat <- data.frame(d=rnorm(3), c=rnorm(3), b=rnorm(3), a=rnorm(3))
> > >> dat
> > >d  c  b a
> > > 1 -0.1816733 -0.4106008 -0.2855991 -1.022951
> > > 2 -1.8326818 -0.6515208  0.3344884 -2.191836
> > > 3  1.0924867  0.1159611 -1.3409719  1.195545
> > >> dat2 <- dat[,order(names(dat))]
> > >> dat2
> > >   a  b  c  d
> > > 1 -1.022951 -0.2855991 -0.4106008 -0.1816733
> > > 2 -2.191836  0.3344884 -0.6515208 -1.8326818
> > > 3  1.195545 -1.3409719  0.1159611  1.0924867
> > >>
> > >
> > > Cheers,
> > >
> > > Simon.
> > >
> > > On Wed, 2009-05-20 at 20:19 -0700, pgseye wrote:
> > >> This is no doubt a very basic question for most R users, but is there
> an
> > >> easy
> > >> way to reorder the variables (columns) in a dataframe (I can't seem to
> > >> find
> > >> an answer anywhere). I've generally been creating a new dataframe and
> > >> selecting the new order I want from the old but this is
> time-consuming.
> > >>
> > >> Thanks,
> > >>
> > >> Paul
> > > --
> > > Simon Blomberg, BSc (Hons), PhD, MAppStat.
> > > Lecturer and Consultant Statistician
> > > School of Biological Sciences
> > > The University of Queensland
> > > St. Lucia Queensland 4072
> > > Australia
> > > Room 320 Goddard Building (8)
> > > T: +61 7 3365 2506
> > > http://www.uq.edu.au/~uqsblomb
> > > email: S.Blomberg1_at_uq.edu.au 
> > >
> > > Policies:
> > > 1.  I will NOT analyse your data for you.
> > > 2.  Your deadline is your problem.
> > >
> > > 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.
> > >
> > > __
> > > R-help@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-help
> > > PLEASE do read the posting guide
> > > http://www.R-project.org/posting-guide.html
> > > and provide commented, minimal, self-contained, reproducible code.
> > >
> > >
> >
> --
> Simon Blomberg, BSc (Hons), PhD, MAppStat.
> Lecturer and Consultant Statistician
> School of Biological Sciences
> The University of Queensland
> St. Lucia Queensland 4072
> Australia
> Room 320 Goddard Building (8)
> T: +61 7 3365 2506
> http://www.uq.edu.au/~uqsblomb
> email: S.Blomberg1_at_uq.edu.au 
>
> Policies:
> 1.  I will NOT analyse your data for you.
> 2.  Your deadline is your problem.
>
> 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.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] Problems with sample variance

2009-05-20 Thread milton ruser
Hi Chloe,

Try this:

NUMBER.OF.RUNS<-10 #change here
for (NR in 1:NUMBER.OF.RUNS)
{
number.simulation<-1000
sample.size=15;
variance.list<-NULL
for(i in 1:number.simulation)
   {
   mysample<-rnorm(sample.size)
   variance.list<- c(variance.list, var(mysample))
   } #i
hist(variance.list)
} #NR


Bests

milton
brazil=toronto

On Wed, May 20, 2009 at 8:16 PM, Chloe Smith  wrote:

>
> Dear R users,
>
> I am a beginner to R. I generated 1000 samples with 15 data in each sample
>
> I tried finding the variance for each sample
>
> I used the code:
>
> m=1000;n=15
> > r<-rnorm(15000)
> > for(i in 1:m){
> x=data[,i]
> v=var(x)}
>
> what I got was just the variance for the last sample i.e. the 1000th sample
>
> but what I want is 1000 variance.
>
> Does anyone know what I did wrong?
>
> Thanks
>
> Chloe Smith
>
> --
> View this message in context:
> http://www.nabble.com/Problems-with-sample-variance-tp23645919p23645919.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Kingsford Jones
A couple more ideas...

If you find reading code useful, try specifying filetype:r in Google
(e.g., do.call filetype:r)

For firefox users, the R wiki provides search tips here:

http://wiki.r-project.org/rwiki/doku.php?id=tips:misc:firefox-search-plugins

My preference is to keep RSeek in the top position of the firefox
search bar so that on my windows box I can Ctrl-Tab to firefox, then
Ctrl-K to search R sites.

hth,

Kingsford Jones

On Wed, May 20, 2009 at 3:05 PM, Kynn Jones  wrote:
> Thank you all very much for the so many useful ideas and resources.
> KJ
>
>        [[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


Re: [R] Re order variables in a dataframe

2009-05-20 Thread Simon Blomberg
How about to insert a variable a2 inbetween the first and second columns
of dat:

 dat2 <- cbind(dat[,1], a2=a2, dat[,2:3])

Where a2 is the new variable. This mangles the variable name for column
1, unfortunately. Surely someone else will offer a better solution.

Simon.


On Wed, 2009-05-20 at 20:39 -0700, pgseye wrote:
> Thanks Simon,
> 
> I should have explained myself better (although I didn't know about the
> order function so that's handy information).
> 
> I've found a few times, I've added variables to a dataframe that I would
> like to 'group' with variables earlier in the datset. So I was wondering if
> you could somehow ask R, for example, to take that last variable and insert
> it at a different position in the dataframe.
> 
> Thanks,
> 
> Paul
> 
> Simon Blomberg-4 wrote:
> > 
> > Alphabetically, like this?:
> > 
> >> dat <- data.frame(d=rnorm(3), c=rnorm(3), b=rnorm(3), a=rnorm(3))
> >> dat
> >d  c  b a
> > 1 -0.1816733 -0.4106008 -0.2855991 -1.022951
> > 2 -1.8326818 -0.6515208  0.3344884 -2.191836
> > 3  1.0924867  0.1159611 -1.3409719  1.195545
> >> dat2 <- dat[,order(names(dat))]
> >> dat2
> >   a  b  c  d
> > 1 -1.022951 -0.2855991 -0.4106008 -0.1816733
> > 2 -2.191836  0.3344884 -0.6515208 -1.8326818
> > 3  1.195545 -1.3409719  0.1159611  1.0924867
> >> 
> > 
> > Cheers,
> > 
> > Simon.
> > 
> > On Wed, 2009-05-20 at 20:19 -0700, pgseye wrote:
> >> This is no doubt a very basic question for most R users, but is there an
> >> easy
> >> way to reorder the variables (columns) in a dataframe (I can't seem to
> >> find
> >> an answer anywhere). I've generally been creating a new dataframe and
> >> selecting the new order I want from the old but this is time-consuming.
> >> 
> >> Thanks,
> >> 
> >> Paul
> > -- 
> > Simon Blomberg, BSc (Hons), PhD, MAppStat. 
> > Lecturer and Consultant Statistician 
> > School of Biological Sciences
> > The University of Queensland 
> > St. Lucia Queensland 4072 
> > Australia
> > Room 320 Goddard Building (8)
> > T: +61 7 3365 2506
> > http://www.uq.edu.au/~uqsblomb
> > email: S.Blomberg1_at_uq.edu.au
> > 
> > Policies:
> > 1.  I will NOT analyse your data for you.
> > 2.  Your deadline is your problem.
> > 
> > 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.
> > 
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> > 
> > 
> 
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

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.

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Kjetil Halvorsen
Sorry to be off-topic.
See below.

On Wed, May 20, 2009 at 5:38 PM, Emmanuel Charpentier <
charp...@bacbuc.dyndns.org> wrote:

> Le mercredi 20 mai 2009 à 09:02 -0400, Kynn Jones a écrit :
> > Hi!  I'm new to R programming, though I've been programming in other
> > languages for years.
> >
> > One thing I find most frustrating about R is how difficult it is to use
> > Google (or any other search tool) to look for answers to my R-related
> > questions.  With languages with even slightly more distinctive names like
> > Perl, Java, Python, Matlab, OCaml, etc., usually including the name of
> the
> > language in the query is enough to ensure that the top hits are relevant.
> >  But this trick does not work for R, because the letter R appears by
> itself
> > in so many pages, that the chaff overwhelms the wheat, so to speak.
> >
> > So I'm curious to learn what strategies R users have found to get around
> > this annoyance.
>
> ISTR having this question or very close ones at least thrice in the last
> two months.
>



 _thrice_
I low to see that english word. Not seen to often. I used to use it without
having seen it,
byt then a scottish friend said "that word do not exist". But he understood
it.

Kjetil

>
> Time for a FAQ entry ? (It does not seem to exist : I checked...)
>
>Emmanuel Charpentier
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

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


Re: [R] XML parse error

2009-05-20 Thread Duncan Temple Lang


Hi Kulwinder

There seems to be many points of confusion here
You appear to have added new files to the installation of the XML 
package, i.e. norel.xsd and LogCallSummary.bin into examplData.

They are not part of the regular XML package installation.

Because these are not part of the XML installation, we have no
idea what they contain.  The binary dump does not show us
the real content, just the sequence of bytes.

xmlParse() can read a regular XML file or a gzip compressed
file. But it cannot make sense of arbitrarily formatted
binary files.

So if you want help on your task, you might try to explain
where you started, and at a higher/more abstract level than
binary files.

So please give a reproducible example that we might be able to emulate.

 D.

kulwinder banipal wrote:

 Hi,
   I am trying to parse XML file ( binary hex) but get an error. Code I am 
using is:
xsd = xmlTreeParse(system.file("exampleData", "norel.xsd", package = "XML"), isSchema =TRUE) doc = 
xmlInternalTreeParse(system.file("exampleData", "LogCallSummary.bin", package = "XML")) Start tag expected, 
'<' not found

 xmlParse command results in same error as well: 
f = system.file("exampleData", "LogCallSummary.bin", package = "XML") > doc = xmlParse(f)Start tag expected, '<' not found
I am at beginner level with XML and will appreciate any help with this error or general guidance. 
Thanks 
Kulwinder Banipal


file is:
000: 0281 0001 0201 0098 c1d5 c000    010: 000a c0a8 db35 0055 6000 
00af 0001 0001  .5.U`...020: 5f00 2200 4530  4411 2233 4455 0f08  
_.".E0..D."3DU..030: 0123 4567 8901 2340  04d2    .#eg...@040: 
  0002 0100 0001 0003 0303   050:   0100  6400  0100 
  d...060: 6401 0300 0900 00fe fe00 012f 0001   d../070: 0101 
0001   0001  2200 0033  "..3080: 3306   0022  1100  
  3...33."090: 0033 3400 2300 0011  0001  3335  .34.#.350a0: 
0024  1100  0200 0033 3600 2500  .$.36.%.0b0: 0011  0003  3337 0026  
1100  37.&0c0:  0400 0033 3800 2700 0011  0005  .38.'...0d0: 
5504 7700 8800 0044 4406  2323 0099  U.wDD...##..0e0: 0100 0200   0023 2400 9901 
0002  .#$...

...0f0:  0001  2325 0099 0100 0200   ..#%100: 0200 0023 2600 9901 
0002  0003   ...#&...110: 2327 0099 0100 0200  0400 0023 2800  
#'...#(.120: 9901 0002  0005 0102 0008 0100 0066  ...f130: 6600 
0055 5533   3400  0a35  f..UU345140:  0014 3600  1e37  0028 
3800  67...(8.150:  3239  003c 3a00  463b   
..29...<:...F;..160: 0050 3c00  5a00 0088 8800 0077 7744  .P<...Z..wwD170: 
  4500  0a46  0014 4700  EFG.180:  1e48  0028 4900  
324a   ...H...(I...2J..190: 003c 4b00  464c  0050 4d00   
.

_
Hotmail® goes with you. 


ial_Mobile1_052009
[[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] Problems with sample variance

2009-05-20 Thread Peter Alspach
Tena koe Chloe

Try

var(r) 

BTW, it is better to use more than single letters in name your objects
to reduce the chance of conflicting with a standard R object.

HTH ...

Peter Alspach

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Chloe Smith
> Sent: Thursday, 21 May 2009 12:33 p.m.
> To: r-help@r-project.org
> Subject: [R] Problems with sample variance
> 
> 
> Dear R users,
> 
> I am a beginner to R. I generated 1000 samples with 15 data 
> in each sample
> 
> I tried finding the variance for each sample
> 
> I used the code:
> 
> m=1000;n=15
> > r<-rnorm(15000)
> > for(i in 1:m){
> x=data[,i]
> v=var(x)}
> 
> what I got was just the variance for the last sample i.e. the 
> 1000th sample
> 
> but what I want is 1000 variance.
> 
> Does anyone know what I did wrong?
> 
> Thanks
> 
> Chloe Smith
> 
> --
> View this message in context: 
> http://www.nabble.com/Problems-with-sample-variance-tp23645919
> p23645919.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.
> 

The contents of this e-mail are confidential and may be subject to legal 
privilege.
 If you are not the intended recipient you must not use, disseminate, 
distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received 
this
 e-mail in error, please notify the sender and delete all material pertaining 
to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the 
individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Problems with sample variance

2009-05-20 Thread Chloe Smith

Dear R users,

I am a beginner to R. I generated 1000 samples with 15 data in each sample

I tried finding the variance for each sample

I used the code:

m=1000;n=15
> r<-rnorm(15000)
> for(i in 1:m){
x=data[,i]
v=var(x)}

what I got was just the variance for the last sample i.e. the 1000th sample

but what I want is 1000 variance.

Does anyone know what I did wrong?

Thanks

Chloe Smith

-- 
View this message in context: 
http://www.nabble.com/Problems-with-sample-variance-tp23645919p23645919.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] Re order variables in a dataframe

2009-05-20 Thread pgseye

Thanks Simon,

I should have explained myself better (although I didn't know about the
order function so that's handy information).

I've found a few times, I've added variables to a dataframe that I would
like to 'group' with variables earlier in the datset. So I was wondering if
you could somehow ask R, for example, to take that last variable and insert
it at a different position in the dataframe.

Thanks,

Paul

Simon Blomberg-4 wrote:
> 
> Alphabetically, like this?:
> 
>> dat <- data.frame(d=rnorm(3), c=rnorm(3), b=rnorm(3), a=rnorm(3))
>> dat
>d  c  b a
> 1 -0.1816733 -0.4106008 -0.2855991 -1.022951
> 2 -1.8326818 -0.6515208  0.3344884 -2.191836
> 3  1.0924867  0.1159611 -1.3409719  1.195545
>> dat2 <- dat[,order(names(dat))]
>> dat2
>   a  b  c  d
> 1 -1.022951 -0.2855991 -0.4106008 -0.1816733
> 2 -2.191836  0.3344884 -0.6515208 -1.8326818
> 3  1.195545 -1.3409719  0.1159611  1.0924867
>> 
> 
> Cheers,
> 
> Simon.
> 
> On Wed, 2009-05-20 at 20:19 -0700, pgseye wrote:
>> This is no doubt a very basic question for most R users, but is there an
>> easy
>> way to reorder the variables (columns) in a dataframe (I can't seem to
>> find
>> an answer anywhere). I've generally been creating a new dataframe and
>> selecting the new order I want from the old but this is time-consuming.
>> 
>> Thanks,
>> 
>> Paul
> -- 
> Simon Blomberg, BSc (Hons), PhD, MAppStat. 
> Lecturer and Consultant Statistician 
> School of Biological Sciences
> The University of Queensland 
> St. Lucia Queensland 4072 
> Australia
> Room 320 Goddard Building (8)
> T: +61 7 3365 2506
> http://www.uq.edu.au/~uqsblomb
> email: S.Blomberg1_at_uq.edu.au
> 
> Policies:
> 1.  I will NOT analyse your data for you.
> 2.  Your deadline is your problem.
> 
> 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.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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/Reorder-variables-in-a-dataframe-tp23647222p23647370.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] Re order variables in a dataframe

2009-05-20 Thread Simon Blomberg
Alphabetically, like this?:

> dat <- data.frame(d=rnorm(3), c=rnorm(3), b=rnorm(3), a=rnorm(3))
> dat
   d  c  b a
1 -0.1816733 -0.4106008 -0.2855991 -1.022951
2 -1.8326818 -0.6515208  0.3344884 -2.191836
3  1.0924867  0.1159611 -1.3409719  1.195545
> dat2 <- dat[,order(names(dat))]
> dat2
  a  b  c  d
1 -1.022951 -0.2855991 -0.4106008 -0.1816733
2 -2.191836  0.3344884 -0.6515208 -1.8326818
3  1.195545 -1.3409719  0.1159611  1.0924867
> 

Cheers,

Simon.

On Wed, 2009-05-20 at 20:19 -0700, pgseye wrote:
> This is no doubt a very basic question for most R users, but is there an easy
> way to reorder the variables (columns) in a dataframe (I can't seem to find
> an answer anywhere). I've generally been creating a new dataframe and
> selecting the new order I want from the old but this is time-consuming.
> 
> Thanks,
> 
> Paul
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
School of Biological Sciences
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

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.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 order variables in a dataframe

2009-05-20 Thread pgseye

This is no doubt a very basic question for most R users, but is there an easy
way to reorder the variables (columns) in a dataframe (I can't seem to find
an answer anywhere). I've generally been creating a new dataframe and
selecting the new order I want from the old but this is time-consuming.

Thanks,

Paul
-- 
View this message in context: 
http://www.nabble.com/Reorder-variables-in-a-dataframe-tp23647222p23647222.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] lmodel2 - regression through origin?

2009-05-20 Thread ekwaters

Hi all, 

is regression through the origin possible at all using lmodel2?

I tried the standard technique of inserting a minus 1 into the formula to
get regression through the origin in R, but the output still gives me an
intercept?

For comparison, this is me trying to do regression through the origin:

> test2.res<-lmodel2(mcr~m-1, data=test, "interval", "interval", nperm=99)
> test2.res

Model II regression

Call: lmodel2(formula = mcr ~ m - 1, data = test, range.y = "interval",
range.x = "interval", nperm = 99)

n = 13   r = 0.9801157   r-square = 0.9606268
Parametric P-values:   2-tailed = 4.491109e-091-tailed = 2.245554e-09
Angle between the two OLS regression lines = 0.440334 degrees

Permutation tests of OLS, MA, RMA slopes: 1-tailed, tail corresponding to
sign
A permutation test of r is equivalent to a permutation test of the OLS slope
P-perm for SMA = NA because the SMA slope cannot be tested

Regression results
  Method  Intercept Slope  Angle (degrees)  P-perm (1-tailed)
1OLS -0.1053969  4.928172 78.52957   0.01
2 MA -0.1261714  5.122467 78.95373   0.01
3SMA -0.1160872  5.028153 78.75177 NA
4RMA -0.1167458  5.034313 78.76519   0.01

and below is the output and formula input when I omit the -1. Does lmodel2
function/ package not understand what I want?

> test1.res<-lmodel2(mcr~m, data=test, "interval", "interval", nperm=99)
> test1.res

Model II regression

Call: lmodel2(formula = mcr ~ m, data = test, range.y = "interval",
range.x = "interval", nperm = 99)

n = 13   r = 0.9801157   r-square = 0.9606268
Parametric P-values:   2-tailed = 4.491109e-091-tailed = 2.245554e-09
Angle between the two OLS regression lines = 0.440334 degrees

Permutation tests of OLS, MA, RMA slopes: 1-tailed, tail corresponding to
sign
A permutation test of r is equivalent to a permutation test of the OLS slope
P-perm for SMA = NA because the SMA slope cannot be tested

Regression results
  Method  Intercept Slope  Angle (degrees)  P-perm (1-tailed)
1OLS -0.1053969  4.928172 78.52957   0.01
2 MA -0.1261714  5.122467 78.95373   0.01
3SMA -0.1160872  5.028153 78.75177 NA
4RMA -0.1167458  5.034313 78.76519   0.01

Ned
-- 
View this message in context: 
http://www.nabble.com/lmodel2---regression-through-origin--tp23646915p23646915.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] Problems with sample variance

2009-05-20 Thread Ben Bolker



Chloe Smith wrote:
> 
> 
> [snip]
> 
> what I got was just the variance for the last sample i.e. the 1000th
> sample
> 
> but what I want is 1000 variance.
> 
> 

m=1000;n=15
r<-matrix(rnorm(m*n),nrow=m)
apply(r,1,var)


-- 
View this message in context: 
http://www.nabble.com/Problems-with-sample-variance-tp23645919p23646590.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Duncan Murdoch

On 20/05/2009 10:01 AM, cr...@binghamton.edu wrote:

For Google searches, I find that throwing in the term cran on every search 
helps weed out irrelevant pages.

For example, instead of 


r residuals

I type

r cran residuals


You are very picky.  When I enter

R residuals

into Google, 8 out of the first 10 hits are for R topics.  Isn't that 
good enough for you?


I think this is true of most Google searches:  the letter R most often 
means the R project.


Duncan Murdoch



--Chris Ryan

 Original message 

Date: Wed, 20 May 2009 09:43:14 -0400
From: Luc Villandre   
Subject: Re: [R] How to google for R stuff?  
To: Kynn Jones 

Cc: r-help@r-project.org


Kynn Jones wrote:

Hi!  I'm new to R programming, though I've been programming in other
languages for years.

One thing I find most frustrating about R is how difficult it is to use
Google (or any other search tool) to look for answers to my R-related
questions.  With languages with even slightly more distinctive names like
Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
language in the query is enough to ensure that the top hits are relevant.
 But this trick does not work for R, because the letter R appears by itself
in so many pages, that the chaff overwhelms the wheat, so to speak.

So I'm curious to learn what strategies R users have found to get around
this annoyance.

TIA!

KJ

[[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 Kynn,

I've had this problem too in the beginning. Luckily, my personal 
experience has taught me that almost all relevant R-related information 
can be found either by searching directly through the archives of the 
different R-forums or by using the functions "RSiteSearch()" or 
"help.search()". The reference manuals provided with each package 
(easily accessible on CRAN) are also invaluable sources of information.


Unfortunately, phrasing queries in a way that will yield relevant 
results is sometimes hard. Knowledge of the terminology mostly comes 
from experience, so patience is in order.

Of course, as a last recourse, there's always the mailing list.

Bottom line is, I suggest you try to avoid generic search engines and 
concentrate your efforts on the different R-forums (note that there are 
also package-specific forums).


I suspect the more experienced R-users might have better strategies to 
propose though...


Cheers,
--
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/

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


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


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


Re: [R] evaluate polynomial

2009-05-20 Thread Rolf Turner


On 21/05/2009, at 11:35 AM, Kon Knafelman wrote:



Hey guys, sorry im drawing a mental blank.



i have coded the function:



y <- function(x) 6*x^4-(1*x^2)^3



How do i evaluate this function for a given x?



i know this is a ridiculous question, but thanks anyway


> y(1.6)

or

> x <- 1.6
> y(x)

or

> fred <- 1.6
> y(fred)

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] evaluate polynomial

2009-05-20 Thread Peter Alspach
Tena koe Kon

y(1)
y(2) and so on.  Or even y(1:5).

HTH ...

Peter Alspach 

> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Kon Knafelman
> Sent: Thursday, 21 May 2009 11:35 a.m.
> To: r-help@r-project.org
> Subject: [R] evaluate polynomial
> 
> 
> Hey guys, sorry im drawing a mental blank.
> 
>  
> 
> i have coded the function:
> 
>  
> 
> y <- function(x) 6*x^4-(1*x^2)^3
> 
>  
> 
> How do i evaluate this function for a given x?
> 
>  
> 
> i know this is a ridiculous question, but thanks anyway
> 
> _
> [[elided Hotmail spam]]
> 
> [[elided Hotmail spam]]
> =Domain_tagline&_m=EXT
>   [[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.
> 

The contents of this e-mail are confidential and may be subject to legal 
privilege.
 If you are not the intended recipient you must not use, disseminate, 
distribute or
 reproduce all or any part of this e-mail or attachments.  If you have received 
this
 e-mail in error, please notify the sender and delete all material pertaining 
to this
 e-mail.  Any opinion or views expressed in this e-mail are those of the 
individual
 sender and may not represent those of The New Zealand Institute for Plant and
 Food Research Limited.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] evaluate polynomial

2009-05-20 Thread Kon Knafelman

Hey guys, sorry im drawing a mental blank.

 

i have coded the function:

 

y <- function(x) 6*x^4-(1*x^2)^3

 

How do i evaluate this function for a given x?

 

i know this is a ridiculous question, but thanks anyway

_
[[elided Hotmail spam]]

[[elided Hotmail spam]]
=Domain_tagline&_m=EXT
[[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] Asymmetric t-copula code?

2009-05-20 Thread Roslina Zakaria
Hi R-users,

Anybody got any idea where can I find the code for asymmetric t-copula?

I found the copula package written by Jun Yan.

Thank you so much for any help given.


  
[[alternative HTML version deleted]]

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


Re: [R] how to get remote ESS graphics to work?

2009-05-20 Thread Matthew Keller
Hi all,

I figured out how to get this to work. Not saying this is the best way
to do it, but it is working for me. The only problem is that the
graphics are very slow (several seconds to draw hist(rnorm(50))!)

First, I changed both /etc/ssh_config and /etc/ssh_configd to allow
X11 forwarding (i.e., emacs into those files, find the ForwardAgent
and ForwardX11 lines, and change these from "no" to "yes").

Then I used the -X option when ssh'ing into the remote machine:

ssh -X myn...@remotecomp.

Then I started R remotely. Within the remote R session, I changed the
default graphics device from 'quartz' to 'x11':
options(device='x11')

That's it. It is working, but as I said, is surprisingly slow. Not
sure why that is. Does anyone have more experience with graphics
remotely? Are they typically slow, or is it my connection, or perhaps
a setting?

Best,

Matt



On Wed, May 20, 2009 at 3:13 PM, Matthew Keller  wrote:
> Hi all,
>
> My graduate student is logging onto my macpro and running R through
> ESS aquamacs (with Mx ssh and then  Mx ess-remote). Everything is
> working fine until we get to graphing.
>
>  We are trying to give him the ability to look at graphics
> interactively. The ESS manual is not too helpful: "If you run X11 (See
> Section 13.3.2 [X11], page 68, X-windows) on both the local and remote
> machines then you should be able to display the graphs locally by
> setting the ‘DISPLAY’ environment variable appropriately."
>
> It's unclear what DISPLAY is appropriate. I have X11 forwarding set up
> on my machine (the remote machine). When we try to create a graphic in
> his ESS remote process, (e.g., hist(rnorm(50))), we get the following
> error:
> "Error in X11(...
> unable to start device X11cairo
> In addition: Warning message:
> In x11(): unable to open connection to X11 display"
>
> Does anyone out there use interactive graphics on their ESS remote
> sessions? If so, could you provide any help? We're really stuck and
> just need a step-by-step from anyone who knows.
>
> Thank you,
>
> Matt
>
>
>
>
> --
> Matthew C Keller
> Asst. Professor of Psychology
> University of Colorado at Boulder
> www.matthewckeller.com
>



-- 
Matthew C Keller
Asst. Professor of Psychology
University of Colorado at Boulder
www.matthewckeller.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] XML parse error

2009-05-20 Thread kulwinder banipal

 Hi,
   I am trying to parse XML file ( binary hex) but get an error. Code I am 
using is:
xsd = xmlTreeParse(system.file("exampleData", "norel.xsd", package = "XML"), 
isSchema =TRUE) doc = xmlInternalTreeParse(system.file("exampleData", 
"LogCallSummary.bin", package = "XML")) Start tag expected, '<' not found

 xmlParse command results in same error as well: 
f = system.file("exampleData", "LogCallSummary.bin", package = "XML") > doc = 
xmlParse(f)Start tag expected, '<' not found
I am at beginner level with XML and will appreciate any help with this error or 
general guidance. 
Thanks 
Kulwinder Banipal

file is:
000: 0281 0001 0201 0098 c1d5 c000    010: 000a 
c0a8 db35 0055 6000 00af 0001 0001  .5.U`...020: 5f00 2200 4530 
 4411 2233 4455 0f08  _.".E0..D."3DU..030: 0123 4567 8901 2340  
04d2    .#eg...@040:   0002 0100 0001 0003 0303 
  050:   0100  6400  0100   
d...060: 6401 0300 0900 00fe fe00 012f 0001   
d../070: 0101 0001   0001  2200 0033  
"..3080: 3306   0022  1100    
3...33."090: 0033 3400 2300 0011  0001  3335  
.34.#.350a0: 0024  1100  0200 0033 3600 2500  
.$.36.%.0b0: 0011  0003  3337 0026  1100  
37.&0c0:  0400 0033 3800 2700 0011  0005  
.38.'...0d0: 5504 7700 8800 0044 4406  2323 0099  
U.wDD...##..0e0: 0100 0200   0023 2400 9901 0002  
.#$.0f0:  0001  2325 0099 0100 0200   
..#%100: 0200 0023 2600 9901 0002  0003   
...#&...110: 2327 0099 0100 0200  0400 0023 2800  
#'...#(.120: 9901 0002  0005 0102 0008 0100 0066  
...f130: 6600 0055 5533   3400  0a35  
f..UU345140:  0014 3600  1e37  0028 3800  
67...(8.150:  3239  003c 3a00  463b   
..29...<:...F;..160: 0050 3c00  5a00 0088 8800 0077 7744  
.P<...Z..wwD170:   4500  0a46  0014 4700  
EFG.180:  1e48  0028 4900  324a   
...H...(I...2J..190: 003c 4b00  464c  0050 4d00   
.__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 xYplot with map

2009-05-20 Thread eric.archer
I'll retract my request for help.  I managed to solve the problem by 
calling map followed by a call to points after rescaling the cex.  Its 
the kind of solution that deserves a head-slap.


library(Hmisc)
library(maps)

sample.data <- data.frame(lat = c(12.1667, 14.6333, -6.874, 2.6167, 14.6833,
11.2, 3.2667, 11.4167, -13.8623, 13.1667), lon = c(-126.25, -103.4667,
-88.4572, -93.65, -97.7, -88.65, -111.0167, -119.7333, -100.0748,
-108.0333), exp.index = c(23.6266244576543, 2.06824648038330,
0, 1.46378849121688, 24.1824663424805, 0, 0.364600074527829,
4.468039274638, 0.543833744085446, 18.2301918845932))

xlim <- c(-150, -80)
ylim <- c(-5, 30)
cex.range <- c(1, 5)
exp.range <- range(sample.data$exp.index)
exp.cex <- diff(cex.range) * sample.data$exp.index / exp.range[2] + 
cex.range[1]

map("world", fill = TRUE, col = "gray", xlim = xlim, ylim = ylim)
points(sample.data$lon, sample.data$lat, pch = 21, cex = exp.cex)



eric.archer wrote:
I'm using xYplot to create a bubble plot of values that I'd like to 
visualize on top of a filled-in map of the coast, but I'm too much of 
a lattice (which I understand xYplot is built on) and mapping newbie 
to figure out how to begin to make this happen.  Below is some sample 
code that doesn't work but illustrates my goal.  Any pointers anyone 
has would be much appreciated.  I'm using R v2.9.0 on Windows with 
Hmisc v3.6-0 and maps v2.1-0.


Cheers,
eric

library(Hmisc)
library(maps)

sample.data <- data.frame(lat = c(12.1667, 14.6333, -6.874, 2.6167, 
14.6833,

11.2, 3.2667, 11.4167, -13.8623, 13.1667), lon = c(-126.25, -103.4667,
-88.4572, -93.65, -97.7, -88.65, -111.0167, -119.7333, -100.0748,
-108.0333), exp.index = c(23.6266244576543, 2.06824648038330,
0, 1.46378849121688, 24.1824663424805, 0, 0.364600074527829,
4.468039274638, 0.543833744085446, 18.2301918845932))

xlim <- c(-150, -80)
ylim <- c(-5, 30)
print(xYplot(lat ~ lon, data = sample.data, size = sample.data$exp.index,
xlim = xlim, ylim = ylim
))
map("world", fill = TRUE, col = "gray", xlim = xlim, ylim = ylim, add 
= TRUE)




--

Eric Archer, Ph.D.
Southwest Fisheries Science Center
National Marine Fisheries Service
 North Torrey Pines Court
La Jolla, CA 92037-1022
858-546-7121 (work)
858-546-7003 (FAX)

ETP Cetacean Assessment Program: http://swfsc.noaa.gov/prd-etp.aspx
Population ID Program: http://swfsc.noaa.gov/prd-popid.aspx 



"Innocence about Science is the worst crime today."
  - Sir Charles Percy Snow

"Lighthouses are more helpful than churches."
  - Benjamin Franklin

  "...but I'll take a GPS over either one."
  - John C. "Craig" George

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 re: max(i), but code and output seen O.K.

2009-05-20 Thread David Scott

On Wed, 20 May 2009, Kirsten Miles wrote:


I have a researcher who is consistently get the warning message:

In max(i) : no non-missing arguments to max; returning -Inf



You get this message when trying to take the maximum of a vector with no 
elements. I am guessing he is looping through and in some cases getting an 
empty vector.



x <- numeric(0)
max(x)

[1] -Inf
Warning message:
In max(x) : no non-missing arguments to max; returning -Inf


David Scott





Best as I can tell the code is working properly and the output is as
expected. I would like some help in understanding why he is getting this
error message and what its implications are.  I have his code.

Sincerely,
Kirsten Miles
Support Specialist
Research Computing Lab
Charles L. Brown Science and Engineering Library

kd...@virginia.edu

[[alternative HTML version deleted]]

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



_
David Scott Department of Statistics
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 923 5055, or +64 9 373 7599 ext 85055
Email:  d.sc...@auckland.ac.nz,  Fax: +64 9 373 7018

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] round function seems to produce maximum 2 decimals

2009-05-20 Thread Ben Bolker



Glenn E Stauffer wrote:
> 
> I am trying to use round()to force R to display a specific number of
> decimals, but it seems to display <=2 decimals no matter what I specify in
> the digits argument. As an alternative I tried signif(), but it also
> produces unexpected results. See example code and results below. Format()
> works, but then the result no longer is numeric. Am I missing something
> simple?
> I am using R 2.9.0 on Windows XP. 
> Thanks,
> Glenn
> 
> #code
> h=12345.16711
> h
> 
> round(h,digits=1)
> round(h,digits=2)
> round(h,digits=3)
> round(h,digits=4)
> round(h,digits=5)
> 
> signif(h,digits=9)
> 
> format(h,nsmall=4)
> 
> #results
>> h=12345.16711
>> h
> [1] 12345.17
>> round(h,digits=1)
> [1] 12345.2
>> round(h,digits=2)
> [1] 12345.17
>> round(h,digits=3)
> [1] 12345.17
>> round(h,digits=4)
> [1] 12345.17
>> round(h,digits=5)
> [1] 12345.17
>> signif(h,digits=9)
> [1] 12345.17
>> 
>> format(h,nsmall=4)
> [1] "12345.1671"
> 
> 

options("digits") is set to 7 by default.

> h <- 12345.16711
> round(h,digits=5)
[1] 12345.17
> print(h,digits=12)
[1] 12345.16711
> options(digits=12)
> round(h,digits=5)
[1] 12345.16711
> round(h,digits=4)
[1] 12345.1671
> round(h,digits=3)
[1] 12345.167
> round(h,digits=2)
[1] 12345.17

-- 
View this message in context: 
http://www.nabble.com/round-function-seems-to-produce-maximum-2-decimals-tp23643311p23643853.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] round function seems to produce maximum 2 decimals

2009-05-20 Thread Ted Harding
On 20-May-09 20:10:15, Glenn E Stauffer wrote:
> I am trying to use round()to force R to display a specific number
> of decimals, but it seems to display <=2 decimals no matter what I
> specify in the digits argument. As an alternative I tried signif(),
> but it also produces unexpected results. See example code and results
> below.
> Format() works, but then the result no longer is numeric. Am I missing
> something simple?
> I am using R 2.9.0 on Windows XP. 
> Thanks,
> Glenn
> 
>#code
> h=12345.16711
> h
> 
> round(h,digits=1)
> round(h,digits=2)
> round(h,digits=3)
> round(h,digits=4)
> round(h,digits=5)
> 
> signif(h,digits=9)
> 
> format(h,nsmall=4)
> 
>#results
>> h=12345.16711
>> h
> [1] 12345.17
>> round(h,digits=1)
> [1] 12345.2
>> round(h,digits=2)
> [1] 12345.17
>> round(h,digits=3)
> [1] 12345.17
>> round(h,digits=4)
> [1] 12345.17
>> round(h,digits=5)
> [1] 12345.17
>> signif(h,digits=9)
> [1] 12345.17
>> 
>> format(h,nsmall=4)
> [1] "12345.1671"

What you're missing is that when you do (e.g.)

  h <- 12345.16711
  round(h,digits=4)
# [1] 12345.17

what is displayed ("[1] 12345.17") is not the result of round(),
but what the result of round() is to be displayed as given the
options digits=7 (default) for the number of *significant figures*
in the display of stored values.

To see the result as it is stored, you should use print() with
the appropriate number of disgits specified:

  print( round(h,digits=5),10)
# [1] 12345.16711
  print( round(h,digits=4),10)
# [1] 12345.1671
  print( round(h,digits=3),10)
# [1] 12345.167
  print( round(h,digits=2),10)
# [1] 12345.17

Internally, round(h) is correctly stored:

  h4 <- round(h,4)
  h - h4
# [1] 1e-05
  h3 <- round(h,3)
  h - h3
# [1] 0.00011
  h2 <- round(h,2)
  h - h2
# [1] -0.00289

To illustrate the influence of the display option digits=7:

  h<-45.16711
  h
# [1] 45.16711
  round(h,digits=4)
# [1] 45.1671
   round(h,digits=3)
# [1] 45.167
  round(h,digits=2)
# [1] 45.17

  h<-345.16711
  h
# [1] 345.1671
   round(h,digits=4)
# [1] 345.1671
   round(h,digits=3)
# [1] 345.167
   round(h,digits=2)
# [1] 345.17

  h<-2345.16711
  h
# [1] 2345.167
  round(h,digits=4)
# [1] 2345.167
   round(h,digits=3)
# [1] 2345.167
  round(h,digits=2)
# [1] 2345.17

Hoping this helps,
Ted.


E-Mail: (Ted Harding) 
Fax-to-email: +44 (0)870 094 0861
Date: 20-May-09   Time: 22:54:41
-- XFMail --

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 xYplot with map

2009-05-20 Thread eric.archer
I'm using xYplot to create a bubble plot of values that I'd like to 
visualize on top of a filled-in map of the coast, but I'm too much of a 
lattice (which I understand xYplot is built on) and mapping newbie to 
figure out how to begin to make this happen.  Below is some sample code 
that doesn't work but illustrates my goal.  Any pointers anyone has 
would be much appreciated.  I'm using R v2.9.0 on Windows with Hmisc 
v3.6-0 and maps v2.1-0.


Cheers,
eric

library(Hmisc)
library(maps)

sample.data <- data.frame(lat = c(12.1667, 14.6333, -6.874, 2.6167, 
14.6833,

11.2, 3.2667, 11.4167, -13.8623, 13.1667), lon = c(-126.25, -103.4667,
-88.4572, -93.65, -97.7, -88.65, -111.0167, -119.7333, -100.0748,
-108.0333), exp.index = c(23.6266244576543, 2.06824648038330,
0, 1.46378849121688, 24.1824663424805, 0, 0.364600074527829,
4.468039274638, 0.543833744085446, 18.2301918845932))

xlim <- c(-150, -80)
ylim <- c(-5, 30)
print(xYplot(lat ~ lon, data = sample.data, size = sample.data$exp.index,
xlim = xlim, ylim = ylim
))
map("world", fill = TRUE, col = "gray", xlim = xlim, ylim = ylim, add = 
TRUE)


--

Eric Archer, Ph.D.
Southwest Fisheries Science Center
National Marine Fisheries Service
 North Torrey Pines Court
La Jolla, CA 92037-1022
858-546-7121 (work)
858-546-7003 (FAX)

ETP Cetacean Assessment Program: http://swfsc.noaa.gov/prd-etp.aspx
Population ID Program: http://swfsc.noaa.gov/prd-popid.aspx 



"Innocence about Science is the worst crime today."
  - Sir Charles Percy Snow

"Lighthouses are more helpful than churches."
  - Benjamin Franklin

  "...but I'll take a GPS over either one."
  - John C. "Craig" George

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Emmanuel Charpentier
Le mercredi 20 mai 2009 à 09:02 -0400, Kynn Jones a écrit :
> Hi!  I'm new to R programming, though I've been programming in other
> languages for years.
> 
> One thing I find most frustrating about R is how difficult it is to use
> Google (or any other search tool) to look for answers to my R-related
> questions.  With languages with even slightly more distinctive names like
> Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
> language in the query is enough to ensure that the top hits are relevant.
>  But this trick does not work for R, because the letter R appears by itself
> in so many pages, that the chaff overwhelms the wheat, so to speak.
> 
> So I'm curious to learn what strategies R users have found to get around
> this annoyance.

ISTR having this question or very close ones at least thrice in the last
two months.

Time for a FAQ entry ? (It does not seem to exist : I checked...)

Emmanuel Charpentier

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Example for parsing XML file?

2009-05-20 Thread Wacek Kusnierczyk
Brigid Mooney wrote:
> Hi,
>
> I am trying to parse XML files and read them into R as a data frame,
> but have been unable to find examples which I could apply
> successfully.
>
> I'm afraid I don't know much about XML, which makes this all the more
> difficult.  If someone could point me in the right direction to a
> resource (preferably with an example or two), it would be greatly
> appreciated.
>
> Here is a snippet from one of the XML files that I am looking to read,
> and I am aiming to be able to get it into a data frame with columns N,
> T, A, B, C as in the 2nd level of the heirarchy.
>   

There might be a simpler approach, but this seems to do:

library(XML)

input = xmlParse(
'
  
  
  
  
  
  
  
  
  
')

(output = data.frame(t(xpathSApply(input, '//T', xpathSApply, '@*'
#  N  T A B C
# 1 1 9:30:13 AM 30.05 29.85 30.05
# 2 2 9:31:05 AM 29.89 29.78 30.05
# 3 3 9:31:05 AM  29.9 29.86 29.87
# 4 4 9:31:05 AM 29.86 29.86 29.87
# 5 5 9:31:05 AM 29.89 29.86 29.87
# 6 6 9:31:06 AM 29.89 29.85 29.86
# 7 7 9:31:06 AM 29.89 29.85 29.86
# 8 8 9:31:06 AM 29.89 29.85 29.86

output$N
# [1] 1 2 3 4 5 6 7 8
# Levels: 1 2 3 4 5 6 7 8

you may need to reformat the columns.

vQ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Example for parsing XML file?

2009-05-20 Thread Duncan Temple Lang

Hi Brigid.

Here are a few commands that should do what you want:

bri = xmlParse("myDataFile.xml")

tmp =  t(xmlSApply(xmlRoot(bri), xmlAttrs))[, -1]
dd = as.data.frame(tmp, stringsAsFactors = FALSE,
row.names = 1:nrow(tmp))

And then you can convert the columns to whatever types you want
using regular R commands.

The basic idea is that for each of the child nodes of C,
i.e. the 's, we want the character vector of attributes
which we can get with xmlAttrs().

Then we stack them together into a matrix, drop the "N"
and then convert the result to a data frame, avoiding
duplicate row names which are all "T".

(BTW, make certain the '-' on the second line is not in the XML content.
 I assume that came from bringing the text into mail.)

HTH
  D.


Brigid Mooney wrote:

Hi,

I am trying to parse XML files and read them into R as a data frame,
but have been unable to find examples which I could apply
successfully.

I'm afraid I don't know much about XML, which makes this all the more
difficult.  If someone could point me in the right direction to a
resource (preferably with an example or two), it would be greatly
appreciated.

Here is a snippet from one of the XML files that I am looking to read,
and I am aiming to be able to get it into a data frame with columns N,
T, A, B, C as in the 2nd level of the heirarchy.

  
- 
  
  
  
  
  
  
  
  


Thanks for any help or direction anyone can provide.

As a point of reference, I am using R 2.8.1 and have loaded the XML package.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] how to get remote ESS graphics to work?

2009-05-20 Thread Matthew Keller
Hi all,

My graduate student is logging onto my macpro and running R through
ESS aquamacs (with Mx ssh and then  Mx ess-remote). Everything is
working fine until we get to graphing.

 We are trying to give him the ability to look at graphics
interactively. The ESS manual is not too helpful: "If you run X11 (See
Section 13.3.2 [X11], page 68, X-windows) on both the local and remote
machines then you should be able to display the graphs locally by
setting the ‘DISPLAY’ environment variable appropriately."

It's unclear what DISPLAY is appropriate. I have X11 forwarding set up
on my machine (the remote machine). When we try to create a graphic in
his ESS remote process, (e.g., hist(rnorm(50))), we get the following
error:
"Error in X11(...
unable to start device X11cairo
In addition: Warning message:
In x11(): unable to open connection to X11 display"

Does anyone out there use interactive graphics on their ESS remote
sessions? If so, could you provide any help? We're really stuck and
just need a step-by-step from anyone who knows.

Thank you,

Matt




-- 
Matthew C Keller
Asst. Professor of Psychology
University of Colorado at Boulder
www.matthewckeller.com

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Kynn Jones
Thank you all very much for the so many useful ideas and resources.
KJ

[[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 re: max(i), but code and output seen O.K.

2009-05-20 Thread Rolf Turner


On 21/05/2009, at 6:23 AM, Kirsten Miles wrote:


I have a researcher who is consistently get the warning message:

In max(i) : no non-missing arguments to max; returning -Inf

Best as I can tell the code is working properly and the output is as
expected. I would like some help in understanding why he is getting  
this

error message and what its implications are.  I have his code.


(a) This is not an error message, it is a warning message.

(b) The message says that, in a particular context, all of the
arguments to max() are missing.  Hence you are taking the maximum
of the empty set.  By definition this maximum is -infinity.  (This
makes good sense when you think about it carefully.)

(c) What the implications are is hard to say without knowing what the
code is actually doing.  You say that the output is as expected; this
*probably* means that the definition of the maximum of the empty set
is meshing as it should with the remainder of the calculations.

However if I were doing it, I'd track down the instance where all
of the arguments to max are missing and make sure that the code
really is doing the right thing.  You have to decide what *is*
the right thing.  What *should* happen if all of the arguments are NA?

One way to start tracking down the instance would be to set

options(warn=2)

to change the warning to a real error, and then use traceback() to
see where the error occurred.

cheers,

Rolf Turner

##
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] minmun p-value for wilcox.test and correlation

2009-05-20 Thread Peter Dalgaard

charles78 wrote:

I have a stupid question on how to get the real p-values for wilcox.test and
correlation.  the minmun can be reached is 2.2E-16 using the R version
2.6.2.  I do not think it is the R version causing this but other issues.

Any help is highly appreciated.

Charles


It's mainly a printing issue (and to some extent historical, because 
small p-values in the upper tail were generated by subtraction and could 
underflow if < 2.2e-16):


> wilcox.test(1:100,101:200)

Wilcoxon rank sum test with continuity correction

data:  1:100 and 101:200
W = 0, p-value < 2.2e-16
alternative hypothesis: true location shift is not equal to 0

> wilcox.test(1:100,101:200)$p.value
[1] 2.562144e-34

--
   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
~~ - (p.dalga...@biostat.ku.dk)  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 re: max(i), but code and output seen O.K.

2009-05-20 Thread Sundar Dorai-Raj
This error is thrown if the argument to max is either NULL or length zero:

[~] Rscript -e "max(NULL)"
[1] -Inf
Warning message:
In max(NULL) : no non-missing arguments to max; returning -Inf
[~] Rscript -e "max(numeric(0))"
[1] -Inf
Warning message:
In max(numeric(0)) : no non-missing arguments to max; returning -Inf

HTH,

--sundar

On Wed, May 20, 2009 at 11:23 AM, Kirsten Miles  wrote:
> I have a researcher who is consistently get the warning message:
>
> In max(i) : no non-missing arguments to max; returning -Inf
>
> Best as I can tell the code is working properly and the output is as
> expected. I would like some help in understanding why he is getting this
> error message and what its implications are.  I have his code.
>
> Sincerely,
> Kirsten Miles
> Support Specialist
> Research Computing Lab
> Charles L. Brown Science and Engineering Library
>
> kd...@virginia.edu
>
>        [[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] How to load data from Statistics Canada

2009-05-20 Thread Wacek Kusnierczyk
Peter Dalgaard wrote:
> g...@ucalgary.ca wrote:
>> We would like to load data from Statistics Canada
>> (http://www.statcan.gc.ca/) using R,
>> for example, Employment and unemployment rates.
>> It seems to me that the tables are displayed in HTML.
>> I was wondering if you know how to load these tables. Thanks,
>
> I suspect the answer is "with some difficulty". You can do stuff like
> this, based on using the clipboard. Go to

or maybe
   
library(XML)
document =
htmlParse('http://www.statcan.gc.ca/daily-quotidien/090520/t090520b1-eng.htm')
rows = xpathSApply(document, '//table/tbody/tr')

and then use further xpaths to extract the content of interest.

vQ

>
> http://www.statcan.gc.ca/daily-quotidien/090520/t090520b1-eng.htm
>
> mark the contents of the table, then
>
> > dd <- t(read.delim("clipboard", colClasses="character"))
> > dd1 <- dd[-1,] # 1st row are labels
> > dd2 <- as.numeric(gsub(",","",dd1)) # strip thousands separators
> Warning message:
> NAs introduced by coercion
> > dim(dd2) <- dim(dd1)
> > dd2
>  [,1]  [,2]  [,3]   [,4][,5] [,6]  [,7] [,8] [,9]   [,10]
> [,11]
> [1,]   NA 226.8 123.1 2948.0 11630.0 178768.0 122.5   NA 37.6 27822.0 
> 1.760
> [2,]   NA 224.6 117.7 2945.0 10709.0 181862.0 121.7   NA 37.1 28822.0 
> 1.750
> [3,]   NA 222.0 109.5 2932.0  9694.0 185068.0 121.1   NA 36.9 27801.0 
> 1.730
> [4,]   NA 218.8 101.2 2924.0  8968.0 187636.0 120.6   NA 36.7 26560.0 
> 1.690
> [5,]   NA 215.6  97.2 2920.0  8759.0 189702.0 120.1   NA 36.4 23762.0 
> 1.640
> [6,]   NA 213.3  96.0 2918.0  8770.0 191343.0 119.7   NA 36.2 22029.0 
> 1.600
> [7,]   NA  -1.1  -1.2   -0.1 0.1  0.9  -0.3   NA -0.5-7.3
> -0.045
>  [,12]  [,13]  [,14] [,15]
> [1,]NA 2959.0 9637.0 221.8
> [2,]NA 2963.0 9635.0 218.4
> [3,]NA 2966.0 9587.0 217.1
> [4,]NA 2939.0 9368.0 211.2
> [5,]NA 2915.0 9325.0 209.4
> [6,]NA 2879.0 9199.0 210.5
> [7,]NA   -1.2   -1.4   0.5

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] round function seems to produce maximum 2 decimals

2009-05-20 Thread Glenn E Stauffer
I am trying to use round()to force R to display a specific number of
decimals, but it seems to display <=2 decimals no matter what I specify in
the digits argument. As an alternative I tried signif(), but it also
produces unexpected results. See example code and results below. Format()
works, but then the result no longer is numeric. Am I missing something
simple?
I am using R 2.9.0 on Windows XP. 
Thanks,
Glenn

#code
h=12345.16711
h

round(h,digits=1)
round(h,digits=2)
round(h,digits=3)
round(h,digits=4)
round(h,digits=5)

signif(h,digits=9)

format(h,nsmall=4)

#results
> h=12345.16711
> h
[1] 12345.17
> round(h,digits=1)
[1] 12345.2
> round(h,digits=2)
[1] 12345.17
> round(h,digits=3)
[1] 12345.17
> round(h,digits=4)
[1] 12345.17
> round(h,digits=5)
[1] 12345.17
> signif(h,digits=9)
[1] 12345.17
> 
> format(h,nsmall=4)
[1] "12345.1671"

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] minmun p-value for wilcox.test and correlation

2009-05-20 Thread Peter Flom
charles78  wrote 

>I have a stupid question on how to get the real p-values for wilcox.test and
>correlation.  the minmun can be reached is 2.2E-16 using the R version
>2.6.2.  I do not think it is the R version causing this but other issues.
>
>Any help is highly appreciated.
>

Can I ask why you want this?

I'm curious.

Peter

Peter L. Flom, PhD
Statistical Consultant
www DOT peterflomconsulting DOT 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] Non-linear regression with latent variable

2009-05-20 Thread Samiul Hasan

Hi 
Can anyone please suggest me a package where I can estimate a non-linear
regression model? One of the independent variables is latent or unobserved.
I have an indicator variable for this unobserved variable; however the
relationship is known to be non-linear also. In terms of equations my
problem is

y=f(latent, fixed) 
q=g(latent) where q is the indicator variable

For me both f and g are non-linear.

Thanks
Samiul Hasan


   
-- 
View this message in context: 
http://www.nabble.com/Non-linear-regression-with-latent-variable-tp23641833p23641833.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] Example for parsing XML file?

2009-05-20 Thread Brigid Mooney
Hi,

I am trying to parse XML files and read them into R as a data frame,
but have been unable to find examples which I could apply
successfully.

I'm afraid I don't know much about XML, which makes this all the more
difficult.  If someone could point me in the right direction to a
resource (preferably with an example or two), it would be greatly
appreciated.

Here is a snippet from one of the XML files that I am looking to read,
and I am aiming to be able to get it into a data frame with columns N,
T, A, B, C as in the 2nd level of the heirarchy.

  
- 
  
  
  
  
  
  
  
  


Thanks for any help or direction anyone can provide.

As a point of reference, I am using R 2.8.1 and have loaded the XML package.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 re: max(i), but code and output seen O.K.

2009-05-20 Thread Kirsten Miles
I have a researcher who is consistently get the warning message:

In max(i) : no non-missing arguments to max; returning -Inf

Best as I can tell the code is working properly and the output is as
expected. I would like some help in understanding why he is getting this
error message and what its implications are.  I have his code.

Sincerely,
Kirsten Miles
Support Specialist
Research Computing Lab
Charles L. Brown Science and Engineering Library

kd...@virginia.edu

[[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] sem with categorical data

2009-05-20 Thread Frank Lawrence
I am trying to run a confirmatory factor analysis using the SEM package.  My
data are ordinal.  I have read
http://socserv.mcmaster.ca/jfox/Misc/sem/SEM-paper.pdf.
When I apply the hetcor function, I receive the following error:
Error in checkmvArgs(lower = lower, upper = upper, mean = mean, corr = corr,
: 
  at least one element of 'lower' is larger than 'upper'

Example:
set.seed(781)
q1 <- cut2(x = rlnorm(n = 1e2, m = 2), cuts = seq(1,6))
q2 <- cut2(x = rlnorm(n = 1e2, m = 0), cuts = seq(1,6))
q3 <- cut2(x = rlnorm(n = 1e2, m = 1), cuts = seq(1,6))
dat <- data.frame(q1,q2,q3)
hetcor(data = dat, ML = T, pd = T, use = 'p')

Any help in understanding and correcting the error would be appreciated.

unlist(R.Version())
  platform   arch 
 "i386-pc-mingw32" "i386" 
os system 
 "mingw32""i386, mingw32" 
status  major 
"""2" 
 minor   year 
 "9.0" "2009" 
 monthday 
  "04"   "17" 
   svn rev   language 
   "48333""R" 
version.string 
"R version 2.9.0 (2009-04-17)"

Respectfully,

Frank Lawrence

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Predicting complicated GAMMs on response scale

2009-05-20 Thread William Paterson

Creation of Animal category in p.d solved all problems. Plots fine now. The
smallest hurdles are often the hardest to get over.


Gavin Simpson wrote:
> 
> On Mon, 2009-05-18 at 11:48 -0700, William Paterson wrote:
>> Hi,
>> 
>> I am using GAMMs to show a relationship of temperature differential over
>> time with a model that looks like this:-
>> 
>> gamm(Diff~s(DaysPT)+AirToC,method="REML") 
>> 
>> where DaysPT is time in days since injury and Diff is repeat measures of
>> temperature differentials with regards to injury sites compared to
>> non-injured sites in individuals over the course of 0-24 days. I use the
>> following code to plot this model on the response scale with 95% CIs
>> which
>> works fine:-
>> 
>> g.m<-gamm(Diff~s(DaysPT)+AirToC,method="REML")
>> p.d<-data.frame(DaysPT=seq(min(DaysPT),max(DaysPT)))
>> p.d$AirToC<-(6.7)
>> b<-predict.gam(g.m$gam,p.d,se=TRUE)
>> range<-c(min(b$fit-2*b$se.fit),max(b$fit+2*b$se.fit))
>> plot(p.d$DaysPT,b$fit,ylim=c(-4,12),xlab="Days post-tagging",ylab="dTmax
>> (ºC)",type="l",lab=c(24,4,12),las=1,cex.lab=1.5, cex.axis=1,lwd=2)
>> lines(p.d$DaysPT,b$fit+b$se.fit*1.96,lty=2,lwd=1.5)
>> lines(p.d$DaysPT,b$fit-b$se.fit*1.96,lty=2,lwd=1.5)
>> points(DaysPT,Diff)
>> 
>> 
>> However, when I add a correlation structure and/or a variance structure
>> so
>> that the model may look like:- 
>> 
>> 
>> gamm(Diff~s(DaysPT3)+AirToC,correlation=corCAR1(form=~DaysPT|
>> Animal),weights=varPower(form=~DaysPT),method="REML")
>> 
>> 
>> I get this message at the point of inputting the line
>> "b<-predict.gam(g.m$gam,p.d,se=TRUE)"
> 
> Note that p.d doesn't contain Animal. Not sure this is the problem, but
> I would have thought you'd need to supply new values of Animal for the
> data you wish to predict for in order to get the CAR(1) errors correct.
> Is it possible that the model is finding another Animal variable in the
> global environment?
> 
> I have predicted from several thousand GAMMs containing correlation
> structures similar to the way you do above so this does work in general.
> If the above change to p.d doesn't work, you'll probably need to speak
> to Simon Wood to take this further.
> 
> Is mgcv up-to-date? I am using 1.5-5 that was released in the last week
> or so.
> 
> For example, this dummy example runs without error for me and is similar
> to your model
> 
> y1 <- arima.sim(list(order = c(1,0,0), ar = 0.5), n = 200, sd = 1)
> y2 <- arima.sim(list(order = c(1,0,0), ar = 0.8), n = 200, sd = 3)
> x1 <- rnorm(200)
> x2 <- rnorm(200)
> ind <- rep(1:2, each = 200)
> d <- data.frame(Y = c(y1,y2), X = c(x1,x2), ind = ind, time = rep(1:200,
> times = 2))
> require(mgcv)
> mod <- gamm(Y ~ s(X), data = d, corr = corCAR1(form = ~ time | ind),
> weights = varPower(form = ~ time))
> p.d <- data.frame(X = rep(seq(min(d$X), max(d$X), len = 20), 2),
>   ind = rep(1:2, each = 20),
>   time = rep(1:20, times = 2))
> pred <- predict(mod$gam, newdata = p.d, se = TRUE)
> 
> Does this work for you? If not, the above would be a reproducible
> example (as asked for in the posting guide) and might help Simon track
> down the problem if you are running an up-to-date mgcv.
> 
> HTH
> 
> G
> 
>> 
>> 
>> Error in model.frame(formula, rownames, variables, varnames, extras,
>> extranames,  : 
>> variable lengths differ (found for 'DaysPT')
>> In addition: Warning messages:
>> 1: not all required variables have been supplied in  newdata!
>>  in: predict.gam(g.m$gam, p.d, se = TRUE) 
>> 2: 'newdata' had 25 rows but variable(s) found have 248 rows 
>> 
>> 
>> Is it possible to predict a more complicated model like this on the
>> response
>> scale? How can I incorporate a correlation structure and variance
>> structure
>> in a dataframe when using the predict function for GAMMs?
>> 
>> Any help would be greatly appreciated.
>> 
>> William Paterson
>> 
>> 
>> 
>> 
> -- 
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
>  Dr. Gavin Simpson [t] +44 (0)20 7679 0522
>  ECRC, UCL Geography,  [f] +44 (0)20 7679 0565
>  Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk
>  Gower Street, London  [w] http://www.ucl.ac.uk/~ucfagls/
>  UK. WC1E 6BT. [w] http://www.freshwaters.org.uk
> %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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/Predicting-complicated-GAMMs-on-response-scale-tp23603248p23639184.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

[R] minmun p-value for wilcox.test and correlation

2009-05-20 Thread charles78

I have a stupid question on how to get the real p-values for wilcox.test and
correlation.  the minmun can be reached is 2.2E-16 using the R version
2.6.2.  I do not think it is the R version causing this but other issues.

Any help is highly appreciated.

Charles
-- 
View this message in context: 
http://www.nabble.com/minmun-p-value-for-wilcox.test-and-correlation-tp23637568p23637568.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] Linear constraints for constrasts

2009-05-20 Thread Serguei Kaniovski

Dear List!

How can I define contrasts (design matrix) that can all be included, 
i.e. which do not require a control category be dropped. My application 
(see below) does not suggest a sensible control category. I am thinking 
of constraining the (treatment) contrasts to sum up to zero and dropping 
the constant term in the regression. Is this a good idea? If yes, how to 
achieve this in R?


I am estimating a GLM for bilateral country data. Each observation in on 
a pair of countries, e.g. GER_USA, GER_JAP, USA_JAP. I constructed the 
following contrasts: d_GER, d_USA, d_JAP, which take the value of 1 when 
the country is in the pair and 0 otherwise, i.e.

“Bilat”, “d_GER”, “d_USA”, “d_JAP”
GER_USA, 1, 1, 0
GER_JAP, 1, 0, 1
USA_JAP, 0, 1, 1
These contrasts highlight the effect of having a given country in the pair.

Thank you for your help!
Serguei Kaniovski

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


Re: [R] How to load data from Statistics Canada

2009-05-20 Thread Peter Dalgaard

g...@ucalgary.ca wrote:

We would like to load data from Statistics Canada
(http://www.statcan.gc.ca/) using R,
for example, Employment and unemployment rates.
It seems to me that the tables are displayed in HTML.
I was wondering if you know how to load these tables. Thanks,


I suspect the answer is "with some difficulty". You can do stuff like 
this, based on using the clipboard. Go to


http://www.statcan.gc.ca/daily-quotidien/090520/t090520b1-eng.htm

mark the contents of the table, then

> dd <- t(read.delim("clipboard", colClasses="character"))
> dd1 <- dd[-1,] # 1st row are labels
> dd2 <- as.numeric(gsub(",","",dd1)) # strip thousands separators
Warning message:
NAs introduced by coercion
> dim(dd2) <- dim(dd1)
> dd2
 [,1]  [,2]  [,3]   [,4][,5] [,6]  [,7] [,8] [,9]   [,10] 
[,11]

[1,]   NA 226.8 123.1 2948.0 11630.0 178768.0 122.5   NA 37.6 27822.0  1.760
[2,]   NA 224.6 117.7 2945.0 10709.0 181862.0 121.7   NA 37.1 28822.0  1.750
[3,]   NA 222.0 109.5 2932.0  9694.0 185068.0 121.1   NA 36.9 27801.0  1.730
[4,]   NA 218.8 101.2 2924.0  8968.0 187636.0 120.6   NA 36.7 26560.0  1.690
[5,]   NA 215.6  97.2 2920.0  8759.0 189702.0 120.1   NA 36.4 23762.0  1.640
[6,]   NA 213.3  96.0 2918.0  8770.0 191343.0 119.7   NA 36.2 22029.0  1.600
[7,]   NA  -1.1  -1.2   -0.1 0.1  0.9  -0.3   NA -0.5-7.3 -0.045
 [,12]  [,13]  [,14] [,15]
[1,]NA 2959.0 9637.0 221.8
[2,]NA 2963.0 9635.0 218.4
[3,]NA 2966.0 9587.0 217.1
[4,]NA 2939.0 9368.0 211.2
[5,]NA 2915.0 9325.0 209.4
[6,]NA 2879.0 9199.0 210.5
[7,]NA   -1.2   -1.4   0.5


--
   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
~~ - (p.dalga...@biostat.ku.dk)  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] How to load data from Statistics Canada

2009-05-20 Thread guox
Yes, XML can help load HTML tables.
As we knew, tables in Bureau of Labor Statistics (http://www.bls.gov/)
can be displayed in HTML and can also be loaded directly using their urls,
for example, ftp://ftp.bls.gov/pub/time.series/wp/
I was wondering if tables in Statist Canada have such locations so that we
load them directly. Thanks,

-james
> g...@ucalgary.ca wrote:
>> We would like to load data from Statistics Canada
>> (http://www.statcan.gc.ca/) using R,
>> for example, Employment and unemployment rates.
>> It seems to me that the tables are displayed in HTML.
>> I was wondering if you know how to load these tables. Thanks,
>>
>> -james
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/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 James,
>
> I believe a similar issue was covered recently in the following thread:
>
> http://www.nabble.com/import-HTML-tables-td23504282.html#a23517322
>
> If this is not what you need, please go into more details as to what the
> issue at hand may be.
>
> HTH,
> --
> *Luc Villandré*
> /Biostatistician
> McGill University Health Center -
> Montreal Children's Hospital Research Institute/
>
>
>

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Where to find a changelog for the survival package

2009-05-20 Thread Heinz Tuechler
Thank you Richie. I had seen this before, but my impression is that 
it's not up to date. I gave a wrong version number in my previous 
post. I changed from 2.34-1 to 2.35-4. For example, the plot.survfit 
function lost it's legend parameters, but I don't see this in the changelog.


Thanks again,
Heinz

At 14:53 20.05.2009, richard.cot...@hsl.gov.uk wrote:

> since some days I try to use the versions 2.35-4 of the survival
> package instead of versions 2.31, I had installed until now. Several
> changes in print.survfit, plot.survfit and seemingly in the structure
> of ratetabels effect some of my syntax files.
> Is there somewhere a documentation of these changes, besides the code
itself?

It's in the repository on R-Forge.  The latest version is here:
http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/survival/Changelog.09?rev=11234&root=survival&view=markup

Regards,
Richie.

Mathematical Sciences Unit
HSL



ATTENTION:

This message contains privileged and confidential information intended
for the addressee(s) only. If this message was sent to you in error,
you must not disseminate, copy or take any action in reliance on it and
we request that you notify the sender immediately by return email.

Opinions expressed in this message and any attachments are not
necessarily those held by the Health and Safety Laboratory or any person
connected with the organisation, save those by whom the opinions were
expressed.

Please note that any messages sent or received by the Health and Safety
Laboratory email system may be monitored and stored in an information
retrieval system.



Scanned by MailMarshal - Marshal's comprehensive email content security
solution. Download a free evaluation of MailMarshal at www.marshal.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] problem with "APPLY"

2009-05-20 Thread William Dunlap
> -Original Message-
> From: r-help-boun...@r-project.org 
> [mailto:r-help-boun...@r-project.org] On Behalf Of Peter Dalgaard
> Sent: Wednesday, May 20, 2009 8:16 AM
> To: De France Henri
> Cc: r-help@r-project.org
> Subject: Re: [R] problem with "APPLY"
> 
> De France Henri wrote:
> > Hello,
> >  
> > The "apply" function seems to behave oddly with my code below
> >  
> > NB : H1 is a data frame. (data in the attached file.)
> > # the first lines are:
> > 1 02/01/2008 0.00  0  0 0.00   0
> > 2 03/01/2008 0.00  0  0 0.00   0
> > 3 04/01/2008 0.00  0  0 0.00   0
> > 4 07/01/2008 0.00  0  0 0.00   0
> > 5 08/01/2008 0.00  0  0 0.00   0
> > 6 09/01/2008 0.00  0  0 0.00   0
> > 7 10/01/2008 0.00  0  0 0.00   0
> > 8 11/01/2008 1.010391  0  0 1.102169   0
> > ...
> > The aim of the code is to extract those lines for which 
> there is a strictly positive value in the second column AND 
> in one of the others:
> >  
> > reper=function(x){as.numeric(x[2]>1 & any(x[3:length(x)]>1))}
> >  
> > TAB1= H1[which(apply(H1,1,reper)>0),]
> >  
> > Strangely, this is OK for all the lines, except for the 
> last one. In fact, in H1, the last 2 lines are:
> > 258 29/12/2008 1.476535 1.187615  0 0.00   0
> > 259 30/12/2008 0.00 1.147888  0 0.00   0
> > Obviously, line 258 should be the last line of TAB1, but it 
> is not the case (it does not appear at all) and I really 
> don't understand why. This is all the more strange since 
> applying the function "reper" only to this line 258 gives a 
> "1" as expected...
> > Can someone help ?
> >  
> 
> Works for me...
> 
> do...1.   V3   V5 V7  V13 V31
> 213 24/10/2008 2.038218 2.820196  0 0.00   0
> 214 27/10/2008 3.356057 2.588509  0 2.101651   0
> 219 03/11/2008 2.122751 1.648410  0 2.180908   0
> 233 21/11/2008 1.439861 1.883605  0 1.359372   0
> 234 24/11/2008 1.216548 1.480797  0 1.049390   0
> 258 29/12/2008 1.476535 1.187615  0 0.00   0
> 
> You are crossing the creek to fetch water, though:
> 
> reper <- function(x) x[2]>1 & any(x[3:length(x)]>1)
> TAB1 <-  H1[apply(H1,1,reper),]
> 
> or even
> 
> TAB1 <-  H1[ H1[2] > 1  & apply(H1[3:6] > 1, 1, any),]
> 
> 
> -- 
> 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
> ~~ - (p.dalga...@biostat.ku.dk)  FAX: 
> (+45) 35327907

I couldn't reproduce the bad result either.  However, it was
more or less by chance that the results were as good as
they were.  The call
apply(myDataFrame, 1, FUN)
does essentially the equivalent of
myMatrix <- as.matrix(myDataFrame)
for(i in seq_len(nrow(myMatrix)))
  rowResult[i] <- FUN(myMatrix[i,,drop=TRUE])
If myDataFrame contains any factor, character, POSIXt, or
any other non-numeric columns then myMatrix will be a matrix
of character strings.  Each column of myDataFrame is passed
though format() to make those strings, so the precise formatting
of the strings depends on all the other elements of the column
(E.g., one big or small number might cause the whole column to
be formatted in "scientific" notation).

Your reper() function happened to work because
"2.3" > 0
is interpreted as (I think)
"2.3" > "0"
which is TRUE (at least in ASCII).  However, if your cutoff were 0.02
then you might be surprised
> "2.3">0.02
[1] FALSE
because as.character(0.02) is "2e-06".

I think that using apply(MARGIN=1,...) to data.frames is generally
a bad idea and it only really works if all the columns are the same
simple type.  Avoiding it altgether makes for tedious coding like
 H1[ H1[2] > 1  & (H1[,3]>1 | H1[,4]>1 | H1[,5]>1 | H1[,6]>1) ,]
You can also use pmax (parallel max), as in,
 H1[H1[2]>1 & do.call("pmax", unname(as.list(H1[,3:6])))>1, ]
Peter's 2nd solution calls apply(MARGIN=1,...) only on the numeric
part of the data.frame so it works as expected.

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com 

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


Re: [R] How to load data from Statistics Canada

2009-05-20 Thread Luc Villandre

g...@ucalgary.ca wrote:

We would like to load data from Statistics Canada
(http://www.statcan.gc.ca/) using R,
for example, Employment and unemployment rates.
It seems to me that the tables are displayed in HTML.
I was wondering if you know how to load these tables. Thanks,

-james

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 James,

I believe a similar issue was covered recently in the following thread:

http://www.nabble.com/import-HTML-tables-td23504282.html#a23517322

If this is not what you need, please go into more details as to what the 
issue at hand may be.


HTH,
--
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Supressing the enumeration of output in console

2009-05-20 Thread Greg Snow
Use the 'cat' function to put text on the console without any extra decoration 
(you are then responsible for all formatting including line feeds).

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of ZeMajik
> Sent: Wednesday, May 20, 2009 1:04 PM
> To: r-help@r-project.org
> Subject: [R] Supressing the enumeration of output in console
> 
> Hi!
> Pretty low content question but I've had major trouble finding an
> answer for
> it so I hope it's alright.
> I'm obviously new to R, and have been trying to get rid of the
> numerated
> output I get in the console.
> 
> What I mean more specifically is that
> 
> X<-4;X
> 
> comes out as
> 
> [1] 4
> 
> and I'd like to get rid of the listing [1].
> 
> This isn't usually a problem when working with the console but when
> writing
> scripts that print out lines of text it gives a rather unattractive
> output
> in the console.
> 
> 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] Supressing the enumeration of output in console

2009-05-20 Thread ZeMajik
Hi!
Pretty low content question but I've had major trouble finding an answer for
it so I hope it's alright.
I'm obviously new to R, and have been trying to get rid of the numerated
output I get in the console.

What I mean more specifically is that

X<-4;X

comes out as

[1] 4

and I'd like to get rid of the listing [1].

This isn't usually a problem when working with the console but when writing
scripts that print out lines of text it gives a rather unattractive output
in the console.

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] How to load data from Statistics Canada

2009-05-20 Thread guox
We would like to load data from Statistics Canada
(http://www.statcan.gc.ca/) using R,
for example, Employment and unemployment rates.
It seems to me that the tables are displayed in HTML.
I was wondering if you know how to load these tables. Thanks,

-james

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] drc results differ for different versions

2009-05-20 Thread Marc Schwartz

On May 20, 2009, at 11:20 AM, Hans Vermeiren wrote:


Hello,

We use drc to fit dose-response curves, recently we discovered that
there are quite different standard error values returned for the same
dataset depending on the drc-version / R-version that was used (not
clear which factor is important)
On R 2.9.0 using drc_1.6-3 we get an IC50 of 1.27447 and a standard
error on the IC50 of 0.43540
Whereas on R 2.7.0 using drc_1.4-2  the IC50 is 1.2039e+00 and the
standard error is 3.7752e-03
Normally I would use the most recent version (both R and drc library)
but it seems to me that a standard error of 0.4 on a mean of 1.2 is  
too

big, so I trust the values we get with the older versions more
Has anyone suggestions on
- how to solve these discrepancies, if possible
- how to calculate which one of the 2 solutions is the correct one?

Thanks a lot,
Hans Vermeiren

Demo (on a windows machine, while the issue was actually discovered on
our ubuntu linux server):
1)
sessionInfo()
R version 2.7.0 (2008-04-22)
i386-pc-mingw32

locale:
LC_COLLATE=Dutch_Belgium.1252;LC_CTYPE=Dutch_Belgium. 
1252;LC_MONETARY=Du

tch_Belgium.1252;LC_NUMERIC=C;LC_TIME=Dutch_Belgium.1252

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


other attached packages:
[1] drc_1.4-2  plotrix_2.4-2  nlme_3.1-89MASS_7.2-41
lattice_0.17-6
[6] alr3_1.1.7

loaded via a namespace (and not attached):
[1] grid_2.7.0

d<-data.frame(dose=c(2.00e-05, 4.00e-06, 8.00e-07, 1.60e-07, 3.20e-08,
6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11, 1.00e-11, 2.00e-05, 4.00e-06,
8.00e-07, 1.60e-07, 3.20e-08, 6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11,
1.00e-11),
response=c(97.202,81.670,47.292,16.924, 16.832,  6.832,  11.118,
1.319,   5.495,  -3.352, 102.464,  83.114,  50.631,  22.792,  18.348,
19.066,  27.794,  14.682,  11.992,  12.868))

m<- drm(response ~ (log10(dose*1e6)), data = d, fct = l4(fixed =
c(NA,NA,NA,NA), names = c("hs", "bottom", "top", "ec50")), logDose =  
10,

control = drmc(useD = T))

summary(m)
results in:
Model fitted: Log-logistic (ED50 as parameter) (4 parms)

Parameter estimates:

 Estimate  Std. Error t-value   p-value
hs:(Intercept) -9.8065e-01  2.5821e-03 -3.7979e+02 2.248e-33
bottom:(Intercept)  1.0955e+01  2.2546e-02  4.8591e+02 4.364e-35
top:(Intercept) 1.0502e+02  9.0935e-02  1.1549e+03 4.210e-41
ec50:(Intercept)1.2039e+00  3.7752e-03  3.1890e+02 3.681e-32

Residual standard error: 7.026655 (16 degrees of freedom)
= 
= 
==

===
2)
sessionInfo()
R version 2.9.0 (2009-04-17)
i386-pc-mingw32

locale:
LC_COLLATE=Dutch_Belgium.1252;LC_CTYPE=Dutch_Belgium. 
1252;LC_MONETARY=Du

tch_Belgium.1252;LC_NUMERIC=C;LC_TIME=Dutch_Belgium.1252

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


other attached packages:
[1] drc_1.6-3   plotrix_2.5-5   nlme_3.1-90 MASS_7.2-46
magic_1.4-4 abind_1.1-0 lattice_0.17-22 alr3_1.1.7

loaded via a namespace (and not attached):
[1] grid_2.9.0  tools_2.9.0

d<-data.frame(dose=c(2.00e-05, 4.00e-06, 8.00e-07, 1.60e-07, 3.20e-08,
6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11, 1.00e-11, 2.00e-05, 4.00e-06,
8.00e-07, 1.60e-07, 3.20e-08, 6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11,
1.00e-11),
response=c(97.202,81.670,47.292,16.924, 16.832,  6.832,  11.118,
1.319,   5.495,  -3.352, 102.464,  83.114,  50.631,  22.792,  18.348,
19.066,  27.794,  14.682,  11.992,  12.868))

m<- drm(response ~ (log10(dose*1e6)), data = d, fct = l4(fixed =
c(NA,NA,NA,NA), names = c("hs", "bottom", "top", "ec50")), logDose =  
10,

control = drmc(useD = T))

summary(m)

gives:
Model fitted: Log-logistic (ED50 as parameter) (4 parms)

Parameter estimates:

   Estimate Std. Error   t-value   p-value
hs:(Intercept)  -0.952660.25778  -3.695640.0020
bottom:(Intercept)  10.974372.24421   4.890090.0002
top:(Intercept)106.383739.98378  10.65565 1.127e-08
ec50:(Intercept) 1.274470.43540   2.927120.0099

Residual standard error:

7.020175 (16 degrees of freedom)


Hans,

You have three important factors changing here. The version of R, the  
version of drc and the versions of any relevant drc dependencies  
(alr3, lattice, magic, MASS, nlme, plotrix).


I would first try to install the newer version of drc on the older R  
system (all else staying the same) and see what you get. Don't run  
update.packages() here, lest you change other things. Just install the  
newer version of drc.


If you get the same results as the older version, then it might lead  
you to something in R or one of the package dependencies changing.


If you get a different result, then it would lead to something in drc  
changing.



You can also install the old version of drc on your more recent R  
system to see what you get, which might help to confirm behavior.


The old source version of dr

Re: [R] arrangement of crowded labels

2009-05-20 Thread Greg Snow
Look at the spread.labs and the dynIdentify and TkIdentify functions in the 
TeachingDemos package. 

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.s...@imail.org
801.408.8111


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-
> project.org] On Behalf Of Thomas Zumbrunn
> Sent: Wednesday, May 20, 2009 12:18 AM
> To: r-help@r-project.org
> Subject: [R] arrangement of crowded labels
> 
> Dear R users
> 
> I'm looking for algorithms that assist in spreading out crowded labels,
> e.g.
> labels of points in a scatter plot, in order to obtain a nicer visual
> appearance and better legibility.
> 
> I'm probably just stuck because I didn't find the right key words for a
> successful search on the R websites or in the mailing list archives.
> 
> Any hints are appreciated.
> 
> Thomas Zumbrunn
> University of Basel
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/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] sem with categorical data

2009-05-20 Thread John Fox
Dear Frank,

Did you take a look at the data you generated? The contingency tables
are extremely sparse. Try, e.g., with(dat, table(q1, q2)). (I assume,
BTW, that you're using the cut2() function in the Hmisc package.)

Beyond that, I'm not sure what the point is of your example. You're
generating three independent lognormal random variables while the model
assumed by polychoric correlation is of multinormal random variables;
of course, these *could* be independent, but generally would not.

I hope this helps,
 John

On Wed, 20 May 2009 12:55:49 -0400
 "Frank Lawrence"  wrote:
> I am trying to run a confirmatory factor analysis using the SEM
> package.  My
> data are ordinal.  I have read
> http://socserv.mcmaster.ca/jfox/Misc/sem/SEM-paper.pdf.
> When I apply the hetcor function, I receive the following error:
> Error in checkmvArgs(lower = lower, upper = upper, mean = mean, corr
> = corr,
> : 
>   at least one element of 'lower' is larger than 'upper'
> 
> Example:
> set.seed(781)
> q1 <- cut2(x = rlnorm(n = 1e2, m = 2), cuts = seq(1,6))
> q2 <- cut2(x = rlnorm(n = 1e2, m = 0), cuts = seq(1,6))
> q3 <- cut2(x = rlnorm(n = 1e2, m = 1), cuts = seq(1,6))
> dat <- data.frame(q1,q2,q3)
> hetcor(data = dat, ML = T, pd = T, use = 'p')
> 
> Any help in understanding and correcting the error would be
> appreciated.
> 
> unlist(R.Version())
>   platform   arch 
>  "i386-pc-mingw32" "i386" 
> os system 
>  "mingw32""i386, mingw32" 
> status  major 
> """2" 
>  minor   year 
>  "9.0" "2009" 
>  monthday 
>   "04"   "17" 
>svn rev   language 
>"48333""R" 
> version.string 
> "R version 2.9.0 (2009-04-17)"
> 
> Respectfully,
> 
> Frank Lawrence
> 
> 
> 
> 


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario, Canada
http://socserv.mcmaster.ca/jfox/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] dropping empty panels in xyplot

2009-05-20 Thread Steve_Friedman


I note that someone asked for help a few weeks ago regarding the ability to
drop empty panels on an xyplot.

I did not see a reply to that inquiry so I am asking for assistance with
the same problem

To prepare the data for the plotting routine, I did the following to
restrict the content of the data object to specific colonies of interest.

>  Colony_HSI.df <- Colony_HSI[Colony_HSI$Colony == "NE Grossman A" |
Colony_HSI$Colony == "Loop Road" | Colony_HSI$Colony == "Otter Creek" |
   Colony_HSI$Colony == "Upper Taylor Slough" |
Colony_HSI$Colony == "Tamiami West" ,]


xyplot(Colony_HSI$MEAN + Colony_HSI$TotalNests ~ Colony_HSI$Year |
Colony_HSI$Colony,  lty=c(1,2), pch=c(1,9),
  par.settings = graph.sets, type = "o",  xlab= "Year",
ylim=c(0,1),
   ylab="Mean HSI",  drop.unused.levels =
lattice.getOption("drop.unused.levels"))


However this produces a plot with 22 panels, but only 5 have data in them.
Am I using the subsetting routines incorrectly? Why are there "place
holders" in the data object even after I selected for just 5 of them? How
can I build the plot including  just the 5 colony names?

Steve

Steve Friedman Ph. D.
Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

steve_fried...@nps.gov
Office (305) 224 - 4282
Fax (305) 224 - 4147

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


Re: [R] How to google for R stuff?

2009-05-20 Thread spencerg
Dear Dieter: 

 Thanks for the correction.  I failed to test the code as written 
before I posted it. 


 Spencer Graves

Dieter Menne wrote:

spencerg  prodsyse.com> writes:

  

de <- RSiteSearch.function("differential equation")
des <- RSiteSearch.function("differential equations")
# With "de" and "des", each finds things missed by the other. 
de. <- de | des # combine into one
sumDE <- packageSum2(de.) # add details on installed packages. 



Should be 

PackageSum2(de.) 


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] How to google for R stuff?

2009-05-20 Thread Dieter Menne
spencerg  prodsyse.com> writes:

> de <- RSiteSearch.function("differential equation")
> des <- RSiteSearch.function("differential equations")
> # With "de" and "des", each finds things missed by the other. 
> de. <- de | des # combine into one
> sumDE <- packageSum2(de.) # add details on installed packages. 

Should be 

PackageSum2(de.) 

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] Class for time of day?

2009-05-20 Thread Gabor Grothendieck
There is a times class in the chron package.  Times are measured
in fractions of a day so 1/24 is one hour.

> library(chron)
> dt <- Sys.time()
> tt <- times(format(dt, "%H:%M:%S"))
> tt
[1] 12:27:46
> tt + 1/24
[1] 13:27:46

There is an article on dates and times in R News 4/1.

On Wed, May 20, 2009 at 10:57 AM, Stavros Macrakis
 wrote:
> What is the recommended class for time of day (independent of calendar
> date)?
>
> And what is the recommended way to get the time of day from a POSIXct
> object? (Not a string representation, but a computable representation.)
>
> I have looked in the man page for DateTimeClasses, in the Time Series
> Analysis Task View and in Spector's Data Manipulation book but haven't found
> these. Clearly I can create my own Time class and hack around with the
> internal representation of POSIXct, e.g.
>
>    days <- unclass(d)/(24*3600)
>    days-floor(days)
>
> and write print.Time, `-.Time`, etc. etc. but I expect there is already a
> standard class or CRAN package.
>
>           -s
>
>        [[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] RGoogleDocs: can now see documents but cannot get content.

2009-05-20 Thread Duncan Temple Lang


Hi Farrel

 This particular problem is a trivial issue of an argument out
of place due to a change in the function definition during the
development.  There is a new version of the package (0.2-2)
and it also uses a slightly different approach (and function)
to pull the values into the form of an R data frame.

Please try that and hopefully it will work.

The code in the run.pdf (or run.html) file on the Web page
and in the package works and is the best and shortest
example of sheetAsMatrix().

Let me know if there are still problems.


  D.

Farrel Buchinsky wrote:

The author of the package, Duncan Temple Lang posted an update. I have
installed it and now can list my spreadsheets but alas I cannot read the
data within any of them.
Has anybody been able to get it to work.
I would love to see a real live example of sheetAsMatrix
I am not sure how to specify sheet and  con = sh...@connection. I have tried
many ways but just get:
Error in !includeEmpty : invalid argument type

Windows Vista (with UAC disabled)
R 2.9.0

Farrel Buchinsky

[[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] drc results differ for different versions

2009-05-20 Thread Hans Vermeiren
Hello,

We use drc to fit dose-response curves, recently we discovered that
there are quite different standard error values returned for the same
dataset depending on the drc-version / R-version that was used (not
clear which factor is important)
On R 2.9.0 using drc_1.6-3 we get an IC50 of 1.27447 and a standard
error on the IC50 of 0.43540   
Whereas on R 2.7.0 using drc_1.4-2  the IC50 is 1.2039e+00 and the
standard error is 3.7752e-03  
Normally I would use the most recent version (both R and drc library)
but it seems to me that a standard error of 0.4 on a mean of 1.2 is too
big, so I trust the values we get with the older versions more
Has anyone suggestions on 
- how to solve these discrepancies, if possible
- how to calculate which one of the 2 solutions is the correct one?

Thanks a lot,
Hans Vermeiren

Demo (on a windows machine, while the issue was actually discovered on
our ubuntu linux server):
1)
sessionInfo()
R version 2.7.0 (2008-04-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=Dutch_Belgium.1252;LC_CTYPE=Dutch_Belgium.1252;LC_MONETARY=Du
tch_Belgium.1252;LC_NUMERIC=C;LC_TIME=Dutch_Belgium.1252

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


other attached packages:
[1] drc_1.4-2  plotrix_2.4-2  nlme_3.1-89MASS_7.2-41
lattice_0.17-6
[6] alr3_1.1.7

loaded via a namespace (and not attached):
[1] grid_2.7.0

d<-data.frame(dose=c(2.00e-05, 4.00e-06, 8.00e-07, 1.60e-07, 3.20e-08,
6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11, 1.00e-11, 2.00e-05, 4.00e-06,
8.00e-07, 1.60e-07, 3.20e-08, 6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11,
1.00e-11),
response=c(97.202,81.670,47.292,16.924, 16.832,  6.832,  11.118,
1.319,   5.495,  -3.352, 102.464,  83.114,  50.631,  22.792,  18.348,
19.066,  27.794,  14.682,  11.992,  12.868))

m<- drm(response ~ (log10(dose*1e6)), data = d, fct = l4(fixed =
c(NA,NA,NA,NA), names = c("hs", "bottom", "top", "ec50")), logDose = 10,
control = drmc(useD = T))

summary(m)
results in:
Model fitted: Log-logistic (ED50 as parameter) (4 parms)

Parameter estimates:

  Estimate  Std. Error t-value   p-value
hs:(Intercept) -9.8065e-01  2.5821e-03 -3.7979e+02 2.248e-33
bottom:(Intercept)  1.0955e+01  2.2546e-02  4.8591e+02 4.364e-35
top:(Intercept) 1.0502e+02  9.0935e-02  1.1549e+03 4.210e-41
ec50:(Intercept)1.2039e+00  3.7752e-03  3.1890e+02 3.681e-32

Residual standard error: 7.026655 (16 degrees of freedom)

===
2)
sessionInfo()
R version 2.9.0 (2009-04-17) 
i386-pc-mingw32 

locale:
LC_COLLATE=Dutch_Belgium.1252;LC_CTYPE=Dutch_Belgium.1252;LC_MONETARY=Du
tch_Belgium.1252;LC_NUMERIC=C;LC_TIME=Dutch_Belgium.1252

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


other attached packages:
[1] drc_1.6-3   plotrix_2.5-5   nlme_3.1-90 MASS_7.2-46
magic_1.4-4 abind_1.1-0 lattice_0.17-22 alr3_1.1.7 

loaded via a namespace (and not attached):
[1] grid_2.9.0  tools_2.9.0

d<-data.frame(dose=c(2.00e-05, 4.00e-06, 8.00e-07, 1.60e-07, 3.20e-08,
6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11, 1.00e-11, 2.00e-05, 4.00e-06,
8.00e-07, 1.60e-07, 3.20e-08, 6.40e-09, 1.28e-09, 2.56e-10, 5.10e-11,
1.00e-11),
response=c(97.202,81.670,47.292,16.924, 16.832,  6.832,  11.118,
1.319,   5.495,  -3.352, 102.464,  83.114,  50.631,  22.792,  18.348,
19.066,  27.794,  14.682,  11.992,  12.868))

m<- drm(response ~ (log10(dose*1e6)), data = d, fct = l4(fixed =
c(NA,NA,NA,NA), names = c("hs", "bottom", "top", "ec50")), logDose = 10,
control = drmc(useD = T))

summary(m)

gives:
Model fitted: Log-logistic (ED50 as parameter) (4 parms)

Parameter estimates:

Estimate Std. Error   t-value   p-value
hs:(Intercept)  -0.952660.25778  -3.695640.0020
bottom:(Intercept)  10.974372.24421   4.890090.0002
top:(Intercept)106.383739.98378  10.65565 1.127e-08
ec50:(Intercept) 1.274470.43540   2.927120.0099

Residual standard error:

 7.020175 (16 degrees of freedom)





--
This e-mail and its attachment(s) (if any) may contain confidential and/or 
proprietary information and is intended for its addressee(s) only. Any 
unauthorized use of the information contained herein (including, but not 
limited to, alteration, reproduction, communication, distribution or any other 
form of dissemination) is strictly prohibited. If you are not the intended 
addressee, please notify the orginator promptly and delete this e-mail and its 
attachment(s) (if any) subsequently. 

Galapagos nor any of its affiliates shall be liable for direct, special, 
indirect or consequential damages arising from alteration of the contents of 
this message (by a third party) or as a result of a virus being passed on.

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

Re: [R] Class for time of day?

2009-05-20 Thread jim holtman
If you want the hours from a POSIXct, here is one way of doing it; you can
create a function for doing it:

> x <- Sys.time()
> x
[1] "2009-05-20 12:17:13 EDT"
> y <- difftime(x, trunc(x, units='days'), units='hours')
> y
Time difference of 12.28697 hours
> as.numeric(y)
[1] 12.28697
>
It depends on what type of computations you want to do with it.  You can
leave it as POSIXct and carry out a lot of them.  Can you specify what you
want?


On Wed, May 20, 2009 at 10:57 AM, Stavros Macrakis wrote:

> What is the recommended class for time of day (independent of calendar
> date)?
>
> And what is the recommended way to get the time of day from a POSIXct
> object? (Not a string representation, but a computable representation.)
>
> I have looked in the man page for DateTimeClasses, in the Time Series
> Analysis Task View and in Spector's Data Manipulation book but haven't
> found
> these. Clearly I can create my own Time class and hack around with the
> internal representation of POSIXct, e.g.
>
>days <- unclass(d)/(24*3600)
>days-floor(days)
>
> and write print.Time, `-.Time`, etc. etc. but I expect there is already a
> standard class or CRAN package.
>
>   -s
>
>[[alternative HTML version deleted]]
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


[R] evaluating partitions in CLUE

2009-05-20 Thread A M Lavezzi
Hello,
I'm starting to use CLUE to compare clusterings.

I have some cluster structures obtained outside R, which are simlply vectors
of lenght N (N: number of objects), which contain a number indicating the
cluster to which each object belongs. I report below a portion of one of
these:


   V1
1  12
2   1
3   2
4   6
5  15
6   9
7   5
8   8
9  12
10  9
11 10
12  2
13  7
14 12
15 10
-
which indicates that object 1 is in cluster "12", object 2 is in cluster "1"
etc.

Is there a way to evaluate the dissimilarity of clusterings of this sort
without transforming them into "ensembles" or, alternatively, is there a way
to turn these vectors into "ensembles"

Thanks a lot!
Mario

-- 
Andrea Mario Lavezzi
Dipartimento Studi su Politica, Diritto e Società
Piazza Bologni 8
90134 Palermo, Italy
tel. ++39 091 6625650
fax  ++39 091 6112023
skype: lavezzimario
email: lave...@unipa.it
web: http://www.unipa.it/~lavezzi

[[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] SEM:Standard error of std.coef estimates?

2009-05-20 Thread John Fox
Dear Bastiaan,

I've written an appendix on bootstrapping regression models, available at

, which describes generally how to proceed. In outline, you'll write a
function that takes your data matrix (not covariance matrix) as an argument,
along with a vector argument for indexing the data matrix. Your function
will calculate covariances from the indexed data matrix, fit your model to
this covariance matrix, get the standardized coefficients from the model,
and return the standardized coefficients as a vector. 

An alternative would be to adapt the boot.sem() function in the sem package
to return standardized coefficients. That might prove simpler for you.

Regards,
 John


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
> Behalf Of BdeGroot
> Sent: May-20-09 10:54 AM
> To: r-help@r-project.org
> Subject: Re: [R] SEM:Standard error of std.coef estimates?
> 
> 
> Dear John,
> 
> Thank you for your reply. I would like to try the bootstrapping method. I
> have the boot package, however, I have not used it before. I do not know
how
> to compute the correct code to calculate the standarized errors. If
possible
> and easily achievable, could you please tell me what to do specifically or
> provide some more specific guidelines?
> 
> Thanks,
> Bastiaan
> 
> 
> John Fox-6 wrote:
> >
> > Dear Bastiaan,
> >
> > The standard errors of the standardized coefficients aren't simple
because
> > the standard deviations used to standardize the coefficients are also
> > subject to sampling error. I can think of two ways to get standard
errors
> > for the standardized coefficients: by the delta method and by
> > bootstrapping.
> > Neither method is implemented in the sem package. Figuring out how to
> > apply
> > the former would require some work; I'll put it on my to-do list, but
may
> > not get to it. The second approach could easily be implemented via the
> > boot
> > package.
> >
> > I hope this helps,
> >  John
> >
> >
> >> -Original Message-
> >> From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org]
> > On
> >> Behalf Of BdeGroot
> >> Sent: May-20-09 7:41 AM
> >> To: r-help@r-project.org
> >> Subject: [R] SEM:Standard error of std.coef estimates?
> >>
> >>
> >> Hi,
> >>
> >> I am currently working with the sem package in R, to create pathway
> >> diagrams. Id like to use the standardized path coeffcients. To get
these,
> > I
> >> use std.coef. However, using this yields only the standardized
> > coefficients,
> >> but does not give me the standard error. Does someone know how to get
> >> std.coef to show the standard error of the standardized path
coefficients
> > as
> >> well?
> >>
> >>
> >> Thanks,
> >> Bastiaan
> >>
> >>
> >> PS:
> >> When I use std.coef, all I get is this:
> >>
> >> std.coef(path.model.SSI4)
> >>   Std. Estimate
> >> par1 par1  0.39499  com_veg <--- tempm
> >> par2 par2  0.35231  SNutBili <--- tempm
> >> par3 par3 -0.68170  S_SSI4 <--- tempm
> >> par4 par4 -0.39145  com_veg <--- Wdeficit
> >> par5 par5 -0.60025  SNutBili <--- Wdeficit
> >> par6 par6 -0.20562  S_SSI4 <--- Wdeficit
> >> par7 par7  0.14871  SNutBili <--- com_veg
> >> par8 par8  0.14905  S_SSI4 <--- com_veg
> >> par9 par9 -0.39164  S_SSI4 <--- SNutBili
> >> --
> >> View this message in context:
> > http://www.nabble.com/SEM%3AStandard-error-of-
> >> std.coef-estimates--tp23633227p23633227.html
> >> Sent from the R help mailing list archive at Nabble.com.
> >>
> >> __
> >> R-help@r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-help
> >> PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> >> and provide commented, minimal, self-contained, reproducible code.
> >
> > __
> > R-help@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide
> > http://www.R-project.org/posting-guide.html
> > and provide commented, minimal, self-contained, reproducible code.
> >
> >
> 
> --
> View this message in context:
http://www.nabble.com/SEM%3AStandard-error-of-
> std.coef-estimates--tp23633227p23636945.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Joshua Stults
I was having the same frustration so I made a Google custom search
engine for Open Math Tools:
http://www.google.com/coop/cse?cx=015659631714008342946:wolsniqtrxc

It gives preferences to results from r-project.org, octave.org,
maxima.sourceforge.net, and the mailing list archives from those
projects.  It also has some other smaller pages that contain tutorials
for those tools.

It includes results from the broader web as well, so if there is a
highly ranked article from wikipedia or mathworld that will show up
too.

Here's a short write-up with example searches:
http://j-stults.blogspot.com/2009/05/open-math-tools-custom-search-engine.html

If any folks on the list out there have any suggestions or would like
to be a 'contributor' on it post a reply with a site to add to the
preference list , or click the 'volunteer to contribute' link on the
search engine homepage.

Good luck with your R searching.

On Wed, May 20, 2009 at 9:02 AM, Kynn Jones  wrote:
> Hi!  I'm new to R programming, though I've been programming in other
> languages for years.
>
> One thing I find most frustrating about R is how difficult it is to use
> Google (or any other search tool) to look for answers to my R-related
> questions.  With languages with even slightly more distinctive names like
> Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
> language in the query is enough to ensure that the top hits are relevant.
>  But this trick does not work for R, because the letter R appears by itself
> in so many pages, that the chaff overwhelms the wheat, so to speak.
>
> So I'm curious to learn what strategies R users have found to get around
> this annoyance.
>
> TIA!
>
> KJ
>
>        [[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.
>



-- 
Joshua Stults
Website: http://j-stults.blogspot.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] Comparing spatial distributions - permutation test implementation

2009-05-20 Thread JiHO

Hello everyone,

I am looking at the joint spatial distribution of 2 kinds of organisms  
(estimated on a grid of points) and want to test for significant  
association or dissociation.


My first question is: do you know a nice technique to do that,  
considering that I have a limited number of points (36) but that they  
are repeated (4 times)? I did GLMs to test for correlations between  
the two (hence forgetting about the spatial aspect of it) and was  
previously pointed to the SADIE software. Would there be anything  
explicitly spatial and available in R please?


Then, Syrjala's test[1] seems appropriate and tests for differences in  
distribution. It computes a Cramér-von Mises-type statistic and tests  
its significance with a permutation test.
I implemented the test in R and posted the code on these mailing  
lists[2]. Some people checked it and confirmed that the statistic  
gives correct results but my estimation of the p-value does not match  
the one predicted with the orignal software from Syrjala. I don't know  
what I am doing wrong. The permutation test is described by Syrjala as:


(...) Under the null hypothesis,
at a given sampling location (x_k, y_k), either density ob-
servation y_i(x_k, y_k), i = 1, 2, is equally likely for each
population. Thus, for a given data set, the distribution
of the test statistic can be constructed by calculating
the value of the test statistic for all 2^k pairwise per-
mutations of the data set. (...) The level of signif-
icance of a specific realization of the test statistic T is
determined from its position in the ordered set of test
statistic values from all 2^k permutations. (...)

My understanding is that, for each permutation I should choose a  
random number of points (between 1 and k), swap the values for species  
1 and species 2 at those points, and recompute the test on the new  
data. But this does not work :/ . Here is my code and associated data  
from Syrjala (for which I have reference values). Any advice would be  
very welcome (in particular if there is a way to leverage boot() for  
this).
NB: computing the 1000 permutations can be a bit lengthy, but  
fortunately, by using plyr, you get a nice progress bar to look at!


syrjala.stat <- function(x, y=NULL, var1=NULL, var2=NULL)
#
#   Compute Syrjala statistic
#   x, ycoordinates
#   var1, var2  value of 2 parameters both measured at (x,y) points
#	NB: x can also be a data.frame/matrix containing x,y,var1,var2 as  
columns

#
{
# Input checks
if (!is.null(ncol(x))) {
if (ncol(x) == 4) {
names(x) = c("x","y","var1","var2")
dat = x
} else {
stop("Wrong number of columns in argument x")
}
} else {
dat = data.frame(x, y, var1, var2)
}

# Normalize abundances
dat$var1 = dat$var1/sum(dat$var1)
dat$var2 = dat$var2/sum(dat$var2)

# For each point (each line of dat)
# compute the squared difference in gammas from each origin
meanSqDiff = apply(dat, 1, function(d, coord, variab) {
north = (coord$x>=d[1])
east = (coord$y>=d[2])
south = (coord$x<=d[1])
west = (coord$y<=d[2])
return( mean( c(
(diff(sapply(variab[(north & east),], sum)))^2,
(diff(sapply(variab[(south & east),], sum)))^2,
(diff(sapply(variab[(south & west),], sum)))^2,
(diff(sapply(variab[(north & west),], sum)))^2
) )
)
}, dat[,c("x","y")], dat[,c("var1","var2")])

# Compute the statistic (i.e. sum of mean squared differences)
return(sum(meanSqDiff))
}


# Get data online : http://dl.getdropbox.com/u/1047321/syrjala_data_cod.csv
system("curl http://dl.getdropbox.com/u/1047321/syrjala_data_cod.csv >  
syrjala_data_cod.csv")


dataCod = read.csv(file = "syrjala_data_cod.csv", header = TRUE)

# Normalize abundances
dataCod$var1 = dataCod$var1/sum(dataCod$var1)
dataCod$var2 = dataCod$var2/sum(dataCod$var2)

# Number of permutations
nperm = 1000

# Create nperm-1 replicates of the data (one is the original  
observation)

d = rep(list(dataCod), nperm-1)

# Compute number of observations before to avoid doing that for every  
replicate

n = nrow(dataCod)

require(plyr)
# Permute some observations and compute the syrjala stat for each  
permutation

psis = ldply(d, .fun=function(x, n){
# choose indices of observations to swap
idx = sample(1:n, runif(1, min=1, max=n))
# swap observations
x[idx, 3:4] = x[idx, 4:3]
# compute syrjala stat
return(syrjala.stat(x))
}, n, .progress="text")
}

# Compute the syrjala stat for the observation

[R] stationarity tests

2009-05-20 Thread mauede
How can I make sure the residual signal, after subtracting the trend extracted 
through some technique, is actually trend-free ?   
I would greatly appreciate any suggestion about some Stationarity tests.

I'd like to make sure I have got the difference between ACF and PACF right.
In the following I am citing some definitions. I would appreciate your thoughts.

ACF(k) estimates the correlation between y(t) and y(t-k)  like an ordinary 
correlation coefficient.
ACF is the simple ( i.e. unconditional ) correlation between a time series and 
it's lags thus
y(t)=a+b*y(t-k) gnerates the kth autocoreelation coefficient (b).

If we have form y(t)=a+b*y(t-1)+c*y(t-2) .. then (c)  is the PARTIAL 
AUTOCORRELATION COEFFFICIENT or in other words the
CONDITIONAL CORRELATION of lag 2 given lag1
PACF(k) estimates the correlation between y(t) and y(t-k) adjusted for the 
effects of y(t-1), ..., y(t-k+1).

Model identification is achieved by looking at the pattern of the ACF and PACF.
- If the ACF dies off exponentially, but the PACF has p spikes, AR(p) is 
indicated.
- If the ACF has  q  spikes and the PACF dies off exponentially, MA(q) is 
indicated.

The ACF and the PACF for the resulting stationary series is used to determine 
the best B/J model for the series according to the following rules:
 a.  If the ACF trails off and the PACF shows spikes, then an AR model with 
order p = number of significant PACF spikes is the best
  model.
 b.  If the PACF trails off and the ACF shows spikes, then an MA model with 
order q= number of significant ACF spikes is the best model.
 c.  If both the ACF and the PACF trail off then a ARMA model is used with p=1 
and q=1.

Thank you very much,
Maura

Thank you very much.
Best regards,
Maura Edelweiss



tutti i telefonini TIM!


[[alternative HTML version deleted]]

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Seeliger . Curt
Kynn writes:
> So I'm curious to learn what strategies R users have found to get around
> this annoyance.

I use Rseek for most of my R questions: http://www.rseek.org/

cur
-- 
Curt Seeliger, Data Ranger
Raytheon Information Services - Contractor to ORD
seeliger.c...@epa.gov
541/754-4638

[[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 "APPLY"

2009-05-20 Thread Peter Dalgaard

De France Henri wrote:

Hello,
 
The "apply" function seems to behave oddly with my code below
 
NB : H1 is a data frame. (data in the attached file.)

# the first lines are:
1 02/01/2008 0.00  0  0 0.00   0
2 03/01/2008 0.00  0  0 0.00   0
3 04/01/2008 0.00  0  0 0.00   0
4 07/01/2008 0.00  0  0 0.00   0
5 08/01/2008 0.00  0  0 0.00   0
6 09/01/2008 0.00  0  0 0.00   0
7 10/01/2008 0.00  0  0 0.00   0
8 11/01/2008 1.010391  0  0 1.102169   0
...
The aim of the code is to extract those lines for which there is a strictly 
positive value in the second column AND in one of the others:
 
reper=function(x){as.numeric(x[2]>1 & any(x[3:length(x)]>1))}
 
TAB1= H1[which(apply(H1,1,reper)>0),]
 
Strangely, this is OK for all the lines, except for the last one. In fact, in H1, the last 2 lines are:

258 29/12/2008 1.476535 1.187615  0 0.00   0
259 30/12/2008 0.00 1.147888  0 0.00   0
Obviously, line 258 should be the last line of TAB1, but it is not the case (it does not appear at 
all) and I really don't understand why. This is all the more strange since applying the function 
"reper" only to this line 258 gives a "1" as expected...
Can someone help ?
 


Works for me...

   do...1.   V3   V5 V7  V13 V31
213 24/10/2008 2.038218 2.820196  0 0.00   0
214 27/10/2008 3.356057 2.588509  0 2.101651   0
219 03/11/2008 2.122751 1.648410  0 2.180908   0
233 21/11/2008 1.439861 1.883605  0 1.359372   0
234 24/11/2008 1.216548 1.480797  0 1.049390   0
258 29/12/2008 1.476535 1.187615  0 0.00   0

You are crossing the creek to fetch water, though:

reper <- function(x) x[2]>1 & any(x[3:length(x)]>1)
TAB1 <-  H1[apply(H1,1,reper),]

or even

TAB1 <-  H1[ H1[2] > 1  & apply(H1[3:6] > 1, 1, any),]


--
   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
~~ - (p.dalga...@biostat.ku.dk)  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.


[R] meaning of order-vector in object of class hclust

2009-05-20 Thread Pieter van der Spek
I'm trying to export the dendrogram created in R such that I can rebuild it
inside an other program. However, I don't fully understand the relation
between the merge, height and order vectors.
This is what I do grasp. The merge-matrix shows how the original
observations were merged into a tree structure. The height-vector contains
the heights for each of the nodes in the tree. The order of the merge-matrix
and the height-vector is the same. This means that row *i* in the matrix
corresponds to row *i* in the vector.
Then there is the order-vector. The documentation describes it as follows:

order a vector giving the permutation of the original observations suitable
for plotting, in the sense that a cluster plot using this ordering and
matrix merge will not have crossings of the branches.

So far, I get it reorders the nodes to prevent overlapping branches, but I
don't understand how the values in this vector correspond to the values in
the other two structures. So what does row *i* in the order-vector say about
the other structures? Should I reorder the merge-matrix and height-vector,
according to the values in the order-vector, before constructing the tree?

Hopefully someone can explain to me how this works. Thanks in advance for
any help you can provide.

Kind regards,
Pieter

[[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] Class for time of day?

2009-05-20 Thread Stavros Macrakis
What is the recommended class for time of day (independent of calendar
date)?

And what is the recommended way to get the time of day from a POSIXct
object? (Not a string representation, but a computable representation.)

I have looked in the man page for DateTimeClasses, in the Time Series
Analysis Task View and in Spector's Data Manipulation book but haven't found
these. Clearly I can create my own Time class and hack around with the
internal representation of POSIXct, e.g.

days <- unclass(d)/(24*3600)
days-floor(days)

and write print.Time, `-.Time`, etc. etc. but I expect there is already a
standard class or CRAN package.

   -s

[[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] SEM:Standard error of std.coef estimates?

2009-05-20 Thread BdeGroot

Dear John,

Thank you for your reply. I would like to try the bootstrapping method. I
have the boot package, however, I have not used it before. I do not know how
to compute the correct code to calculate the standarized errors. If possible
and easily achievable, could you please tell me what to do specifically or
provide some more specific guidelines?

Thanks,
Bastiaan


John Fox-6 wrote:
> 
> Dear Bastiaan,
> 
> The standard errors of the standardized coefficients aren't simple because
> the standard deviations used to standardize the coefficients are also
> subject to sampling error. I can think of two ways to get standard errors
> for the standardized coefficients: by the delta method and by
> bootstrapping.
> Neither method is implemented in the sem package. Figuring out how to
> apply
> the former would require some work; I'll put it on my to-do list, but may
> not get to it. The second approach could easily be implemented via the
> boot
> package.
> 
> I hope this helps,
>  John
> 
> 
>> -Original Message-
>> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
> On
>> Behalf Of BdeGroot
>> Sent: May-20-09 7:41 AM
>> To: r-help@r-project.org
>> Subject: [R] SEM:Standard error of std.coef estimates?
>> 
>> 
>> Hi,
>> 
>> I am currently working with the sem package in R, to create pathway
>> diagrams. Id like to use the standardized path coeffcients. To get these,
> I
>> use std.coef. However, using this yields only the standardized
> coefficients,
>> but does not give me the standard error. Does someone know how to get
>> std.coef to show the standard error of the standardized path coefficients
> as
>> well?
>> 
>> 
>> Thanks,
>> Bastiaan
>> 
>> 
>> PS:
>> When I use std.coef, all I get is this:
>> 
>> std.coef(path.model.SSI4)
>>   Std. Estimate
>> par1 par1  0.39499  com_veg <--- tempm
>> par2 par2  0.35231  SNutBili <--- tempm
>> par3 par3 -0.68170  S_SSI4 <--- tempm
>> par4 par4 -0.39145  com_veg <--- Wdeficit
>> par5 par5 -0.60025  SNutBili <--- Wdeficit
>> par6 par6 -0.20562  S_SSI4 <--- Wdeficit
>> par7 par7  0.14871  SNutBili <--- com_veg
>> par8 par8  0.14905  S_SSI4 <--- com_veg
>> par9 par9 -0.39164  S_SSI4 <--- SNutBili
>> --
>> View this message in context:
> http://www.nabble.com/SEM%3AStandard-error-of-
>> std.coef-estimates--tp23633227p23633227.html
>> Sent from the R help mailing list archive at Nabble.com.
>> 
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 
> 

-- 
View this message in context: 
http://www.nabble.com/SEM%3AStandard-error-of-std.coef-estimates--tp23633227p23636945.html
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] How to google for R stuff?

2009-05-20 Thread spencerg
 There is also the relatively new "RSiteSearch" package.  It's 
"RSiteSearch.function" searches only help pages of contributed packages 
but returns the result in a data.frame (of class "RSiteSearch") sorted 
to put the most interesting package first with help pages sorted within 
packages.  If this package is installed, "system.file('doc', 
'RSiteSearch.pdf', package='RSiteSearch')" will give you the location of 
a 2-page description of the most important features of this package 
including examples that work.  Since that document was written, we've 
added "|" and "&" for combining the objects returned by different 
searches and "packageSum2" to add information from installed packages 
not available from "RSiteSearch" itself. 



 For example, I'm giving an invited presentation on "Fitting 
Nonlinear Differential Equations to Data in R" as part of a "Dynamics 
Workshop" in Vancouver this June 4-6 
(http://stat.sfu.ca/~dac5/workshop09/Welcome.html).  To prepare for 
that, I first did the following: 



de <- RSiteSearch.function("differential equation")
des <- RSiteSearch.function("differential equations")
# With "de" and "des", each finds things missed by the other. 
de. <- de | des # combine into one
sumDE <- packageSum2(de.) # add details on installed packages. 



 This helped me decide which packages I should look at first. 

 Hope this helps. 
 Spencer Graves


cr...@binghamton.edu wrote:

For Google searches, I find that throwing in the term cran on every search 
helps weed out irrelevant pages.

For example, instead of 


r residuals

I type

r cran residuals

--Chris Ryan

 Original message 
  

Date: Wed, 20 May 2009 09:43:14 -0400
From: Luc Villandre   
Subject: Re: [R] How to google for R stuff?  
To: Kynn Jones 

Cc: r-help@r-project.org


Kynn Jones wrote:


Hi!  I'm new to R programming, though I've been programming in other
languages for years.

One thing I find most frustrating about R is how difficult it is to use
Google (or any other search tool) to look for answers to my R-related
questions.  With languages with even slightly more distinctive names like
Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
language in the query is enough to ensure that the top hits are relevant.
 But this trick does not work for R, because the letter R appears by itself
in so many pages, that the chaff overwhelms the wheat, so to speak.

So I'm curious to learn what strategies R users have found to get around
this annoyance.

TIA!

KJ

[[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 Kynn,

I've had this problem too in the beginning. Luckily, my personal 
experience has taught me that almost all relevant R-related information 
can be found either by searching directly through the archives of the 
different R-forums or by using the functions "RSiteSearch()" or 
"help.search()". The reference manuals provided with each package 
(easily accessible on CRAN) are also invaluable sources of information.


Unfortunately, phrasing queries in a way that will yield relevant 
results is sometimes hard. Knowledge of the terminology mostly comes 


>from experience, so patience is in order.
  

Of course, as a last recourse, there's always the mailing list.

Bottom line is, I suggest you try to avoid generic search engines and 
concentrate your efforts on the different R-forums (note that there are 
also package-specific forums).


I suspect the more experienced R-users might have better strategies to 
propose though...


Cheers,
--
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] problem with "APPLY"

2009-05-20 Thread De France Henri
Hello,
 
The "apply" function seems to behave oddly with my code below
 
NB : H1 is a data frame. (data in the attached file.)
# the first lines are:
1 02/01/2008 0.00  0  0 0.00   0
2 03/01/2008 0.00  0  0 0.00   0
3 04/01/2008 0.00  0  0 0.00   0
4 07/01/2008 0.00  0  0 0.00   0
5 08/01/2008 0.00  0  0 0.00   0
6 09/01/2008 0.00  0  0 0.00   0
7 10/01/2008 0.00  0  0 0.00   0
8 11/01/2008 1.010391  0  0 1.102169   0
...
The aim of the code is to extract those lines for which there is a strictly 
positive value in the second column AND in one of the others:
 
reper=function(x){as.numeric(x[2]>1 & any(x[3:length(x)]>1))}
 
TAB1= H1[which(apply(H1,1,reper)>0),]
 
Strangely, this is OK for all the lines, except for the last one. In fact, in 
H1, the last 2 lines are:
258 29/12/2008 1.476535 1.187615  0 0.00   0
259 30/12/2008 0.00 1.147888  0 0.00   0
Obviously, line 258 should be the last line of TAB1, but it is not the case (it 
does not appear at all) and I really don't understand why. This is all the 
more strange since applying the function "reper" only to this line 258 gives a 
"1" as expected...
Can someone help ?
 
Thanks,
 
Henri 


  "do[, 1]" "V3" "V5" "V7" "V13" "V31"
"1" "02/01/2008" 0 0 0 0 0
"2" "03/01/2008" 0 0 0 0 0
"3" "04/01/2008" 0 0 0 0 0
"4" "07/01/2008" 0 0 0 0 0
"5" "08/01/2008" 0 0 0 0 0
"6" "09/01/2008" 0 0 0 0 0
"7" "10/01/2008" 0 0 0 0 0
"8" "11/01/2008" 1.01039075593190 0 0 1.10216867469880 0
"9" "14/01/2008" 0 0 0 0 0
"10" "15/01/2008" 0 0 0 0 0
"11" "16/01/2008" 0 0 0 0 0
"12" "17/01/2008" 0 0 0 0 0
"13" "18/01/2008" 0 0 0 0 0
"14" "21/01/2008" 0 1.91598986420635 0 0 0
"15" "22/01/2008" 0 0 0 1.67943418163028 0
"16" "23/01/2008" 0 1.72752274788613 0 0 0
"17" "24/01/2008" 0 0 0 0 0
"18" "25/01/2008" 0 0 0 0 0
"19" "28/01/2008" 0 1.58121398689715 0 0 0
"20" "29/01/2008" 0 0 0 0 0
"21" "30/01/2008" 0 0 0 0 0
"22" "31/01/2008" 0 0 0 0 0
"23" "01/02/2008" 0 0 0 0 0
"24" "04/02/2008" 0 0 0 0 0
"25" "05/02/2008" 0 0 0 0 0
"26" "06/02/2008" 0 0 0 0 0
"27" "07/02/2008" 0 0 0 0 0
"28" "08/02/2008" 2.14000732355798 1.69766978689504 0 1.75685318945262 0
"29" "11/02/2008" 0 0 0 0 0
"30" "12/02/2008" 0 0 0 0 0
"31" "13/02/2008" 0 0 0 0 0
"32" "14/02/2008" 1.46825855993268 1.01452104942038 0 1.36151226158038 0
"33" "15/02/2008" 0 0 0 0 0
"34" "18/02/2008" 1.23828782287823 1.85457398206402 0 1.01737020551797 0
"35" "19/02/2008" 0 0 0 0 0
"36" "20/02/2008" 0 0 0 1.16595050312755 0
"37" "21/02/2008" 0 0 0 0 0
"38" "22/02/2008" 0 0 0 0 0
"39" "25/02/2008" 0 0 0 0 0
"40" "26/02/2008" 0 0 0 0 0
"41" "27/02/2008" 0 0 0 1.14892847454562 0
"42" "28/02/2008" 0 0 0 0 0
"43" "29/02/2008" 0 0 0 1.08156034746327 0
"44" "03/03/2008" 0 0 0 0 0
"45" "04/03/2008" 0 0 0 0 0
"46" "05/03/2008" 0 0 0 0 0
"47" "06/03/2008" 0 0 0 0 0
"48" "07/03/2008" 0 0 0 0 0
"49" "10/03/2008" 0 0 0 0 0
"50" "11/03/2008" 0 0 0 0 0
"51" "12/03/2008" 0 0 0 0 0
"52" "13/03/2008" 0 0 0 0 0
"53" "14/03/2008" 0 0 0 0 0
"54" "17/03/2008" 4.35512801471512 5.36991654793405 0 6.16519844357977 0
"55" "18/03/2008" 2.79350502621745 2.11529748269272 0 3.52300391995049 0
"56" "19/03/2008" 2.71891047108730 2.44490502825019 0 2.88516037009928 0
"57" "20/03/2008" 0 0 0 0 0
"58" "21/03/2008" 0 0 0 0 0
"59" "24/03/2008" 5.54031680331131 5.79959578768216 0 6.7272138683414 0
"60" "25/03/2008" 0 0 0 0 0
"61" "26/03/2008" 0 0 0 0 0
"62" "27/03/2008" 0 0 0 0 0
"63" "28/03/2008" 0 0 0 0 0
"64" "31/03/2008" 1.36298613237674 1.93688809995221 0 1.62820120724346 0
"65" "01/04/2008" 0 0 0 0 0
"66" "02/04/2008" 0 1.50365203568443 0 1.41661422278162 0
"67" "03/04/2008" 0 0 0 0 0
"68" "04/04/2008" 0 0 0 0 0
"69" "07/04/2008" 0 0 0 0 0
"70" "08/04/2008" 0 0 0 0 0
"71" "09/04/2008" 0 0 0 0 0
"72" "10/04/2008" 0 0 0 0 0
"73" "11/04/2008" 0 0 0 0 0
"74" "14/04/2008" 0 0 0 0 0
"75" "15/04/2008" 0 1.12993898169451 0 0 0
"76" "16/04/2008" 0 1.64919239565466 0 0 0
"77" "17/04/2008" 1.85794201323402 2.32701547844896 0 2.13671788020485 0
"78" "18/04/2008" 0 0 0 0 0
"79" "21/04/2008" 0 0 0 0 0
"80" "22/04/2008" 0 0 0 0 0
"81" "23/04/2008" 0 0 0 0 0
"82" "24/04/2008" 0 0 0 0 0
"83" "25/04/2008" 0 0 0 0 0
"84" "28/04/2008" 0 0 0 0 0
"85" "29/04/2008" 1.41455686561253 1.23468581006293 0 1.41084889962815 0
"86" "30/04/2008" 0 0 0 0 0
"87" "01/05/2008" 0 1.5699823478825 0 0 0
"88" "02/05/2008" 0 0 0 0 0
"89" "05/05/2008" 0 0 0 0 0
"90" "06/05/2008" 0 0 0 0 0
"91" "07/05/2008" 0 0 0 0 0
"92" "08/05/2008" 0 0 0 0 0
"93" "09/05/2008" 0 0 0 0 0
"94" "12/05/2008" 0 0 0 0 0
"95" "13/05/2008" 0 0 0 0 0
"96" "14/05/2008" 0 0 0 0 0
"97" "15/05/2008" 0 0 0 0 0
"98" "16/05/2008" 0 0 0 0 0
"99" "19/05/2008" 0 0 0 0 0
"100" "20/05/2008" 0 0 0 0 0
"101" "21/05/2008" 0 0 0 0 0
"102" "22/05/2008" 0 0 0 0 0
"103" "23/05/2008" 0 0 0 0 0
"104" "26/05/2008" 0 0 0 0 0
"105" "27/05/2008" 0 0 0 0 0
"106" "28/05/2008" 0 0 0 0 0
"107" "29/05/2008" 0 0 0 0 0
"108" "30/05/2008" 0 0 0 0 0
"109" "02/06/2008" 0 0 0 0 0
"110" "03/06/2008" 

Re: [R] Trouble installing package 'systemfit'

2009-05-20 Thread Rui Wang
Renaming the file worked! Thanks!

- Original Message -
From: Uwe Ligges 
Date: Wednesday, May 20, 2009 10:07 am
Subject: Re: [R] Trouble installing package 'systemfit'
To: Rui Wang 
Cc: r-help@r-project.org

> 
> 
> Rui Wang wrote:
> > I tried unnder R 2.9.0 and R 2.8.1. Both versions failed to 
> install 'systemfit'. 
> > I downloaded file 'systemfit_1[1].0-8.zip' to install the 
> package. 
> > I am using Windows 2000 service pack 4.
> 
> 
> The filename lost its canonical form, pelase try to rename it to:
> 
> systemfit_1.0-8.zip
> 
> Uwe Ligges
> 
> 
> 
> 
> > The error message is:
> >  
> > Error in gzfile(file, "r") : cannot open the connection
> > In addition: Warning message:
> > In gzfile(file, "r") :
> >   cannot open compressed file 'systemfit_1[1].0-
> 8/DESCRIPTION', probable reason 'No such file or directory'
> >  
> > 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.

[[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] Getting lm() to work with a matrix

2009-05-20 Thread Berwin A Turlach
G'day Luc,

On Wed, 20 May 2009 09:58:41 -0400
Luc Villandre  wrote:

> MikSmith wrote:
> > [...]

> Indeed, functions like /lm()/ require the object fed to the /data/ 
> argument to be either [...]

But the data argument is optional and does not need to be specified.

> In your situation, I suggest you typecast your matrix into a data
> frame using /as.data.frame()/.  [...]

My guess is that he is already working with a data frame and does not
work with matrices, otherwise he should not have encountered problems:

R> response <- matrix(rnorm(120), ncol=4)
R> spectra.spec <- matrix(rnorm(900), ncol=30)
R> spectra.lm <- lm(response[,3]~spectra.spec[,2:20])
R> spectra.lm

Call:
lm(formula = response[, 3] ~ spectra.spec[, 2:20])

Coefficients:
   (Intercept)   spectra.spec[, 2:20]1  
  -0.48404 0.42503  
 spectra.spec[, 2:20]2   spectra.spec[, 2:20]3  
  -0.08955-0.27605  
 spectra.spec[, 2:20]4   spectra.spec[, 2:20]5  
  -0.16832-0.14107  
 spectra.spec[, 2:20]6   spectra.spec[, 2:20]7  
  -0.47009-0.23672  
 spectra.spec[, 2:20]8   spectra.spec[, 2:20]9  
   0.12920 0.23306  
spectra.spec[, 2:20]10  spectra.spec[, 2:20]11  
  -0.28586 0.03579  
spectra.spec[, 2:20]12  spectra.spec[, 2:20]13  
   0.10676-0.34407  
spectra.spec[, 2:20]14  spectra.spec[, 2:20]15  
   0.20253-0.17259  
spectra.spec[, 2:20]16  spectra.spec[, 2:20]17  
   0.19765 0.40705  
spectra.spec[, 2:20]18  spectra.spec[, 2:20]19  
  -0.12448-0.17149  

Cheers,

Berwin

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 returning the name of an object

2009-05-20 Thread Antonio Gasparrini
Hello R users,
 
I'm trying to solve an apparently simple problem.
I include a matrix in a model formula, and I want then to extract the related 
coefficients.
Basically, I want a function func such that:
 
mymatrix <- cbind(rnorm(10),rnorm(10))
y <- b <- rnorm(10)
model <- lm(y ~ b + mymatrix)
func(mymatrix,model)
 
which returns only the 3rd and 4th coefficients.
 
I thought to search by:
 
grep("mymatrix",names(coef(model)))
 
but I don't know how to extract the name "mymatrix" from the object mymatrix.
Is there a specific function, something like func(mymatrix) returning the 
string "mymatrix"?
 
Thanks so much for your time.
 
Antonio Gasparrini
Public and Environmental Health Research Unit (PEHRU)
London School of Hygiene & Tropical Medicine
Keppel Street, London WC1E 7HT, UK
Office: 0044 (0)20 79272406 - Mobile: 0044 (0)79 64925523
Skype contact: a.gasparrini
http://www.lshtm.ac.uk/people/gasparrini.antonio ( 
http://www.lshtm.ac.uk/pehru/ )

[[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] Random effects aov

2009-05-20 Thread Christine Griffiths

Dear All

I have a repeated measures design in which abundance was measured 
repeatedly over 10 months in three treatments (Tortoise A; Tortoise B and 
control) established in 6 blocks, i.e. crossed fixed effects. My original 
design incorporated two tortoises per treatment, however as fieldwork goes 
I ended up losing some animals. Rather than lose a couple of enclosures in 
the analysis and have to do a lmer, I thought I could include tortoise 
weight as an explanatory variable. For my treatments, tortoise weight in 
the control always = 0, while in general Tortoise A is twice as large as 
Tortoise B except when I lost animals. Is this the correct model?


aov(Tel.ab~Tort.W+Treatment*Month+Error(Month/Block))

Or should tortoise weight be nested in Treatment, i.e not included as a 
fixed factor but including the fact that tortoises species may have an 
effect? I am utterly confused now as to whether that should be the case as 
to some extent Tort.W and Treatment are correlated.

Any help would be much appreciated.
Many thanks
Christine


--
Christine Griffiths
School of Biological Sciences
University of Bristol
Woodland Road
Bristol BS8 1UG
Tel: 0117 9287593
Fax 0117 925 7374
christine.griffi...@bristol.ac.uk
http://www.bio.bris.ac.uk/research/mammal/tortoises.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] Error with regsubset in leaps package - vcov and all.best option (plus calculating VIFs for subsets)

2009-05-20 Thread Thomas Lumley

On Wed, 20 May 2009, lara harrup (IAH-P) wrote:




Hi all


I am hoping this is just a minor problem, I am trying to implement a best 
subsets regression procedure on some ecological datasets using the regsubsets 
function in the leaps package. The dataset contains 43 predictor variables plus 
the response (logcount) all in a dataframe called environment. I am 
implementing it as follows:

library(leaps)


subsets<-regsubsets(logcount~.,data=environment,nvmax=10,nbest=2,really.big=FALSE,method="exhaustive")

###the subset regression runs fine when i run it as above and i can get all 
>the usual summaries

###The problem comes when i try and get it to output the variance convariance 
>matric by adding the option vcov=TRUE


Yes, that would be because there is no option vcov=TRUE for regsubsets. There 
is a vcov= option for the coef() method, which may be what is confusing you.




I was wanting to get the variance - covariance matrix as I believe I need it >to 
calculate the Variance Inflation Factors (VIFs) for each of the models >reported by 
regsubsets. As I want to exclude any models that exhibit >multicollinerarity from later 
analysis, I am hoping to select say the 'best' >10 models and bootstrap them to find out 
more about how they perform.


As in the example on the help page, once you have run regsubsets() you can use  
coef() and vcov() on the object it returns to get coefficient estimates and 
variance-covariance matrices for any of the best models.

 -thomas

Thomas Lumley   Assoc. Professor, Biostatistics
tlum...@u.washington.eduUniversity of Washington, Seattle

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Trouble installing package 'systemfit'

2009-05-20 Thread Uwe Ligges



Rui Wang wrote:
I tried unnder R 2.9.0 and R 2.8.1. Both versions failed to install 'systemfit'. 
I downloaded file 'systemfit_1[1].0-8.zip' to install the package. 
I am using Windows 2000 service pack 4.



The filename lost its canonical form, pelase try to rename it to:

systemfit_1.0-8.zip

Uwe Ligges





The error message is:
 
Error in gzfile(file, "r") : cannot open the connection

In addition: Warning message:
In gzfile(file, "r") :
  cannot open compressed file 'systemfit_1[1].0-8/DESCRIPTION', probable reason 
'No such file or directory'
 
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-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Trouble installing package 'systemfit'

2009-05-20 Thread Ronggui Huang
Have you tried another mirror? It seems that downloaded file is incomplete.


2009/5/20 Rui Wang :
> I tried unnder R 2.9.0 and R 2.8.1. Both versions failed to install 
> 'systemfit'.
> I downloaded file 'systemfit_1[1].0-8.zip' to install the package.
> I am using Windows 2000 service pack 4.
>
> The error message is:
>
> Error in gzfile(file, "r") : cannot open the connection
> In addition: Warning message:
> In gzfile(file, "r") :
>  cannot open compressed file 'systemfit_1[1].0-8/DESCRIPTION', probable 
> reason 'No such file or directory'
>
> 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.
>



-- 
HUANG Ronggui, Wincent
PhD Candidate
Dept of Public and Social Administration
City University of Hong Kong
Home page: http://asrr.r-forge.r-project.org/rghuang.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] How to google for R stuff?

2009-05-20 Thread cryan
For Google searches, I find that throwing in the term cran on every search 
helps weed out irrelevant pages.

For example, instead of 

r residuals

I type

r cran residuals

--Chris Ryan

 Original message 
>Date: Wed, 20 May 2009 09:43:14 -0400
>From: Luc Villandre   
>Subject: Re: [R] How to google for R stuff?  
>To: Kynn Jones 
>Cc: r-help@r-project.org
>
>
>Kynn Jones wrote:
>> Hi!  I'm new to R programming, though I've been programming in other
>> languages for years.
>>
>> One thing I find most frustrating about R is how difficult it is to use
>> Google (or any other search tool) to look for answers to my R-related
>> questions.  With languages with even slightly more distinctive names like
>> Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
>> language in the query is enough to ensure that the top hits are relevant.
>>  But this trick does not work for R, because the letter R appears by itself
>> in so many pages, that the chaff overwhelms the wheat, so to speak.
>>
>> So I'm curious to learn what strategies R users have found to get around
>> this annoyance.
>>
>> TIA!
>>
>> KJ
>>
>>  [[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 Kynn,
>
>I've had this problem too in the beginning. Luckily, my personal 
>experience has taught me that almost all relevant R-related information 
>can be found either by searching directly through the archives of the 
>different R-forums or by using the functions "RSiteSearch()" or 
>"help.search()". The reference manuals provided with each package 
>(easily accessible on CRAN) are also invaluable sources of information.
>
>Unfortunately, phrasing queries in a way that will yield relevant 
>results is sometimes hard. Knowledge of the terminology mostly comes 
>from experience, so patience is in order.
>
>Of course, as a last recourse, there's always the mailing list.
>
>Bottom line is, I suggest you try to avoid generic search engines and 
>concentrate your efforts on the different R-forums (note that there are 
>also package-specific forums).
>
>I suspect the more experienced R-users might have better strategies to 
>propose though...
>
>Cheers,
>-- 
>*Luc Villandré*
>/Biostatistician
>McGill University Health Center -
>Montreal Children's Hospital Research Institute/
>
>__
>R-help@r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/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] Getting lm() to work with a matrix

2009-05-20 Thread Luc Villandre

MikSmith wrote:

Hi

I'm fairly new to R and am trying to analyse some large spectral datasets
using stepwise regression (fairly standard in this area). I have a field
sampled dataset, of which a proportion has been held back for validation. I
gather than step() needs to be fed a regression model and lm() can produce a
multiple regression. I had thought something like:

spectra.lm <- lm(response[,3]~spectra.spec[,2:20])

might work but lm() doesnt appear to like being fed a range of columns. I
suspect Ive missed something fairly fundamental here.

Any help much appreciated

best wishes

mike
  

Hi Mike,

Indeed, functions like /lm()/ require the object fed to the /data/ 
argument to be either a list, a data frame or an environment containing 
the variables in the model.  The /formula/ argument will then refer to 
column names or element names.


In your situation, I suggest you typecast your matrix into a data frame 
using /as.data.frame()/. You can attribute column names by using 
/colnames()/. If you have a very large number of columns and you don't 
feel like giving them names individually, using the /paste()/ function 
should save you a lot of time.


Also, character-type objects can be typecasted using /as.formula()/ to 
formula-like objects. So, using a combination of /paste()/ and 
/as.formula()/ might make your life a lot easier.


HTH,
--
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Trouble installing package 'systemfit'

2009-05-20 Thread Rui Wang
I tried unnder R 2.9.0 and R 2.8.1. Both versions failed to install 
'systemfit'. 
I downloaded file 'systemfit_1[1].0-8.zip' to install the package. 
I am using Windows 2000 service pack 4.
 
The error message is:
 
Error in gzfile(file, "r") : cannot open the connection
In addition: Warning message:
In gzfile(file, "r") :
  cannot open compressed file 'systemfit_1[1].0-8/DESCRIPTION', probable reason 
'No such file or directory'
 
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] SEM:Standard error of std.coef estimates?

2009-05-20 Thread John Fox
Dear Bastiaan,

The standard errors of the standardized coefficients aren't simple because
the standard deviations used to standardize the coefficients are also
subject to sampling error. I can think of two ways to get standard errors
for the standardized coefficients: by the delta method and by bootstrapping.
Neither method is implemented in the sem package. Figuring out how to apply
the former would require some work; I'll put it on my to-do list, but may
not get to it. The second approach could easily be implemented via the boot
package.

I hope this helps,
 John


> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org]
On
> Behalf Of BdeGroot
> Sent: May-20-09 7:41 AM
> To: r-help@r-project.org
> Subject: [R] SEM:Standard error of std.coef estimates?
> 
> 
> Hi,
> 
> I am currently working with the sem package in R, to create pathway
> diagrams. Id like to use the standardized path coeffcients. To get these,
I
> use std.coef. However, using this yields only the standardized
coefficients,
> but does not give me the standard error. Does someone know how to get
> std.coef to show the standard error of the standardized path coefficients
as
> well?
> 
> 
> Thanks,
> Bastiaan
> 
> 
> PS:
> When I use std.coef, all I get is this:
> 
> std.coef(path.model.SSI4)
>   Std. Estimate
> par1 par1  0.39499  com_veg <--- tempm
> par2 par2  0.35231  SNutBili <--- tempm
> par3 par3 -0.68170  S_SSI4 <--- tempm
> par4 par4 -0.39145  com_veg <--- Wdeficit
> par5 par5 -0.60025  SNutBili <--- Wdeficit
> par6 par6 -0.20562  S_SSI4 <--- Wdeficit
> par7 par7  0.14871  SNutBili <--- com_veg
> par8 par8  0.14905  S_SSI4 <--- com_veg
> par9 par9 -0.39164  S_SSI4 <--- SNutBili
> --
> View this message in context:
http://www.nabble.com/SEM%3AStandard-error-of-
> std.coef-estimates--tp23633227p23633227.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Luc Villandre


Kynn Jones wrote:

Hi!  I'm new to R programming, though I've been programming in other
languages for years.

One thing I find most frustrating about R is how difficult it is to use
Google (or any other search tool) to look for answers to my R-related
questions.  With languages with even slightly more distinctive names like
Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
language in the query is enough to ensure that the top hits are relevant.
 But this trick does not work for R, because the letter R appears by itself
in so many pages, that the chaff overwhelms the wheat, so to speak.

So I'm curious to learn what strategies R users have found to get around
this annoyance.

TIA!

KJ

[[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 Kynn,

I've had this problem too in the beginning. Luckily, my personal 
experience has taught me that almost all relevant R-related information 
can be found either by searching directly through the archives of the 
different R-forums or by using the functions "RSiteSearch()" or 
"help.search()". The reference manuals provided with each package 
(easily accessible on CRAN) are also invaluable sources of information.


Unfortunately, phrasing queries in a way that will yield relevant 
results is sometimes hard. Knowledge of the terminology mostly comes 
from experience, so patience is in order.


Of course, as a last recourse, there's always the mailing list.

Bottom line is, I suggest you try to avoid generic search engines and 
concentrate your efforts on the different R-forums (note that there are 
also package-specific forums).


I suspect the more experienced R-users might have better strategies to 
propose though...


Cheers,
--
*Luc Villandré*
/Biostatistician
McGill University Health Center -
Montreal Children's Hospital Research Institute/

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Richard . Cotton
> One thing I find most frustrating about R is how difficult it is to use
> Google (or any other search tool) to look for answers to my R-related
> questions.  With languages with even slightly more distinctive names 
like
> Perl, Java, Python, Matlab, OCaml, etc., usually including the name of 
the
> language in the query is enough to ensure that the top hits are 
relevant.
>  But this trick does not work for R, because the letter R appears by 
itself
> in so many pages, that the chaff overwhelms the wheat, so to speak.

There are loads of ways of finding information.

Use the function RSiteSearch, or
The R mail archive  
http://www.googlesyndicatedsearch.com/u/newcastlemaths
RSeek   http://www.rseek.org/
R Searchhttp://www.dangoldstein.com/search_r.html  

The R Graph Gallery http://addictedtor.free.fr/graphiques/
R Help Wiki http://wiki.r-project.org/rwiki/doku.php
R manuals   http://cran.r-project.org/manuals.html
FAQshttp://cran.r-project.org/faqs.html
Task Views  http://cran.r-project.org/web/views/
News
http://www.r-project.org/doc/Rnews/index.html
Books   
http://www.r-project.org/doc/bib/R-books.html
Cranberries http://dirk.eddelbuettel.com/cranberries/

R-Forge (http://r-forge.r-project.org/) and Bioconductor (
http://www.bioconductor.org/GettingStarted) also have their own search 
tools.

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] efficiency when processing ordered data frames

2009-05-20 Thread jim holtman
How much is it currently costing you in time to do the selection process?
Is it having a large impact on your program? Is it the part that is really
consuming the overall time?  What is your concern in this area? Here is the
timing that it take so select from 10M values those that are less than a
specific value.  This takes less than 0.2 seconds:

> x <- runif(1e7)
> system.time(y <- x < .5)
   user  system elapsed
   0.150.050.20
> x <- sort(x)
> system.time(y <- x < .5)
   user  system elapsed
   0.110.030.14
>


On Wed, May 20, 2009 at 8:54 AM, Brigid Mooney  wrote:

> Hoping for a little insight into how to make sure I have R running as
> efficiently as possible.
>
> Suppose I have a data frame, A, with n rows and m columns, where col1
> is a date time stamp.  Also suppose that when this data is imported
> (from a csv or SQL), that the data is already sorted such that the
> time stamp in col1 is in ascending (or descending) order.
>
> If I then wanted to select only the rows of A where col1 <= a certain
> time, I am wondering if R has to read through the entirety of col1 to
> select those rows (all n of them).  Is it possible for R to recognize
> (or somehow be told) that these rows are already in order, thus
> allowing the computation could be completed in ~log(n) row reads
> instead?
>
> Thanks!
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



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

What is the problem that you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Ian Fiske

www.rseek.org is the best solution to this that I have found.

Ian



kynn wrote:
> 
> Hi!  I'm new to R programming, though I've been programming in other
> languages for years.
> 
> One thing I find most frustrating about R is how difficult it is to use
> Google (or any other search tool) to look for answers to my R-related
> questions.  With languages with even slightly more distinctive names like
> Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
> language in the query is enough to ensure that the top hits are relevant.
>  But this trick does not work for R, because the letter R appears by
> itself
> in so many pages, that the chaff overwhelms the wheat, so to speak.
> 
> So I'm curious to learn what strategies R users have found to get around
> this annoyance.
> 
> TIA!
> 
> KJ
> 
>   [[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/How-to-google-for-R-stuff--tp23635068p23635296.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] Error with regsubset in leaps package - vcov and all.best option (plus calculating VIFs for subsets)

2009-05-20 Thread lara harrup (IAH-P)


Hi all


I am hoping this is just a minor problem, I am trying to implement a best 
subsets regression procedure on some ecological datasets using the regsubsets 
function in the leaps package. The dataset contains 43 predictor variables plus 
the response (logcount) all in a dataframe called environment. I am 
implementing it as follows:

library(leaps)


subsets<-regsubsets(logcount~.,data=environment,nvmax=10,nbest=2,really.big=FALSE,method="exhaustive")

###the subset regression runs fine when i run it as above and i can get all the 
usual summaries

###The problem comes when i try and get it to output the variance convariance 
matric by adding the option vcov=TRUE
##When I do that i get the following:

subsets<-regsubsets(logcount~.,data=environment,nvmax=10,nbest=2,really.big=FALSE,method="exhaustive",vcov=TRUE)

Error in model.frame.default(data = environment, vcov = TRUE, formula = 
logcount~  : 
  variable lengths differ (found for '(vcov)')

> traceback()
6: model.frame.default(data = environment, vcov = TRUE, formula = logcount~ 
   .)
5: model.frame(data = environment, vcov = TRUE, formula = logcount~ .)
4: eval(expr, envir, enclos)
3: eval(mm, sys.frame(sys.parent()))
2: regsubsets.formula(logcount~ ., data = environment, nvmax = 10, really.big = 
TRUE, 
   method = "exhaustive", nbest = 5, vcov = TRUE)
1: regsubsets(obs ~ ., data = environment, nvmax = 10, really.big = TRUE, 
   method = "exhaustive", nbest = 5, vcov = TRUE)

I get the same error when i try and add the all.best=TRUE option (as ideally i 
would like it to report the fits of all the subsets).

All the predictor variables and the response are the same length (143) so not 
sure if I am misinterpreting the error or have misspecified the regsubsets?

I was wanting to get the variance - covariance matrix as I believe I need it to 
calculate the Variance Inflation Factors (VIFs) for each of the models reported 
by regsubsets. As I want to exclude any models that exhibit multicollinerarity 
from later analysis, I am hoping to select say the 'best' 10 models and 
bootstrap them to find out more about how they perform.

Or am I going about this all the wrong way? is there away to calulate vifs from 
regsubsets or pass it directly to something that calculates them e.g. VIF in 
the car package?

Any help will be most appreciated, many thanks in advance

Lara

lara.har...@bbsrc.ac.uk

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


Re: [R] How to google for R stuff?

2009-05-20 Thread Jonathan Baron
See http://finzi.psych.upenn.edu/
for many options for searching for R stuff.

If you type R into Google, the R home page usually comes up first.  I
was amazed when this happened 9 years ago.

And now, if I type "R lmer" into Google (without the quotes), a whole
bunch of relevant stuff comes up, although it isn't so systematically
arranged as with the other search options.

Jon

On 05/20/09 09:02, Kynn Jones wrote:
> Hi!  I'm new to R programming, though I've been programming in other
> languages for years.
> 
> One thing I find most frustrating about R is how difficult it is to use
> Google (or any other search tool) to look for answers to my R-related
> questions.  With languages with even slightly more distinctive names like
> Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
> language in the query is enough to ensure that the top hits are relevant.
>  But this trick does not work for R, because the letter R appears by itself
> in so many pages, that the chaff overwhelms the wheat, so to speak.
> 
> So I'm curious to learn what strategies R users have found to get around
> this annoyance.
> 
> TIA!
> 
> KJ
> 
>   [[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.

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

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


Re: [R] Too large a data set to be handled by R?

2009-05-20 Thread Stavros Macrakis
On Tue, May 19, 2009 at 11:59 PM, tsunhin wong  wrote:

> In order to save time, I am planning to generate a data set of size
> 1500 x 2 with each data point a 9-digit decimal number, in order
> to save my time.
> I know R is limited to 2^31-1 and that my data set is not going to
> exceed this limit. But my laptop only has 2 Gb and is running 32-bit
> Windows / XP or Vista.
>

32-bit R on Windows XP with 2GB RAM has no problem with a matrix this size
(not just integers, but also numerics):

> system.time(mm <- matrix( numeric(1500 * 2), 1500, 2))
   user  system elapsed
   0.590.231.87
> system.time(nn <- matrix( runif(1500 * 2), 1500, 2))
   user  system elapsed
   2.660.64   13.39
> system.time(oo <- nn + 3)
   user  system elapsed
   0.240.170.41
> system.time(pp <- oo - oo)
   user  system elapsed
   0.150.130.28

[[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] Functions returning functions

2009-05-20 Thread Stavros Macrakis
On Wed, May 20, 2009 at 7:21 AM, Paulo Grahl  wrote:

> A <- function(parameters) {
> # calculations w/ parameters returning 'y'
> tmpf <- function(x) { # function of 'y' }
> return(tmpf)
> }
>
> The value of the parameters are stored in an environment local to the
> function. Then I call
> x<- something
> B<-A(x)
>
> When R executes this last statement,  does it perform all the
> calculations inside function A again (i.e., all the calculations that
> yield 'y')
>  or the value of 'y' is already stored in the function's local environment
> ?
>

 A <- function(q) {
print("calculating y")
y <- q+1
function(x) print(paste("value of x:",x,"value of y:",y))
 }
> A(5)
[1] "calculating y"
function(x) print(paste("value of x:",x,"value of y:",y))

> A(5)(4)
[1] "calculating y"
[1] "value of x: 4 value of y: 6"
> A5 <- A(5)
[1] "calculating y"
> A5(4)
[1] "value of x: 4 value of y: 6"
>

[[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] Plot data from table with column and row names

2009-05-20 Thread Gabor Grothendieck
Here are a few possibilities:


Lines <- "GM1  GM2  GM3  GM4  GM5
Run1  1  2  1   2  3
Run2  2  1  3   2  1
Run3 2  1  1  1  1"

DF <- read.table(textConnection(Lines), header = TRUE)
long <- as.data.frame.table(as.matrix(DF))
head(long)

with(long, balloonplot(Var1, Var2, Freq))

library(lattice)
dotplot(Freq ~ Var1, long, group = Var2, type = "l")


On Wed, May 20, 2009 at 6:21 AM, Matt Bishop  wrote:
>
> Dear All
> Sorry for what appears a trivial matter - I'm new to R and am stumbling
> ahead.
>
> I have a table of numerical data (36 rows by 12 columns) such as below:
>
>       GM1  GM2  GM3  GM4  GM5 ...etc GM12
> Run1  1      2      1       2      3   ...
> Run2  2      1      3       2      1   ...
> ...
> Run36 2      1      1      1      1
>
> I would like to plot simple line graphs of some of the runs or all 36 to
> compare together but I can't even get a plot to have the GM1-GM12 on the
> x-axis and the numerical y -axis with the scores (1 to 3).
> I think that using >Plot(x) is not correct for this type of data.
> Help would be appreciated - I'm sure I'm missing something...
> Matt
>
> --
> View this message in context: 
> http://www.nabble.com/Plot-data-from-table-with-column-and-row-names-tp23632750p23632750.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

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


[R] How to google for R stuff?

2009-05-20 Thread Kynn Jones
Hi!  I'm new to R programming, though I've been programming in other
languages for years.

One thing I find most frustrating about R is how difficult it is to use
Google (or any other search tool) to look for answers to my R-related
questions.  With languages with even slightly more distinctive names like
Perl, Java, Python, Matlab, OCaml, etc., usually including the name of the
language in the query is enough to ensure that the top hits are relevant.
 But this trick does not work for R, because the letter R appears by itself
in so many pages, that the chaff overwhelms the wheat, so to speak.

So I'm curious to learn what strategies R users have found to get around
this annoyance.

TIA!

KJ

[[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] efficiency when processing ordered data frames

2009-05-20 Thread Brigid Mooney
Hoping for a little insight into how to make sure I have R running as
efficiently as possible.

Suppose I have a data frame, A, with n rows and m columns, where col1
is a date time stamp.  Also suppose that when this data is imported
(from a csv or SQL), that the data is already sorted such that the
time stamp in col1 is in ascending (or descending) order.

If I then wanted to select only the rows of A where col1 <= a certain
time, I am wondering if R has to read through the entirety of col1 to
select those rows (all n of them).  Is it possible for R to recognize
(or somehow be told) that these rows are already in order, thus
allowing the computation could be completed in ~log(n) row reads
instead?

Thanks!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Where to find a changelog for the survival package

2009-05-20 Thread Richard . Cotton
> since some days I try to use the versions 2.35-4 of the survival 
> package instead of versions 2.31, I had installed until now. Several 
> changes in print.survfit, plot.survfit and seemingly in the structure 
> of ratetabels effect some of my syntax files.
> Is there somewhere a documentation of these changes, besides the code 
itself?

It's in the repository on R-Forge.  The latest version is here:
http://r-forge.r-project.org/plugins/scmsvn/viewcvs.php/pkg/survival/Changelog.09?rev=11234&root=survival&view=markup

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.


  1   2   >