[R] if ( expr )

2007-11-20 Thread Gregory Wall

Hello,

I've searched the list but haven't found anything really applicable to my
question. Any advice would be super.

I'm working on a snippet of R code and I have a function with a prototype
like this:

foo - function( x, ... ){
 if( is.na(x)[1] ) {etc...}
}

Where x is typically a vector of bools. 

At times, however, x can be NA, and yet at other super rare times x can be
the result of this type of comparison:

 c(4,5,13,2,3,4,5,7) == numeric(0) 

which produces logical(0). When this is the case, if( is.na(x)[1] ) isn't
happy. 

I'm trying to create a condition to my if statement inside foo that only
is true when x is NA but that doesn't die when its a logical(0). 

Any suggestions on how best to approach this? 

As always, thanks a bunch,

Greg

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Odp: if ( expr )

2007-11-20 Thread Petr PIKAL
Hi


[EMAIL PROTECTED] napsal dne 20.11.2007 10:03:53:

 
 Hello,
 
 I've searched the list but haven't found anything really applicable to 
my
 question. Any advice would be super.
 
 I'm working on a snippet of R code and I have a function with a 
prototype
 like this:
 
 foo - function( x, ... ){
  if( is.na(x)[1] ) {etc...}
 }
 
 Where x is typically a vector of bools. 
 
 At times, however, x can be NA, and yet at other super rare times x can 
be
 the result of this type of comparison:
 
  c(4,5,13,2,3,4,5,7) == numeric(0) 
 
 which produces logical(0). When this is the case, if( is.na(x)[1] ) 
isn't
 happy. 

Check the length. In case of numeric(0) or logical(0) the length is 0 
which you can use for testing.

Regards
Petr

 
 I'm trying to create a condition to my if statement inside foo that 
only
 is true when x is NA but that doesn't die when its a logical(0). 
 
 Any suggestions on how best to approach this? 
 
 As always, thanks a bunch,
 
 Greg
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 is the Gauss-Newton method compared to Levenberg-Marquardt for curve-fitting?

2007-11-20 Thread Katharine Mullen
Almost every problem I have seen in the context of fitting mixtures of
exponentials/Gaussians has near-equal performance under LM or GN in terms
of iterations/evaluations to convergence and the SSE of the solution
found.

(However, very recently I have encountered a problem with a large number
of nonlinear parameters (~100) for which LM finds a better optimum than
GN; I am in the process of looking into why this is the case.)

Regarding profiling: I have never looked for such literature; if you find
it, realize that the results may not generalize to the SSE surface of the
residual functions you will consider.  Therefore you might be better off
doing the profiling yourself for the residual functions that are typical
in your problem domain (you can use the R package minpack.lm for LM).

For general discussion of LM and GN, standard referencs are Bates and
Watts, Nonlinear regression analysis and its applications, and Seber and
Wild, Nonlinear regression.

I believe that one of the main reasons that GN gets more use than LM by R
users is that the former is in base R, and for many simple problems,
writing the function to minimize using a formula is handy, which only nls,
but not minpack.lm, allows.  I don't think it's the case that LM is hardly
competitive in general.

On Tue, 20 Nov 2007, Ali - wrote:


 Hi,

 It seems to me that the most suitable method in R for curve-fitting is
 the use of nls, which uses a Gauss-Newton (GN) algorithm, while the use
 of the Levenberg-Marquardt (LM) algorithm does not seem to be very
 stressed in R. According to this [1] by Ripley, 'Levenberg-Marquardt is
 hardly competitive these days' which could imply the low emphasize on LM
 in R.

 The position of LM is, to some extend, confusing. Bonnans et al [2]
 introduce the trust-region-based method of LM like this:

 'This chapter is mostly devoted to methods which, although less
 universal than the preceding, are useful in a good number of cases.
 The frst one (trust-region) is actually extremely important, and might
 supersede line-searches, sooner or later.'

 The above should demonstrate the contradiction.

 Since some R developers are indeed the pioneers in the optimisation
 theory, I would like to ask for references involving profiling of
 various methods, including more modern techniques, with an application
 in general model-fitting.




 [1] http://tolstoy.newcastle.edu.au/R/help/00b/2492.html

 [2] Numerical Optimization, 2nd ed
 _
 100?s of Music vouchers to be won with MSN Music

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Help with talking to R from Java (on Window)

2007-11-20 Thread Ido M. Tamir
Does anybody know any alternative ways to be able to call R from Java? 

JRI
http://rosuda.org/JRI/
now contained in rJava
http://www.rforge.net/rJava/

and new is this one which
I think provides something on top of rJava maybe
Rserve:

http://www.ebi.ac.uk/microarray-srv/frontendapp/BIOCEP_README.txt

best wishes
ido

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ASCII character set and hyphen

2007-11-20 Thread Roland Kaiser

Am 19.11.2007 um 18:43 schrieb Prof Brian Ripley:

 On Mon, 19 Nov 2007, Roland Kaiser wrote:

 Hi all!

 To add to my previous posting
 I want to give some more deatils give a more precise

 I want to print a hyphen to a pdf() or postscript() device.
 As the documentaion of postscript says
 ASCII Character 45(-) is mapped to a minus sign (ASCII Character
 95) by default.
 The advice given is to use \173 for a hyphen.

 But, the following code produces a curly brace
 instead of a hyphen.

 Thanks for any advice?

 Check your reading before posting?  The advice actually is

  There is an exception.  Character 45 ('-') is always set as
  minus (its value in Adobe ISOLatin1) even though it is hyphen in
  the other encodings.  Hyphen is available as character 173 (octal
  0255) in all the Latin encodings, Cyrillic and Greek.

Sorry, I missed to honour the octal coding.


 So try \255.  And please don't post twice.

I tried that, bit it raised an error

pdf(foo.pdf, encoding = ISOLatin1)
display.ascii.d()
mtext(\255, side = 3)
dev.off()

Warning messages:
1: In mtext(\xad, side = 3) : ungültige Eingabe für mbcsToLatin1





 Roland

 library(rgr)
 pdf(foo.pdf, encoding = ISOLatin1)
 display.ascii.d()
 mtext(\173, side = 3)
 dev.off()


 R version 2.6.0 (2007-10-03)
 i386-apple-darwin8.10.1

 locale:
 de_AT.UTF-8/de_AT.UTF-8/de_AT.UTF-8/C/de_AT.UTF-8/de_AT.UTF-8

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

 other attached packages:
 [1] rgr_1.0.3   MASS_7.2-36 akima_0.5-1

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


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

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


Re: [R] biplot

2007-11-20 Thread Bernardo Rangel Tura

On Mon, 2007-11-19 at 13:51 -0500, Weiwei Shi wrote:
 Hi,
 
 I am wondering how to draw biplot with the same scales on both plots?
 For example, if the two plots have much different scales, generally
 the two x-y's are scaled so that the two plots are sitting in the
 center automatically. How to disable this?
 
 Thanks

Hi WeiWei

To solve your problem you must use the options xlim, ylim in your biplot


par(mfrow=c(2,1))
biplot(...,xlim=c(minimun,maximun),ylim=c(minimun,maximun),...)
biplot(...,xlim=c(minimun,maximun),ylim=c(minimun,maximun),...)

-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ASCII character set and hyphen

2007-11-20 Thread Prof Brian Ripley

On Tue, 20 Nov 2007, Roland Kaiser wrote:



Am 19.11.2007 um 18:43 schrieb Prof Brian Ripley:


On Mon, 19 Nov 2007, Roland Kaiser wrote:


Hi all!

To add to my previous posting
I want to give some more deatils give a more precise

I want to print a hyphen to a pdf() or postscript() device.
As the documentaion of postscript says
ASCII Character 45(-) is mapped to a minus sign (ASCII Character
95) by default.
The advice given is to use \173 for a hyphen.

But, the following code produces a curly brace
instead of a hyphen.

Thanks for any advice?


Check your reading before posting?  The advice actually is

 There is an exception.  Character 45 ('-') is always set as
 minus (its value in Adobe ISOLatin1) even though it is hyphen in
 the other encodings.  Hyphen is available as character 173 (octal
 0255) in all the Latin encodings, Cyrillic and Greek.


Sorry, I missed to honour the octal coding.



So try \255.  And please don't post twice.


I tried that, bit it raised an error

pdf(foo.pdf, encoding = ISOLatin1)
display.ascii.d()
mtext(\255, side = 3)
dev.off()

Warning messages:
1: In mtext(\xad, side = 3) : ungültige Eingabe für mbcsToLatin1


In UTF-8 you need \uad.  Note that it is character 0255 in the 8-bit 
encodings mentioned and in UTF-8, *but* \255 is not valid to produce 
that character in UTF-8.



Roland

library(rgr)
pdf(foo.pdf, encoding = ISOLatin1)
display.ascii.d()
mtext(\173, side = 3)
dev.off()


R version 2.6.0 (2007-10-03)
i386-apple-darwin8.10.1

locale:
de_AT.UTF-8/de_AT.UTF-8/de_AT.UTF-8/C/de_AT.UTF-8/de_AT.UTF-8

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

other attached packages:
[1] rgr_1.0.3   MASS_7.2-36 akima_0.5-1

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



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


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



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] biplot

2007-11-20 Thread S Ellison
Also check the asp= parameter in plot.default and plot.window; this sets
the aspect ratio so that 1 unit in x is the same physicla length as 1
unit in y. I don;t know whether it is respeced by your particular
biplot, though.

 Bernardo Rangel Tura [EMAIL PROTECTED] 20/11/2007 10:51:12


On Mon, 2007-11-19 at 13:51 -0500, Weiwei Shi wrote:
 Hi,
 
 I am wondering how to draw biplot with the same scales on both
plots?
 For example, if the two plots have much different scales, generally
 the two x-y's are scaled so that the two plots are sitting in the
 center automatically. How to disable this?
 
 Thanks

Hi WeiWei

To solve your problem you must use the options xlim, ylim in your
biplot


par(mfrow=c(2,1))
biplot(...,xlim=c(minimun,maximun),ylim=c(minimun,maximun),...)
biplot(...,xlim=c(minimun,maximun),ylim=c(minimun,maximun),...)

-- 
Bernardo Rangel Tura, M.D,MPH,Ph.D
National Institute of Cardiology
Brazil

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

***
This email and any attachments are confidential. Any use...{{dropped:8}}

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] ASCII character set and hyphen

2007-11-20 Thread Roland Kaiser

Am 20.11.2007 um 12:13 schrieb Prof Brian Ripley:

 On Tue, 20 Nov 2007, Roland Kaiser wrote:


 Am 19.11.2007 um 18:43 schrieb Prof Brian Ripley:

 On Mon, 19 Nov 2007, Roland Kaiser wrote:

 Hi all!

 To add to my previous posting
 I want to give some more deatils give a more precise

 I want to print a hyphen to a pdf() or postscript() device.
 As the documentaion of postscript says
 ASCII Character 45(-) is mapped to a minus sign (ASCII Character
 95) by default.
 The advice given is to use \173 for a hyphen.

 But, the following code produces a curly brace
 instead of a hyphen.

 Thanks for any advice?

 Check your reading before posting?  The advice actually is

  There is an exception.  Character 45 ('-') is always set as
  minus (its value in Adobe ISOLatin1) even though it is  
 hyphen in
  the other encodings.  Hyphen is available as character 173  
 (octal
  0255) in all the Latin encodings, Cyrillic and Greek.

 Sorry, I missed to honour the octal coding.


 So try \255.  And please don't post twice.

 I tried that, bit it raised an error

 pdf(foo.pdf, encoding = ISOLatin1)
 display.ascii.d()
 mtext(\255, side = 3)
 dev.off()

 Warning messages:
 1: In mtext(\xad, side = 3) : ungültige Eingabe für mbcsToLatin1

 In UTF-8 you need \uad.  Note that it is character 0255 in the 8- 
 bit encodings mentioned and in UTF-8, *but* \255 is not valid to  
 produce that character in UTF-8.

Great Thanks
for clarifying this point!

Roland


 Roland

 library(rgr)
 pdf(foo.pdf, encoding = ISOLatin1)
 display.ascii.d()
 mtext(\173, side = 3)
 dev.off()


 R version 2.6.0 (2007-10-03)
 i386-apple-darwin8.10.1

 locale:
 de_AT.UTF-8/de_AT.UTF-8/de_AT.UTF-8/C/de_AT.UTF-8/de_AT.UTF-8

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

 other attached packages:
 [1] rgr_1.0.3   MASS_7.2-36 akima_0.5-1

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


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

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


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

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


[R] significance levels for partial correlations?

2007-11-20 Thread Ashish Ranpura

I've seen that this question has been asked before, in the archives,  
but I haven't been able to find a workable answer. This may be a  
failure to understand the statistics!

The problem is that, while I can easily get partial correlation  
values out of corpcor, how do I get significance values? Surely the  
significance of a partial correlation between two variables isn't the  
same as the simple bivariate correlation significance (cor.test)? As  
I said, I may be misunderstanding the stats.


And just to round out the scenario, I should mention that I've  
written a function that uses the corpcor library to perform partial  
correlations on experimental variables while partialing out the  
effect of control variables (as opposed to getting the partial  
correlation of a single variable controlling for ALL other  
variables). This is just a convenience function that allows me to  
stick in a whole data frame and analyze only those variables I'm  
interested in.

I won't paste in that function here, it's not relevant to the  
problem, but if anyone wants a copy just let me know. Here is the  
syntax:

pcor.n = function (df, cont, expi=) {
###
## Perform an n-order partial correlation, controlling for the  
influence of
##   control variables on experimental ones.
##
## df   data frame containing all the variables.
## cont a list of control variable names (list of strings)
## expi a list of experimental variable names (list of strings).
## (defaults to all variables excluding controls)
##
## RETURN VALUES
##   The function returns a matrix of partial correlation values,  
excluding the
##   effects of the control variables.
##
###

Thanks for any guidance,

-Ashish Ranpura.


-
Ashish Ranpura
Institute of Cognitive Neuroscience
University College London
17 Queen Square
London WC1N 3AR

tel: +44 (20) 7679 1126
web: http://www.icn.ucl.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.


[R] match.call idiom to call other function with same arguments

2007-11-20 Thread Mads Jeppe Tarp-Johansen
The R language definition (version 2.5.1, 2007-06-27, p37) outlines an 
idiom (here perhaps abusively abbreviated)

   m - match.call()
   m[[1]] - as.name('plot')
   eval(m, parent.frame() )

A posting (Subject: Re: [Rd] problems with plot.formula, Date: Wed 26 
May 2004 - 05:44:34 EST, From: Prof Brian Ripley ([EMAIL PROTECTED])) 
related to plot.formula reads

   not a standard idiom for a generic with a formula method

Could someone kindly direct my attention to a tutorial/howto/intro or 
other written material that provides insight on how this idiom (and 
preferably other R-idioms) should be used and not used?

If the answer is that there is no such other material, so the solution is 
go read the language definition again, go think again and go (hopefully) 
figure that would be appreciated too.

Thanks, MJ

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Use and misuse of update function for non-models. Any views/recommendations??

2007-11-20 Thread Søren Højsgaard
Dear all,
 
I wonder if it is bad style (or something worse) to create an update 
function which does not work on model objects of the lm, glm etc. type. 
Specifically, I have some graph objects (graphs as mathematical objects, not as 
displays) which I want to alter and for that purpose I thought of writing an 
update function. Would doing so violate a deeper philosophy in the R system 
or have other unfortunate consequences. If so, I'm happy to hear other 
suggestions...
 
Regards
Søren

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 improve a function converting year, day of year, decimal hour into date ?

2007-11-20 Thread Ptit_Bleu

Hi,

I would like to build a date from a year, a day of the year and a decimal
hour.
Ex : reconst_date(2007,324,12.50) gives 2007-11-20 12:30:0

The following function is doing this job but I would like to know if there
is a function which directly converts the decimal hours into
hours:minutes:secondes ?

Thanks for your help,
Have a nice day,
Ptit Bleu.



reconst_date-function(annee, jour, heured) {
str_anneejour-paste(annee,jour,sep= )
str_anneemoisjour-strptime(str_anneejour, %Y %j)
heure-trunc(heured)
minute-trunc((heured-heure)*60)
seconde-((heured-heure)*60-minute)*60
seq_dateR-paste(str_anneemoisjour,
,heure,:,minute,:,round(seconde),sep=)
return(seq_dateR)
}
-- 
View this message in context: 
http://www.nabble.com/How-to-improve-a-function-converting-year%2Cday-of-year%2Cdecimal-hour-into-date---tf4843032.html#a13855563
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] Use and misuse of update function for non-models. Any views/recommendations??

2007-11-20 Thread Gabor Grothendieck
If you write an update.X method where X is the class of your graph
objects then it will work on
your graph objects and yet still work on lm, glm, etc.

On Nov 20, 2007 7:01 AM, Søren Højsgaard [EMAIL PROTECTED] wrote:
 Dear all,

 I wonder if it is bad style (or something worse) to create an update 
 function which does not work on model objects of the lm, glm etc. type. 
 Specifically, I have some graph objects (graphs as mathematical objects, not 
 as displays) which I want to alter and for that purpose I thought of writing 
 an update function. Would doing so violate a deeper philosophy in the R 
 system or have other unfortunate consequences. If so, I'm happy to hear other 
 suggestions...

 Regards
 Søren

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 improve a function converting year, day of year, decimal hour into date ?

2007-11-20 Thread Gabor Grothendieck
library(chron)
chron(paste(1/1/, year, sep = )) + julday + hour/24

That produces a chron, i.e. dates/times class datetime.  If you want
it as a string use format(...above expression...)See the help desk
article in R News 4/1.

On Nov 20, 2007 6:53 AM, Ptit_Bleu [EMAIL PROTECTED] wrote:

 Hi,

 I would like to build a date from a year, a day of the year and a decimal
 hour.
 Ex : reconst_date(2007,324,12.50) gives 2007-11-20 12:30:0

 The following function is doing this job but I would like to know if there
 is a function which directly converts the decimal hours into
 hours:minutes:secondes ?

 Thanks for your help,
 Have a nice day,
 Ptit Bleu.

 

 reconst_date-function(annee, jour, heured) {
 str_anneejour-paste(annee,jour,sep= )
 str_anneemoisjour-strptime(str_anneejour, %Y %j)
 heure-trunc(heured)
 minute-trunc((heured-heure)*60)
 seconde-((heured-heure)*60-minute)*60
 seq_dateR-paste(str_anneemoisjour,
 ,heure,:,minute,:,round(seconde),sep=)
 return(seq_dateR)
 }
 --
 View this message in context: 
 http://www.nabble.com/How-to-improve-a-function-converting-year%2Cday-of-year%2Cdecimal-hour-into-date---tf4843032.html#a13855563
 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] Problem with code for bootstrapping chi square test with count data

2007-11-20 Thread Geertje Van der Heijden
Hi,

I'd like some advice on bootstrapping in R.

I have a species x with 20 individuals and a factor containing 0 and 1's
(in this case 5 zeros and 15 ones). I want to compare the frequency of
the occurrence of 1 with a probability value. This code seems to work to
do this in R.

attach(test)
p - c(0.5272, (1-0.5272))
sp1_1 - length(subset(x, x==1))
sp1_0 - length(subset(x, x==0))
obs1_1 - c(sp1_1, sp1_0)
chisq.test(obs1_1, p=p)

However, I'd like to bootstrap these 20 individuals to produce a whole
population of samples and I'd like to do a chi-square test for each of
the bootstrap sample to create a distribution of the chi-square
statistic.

I have bootstrapped the 0's and 1's of x 20 times using the following
code:

resamples - lapply(1:20, function(i) sample(x, replace=T))

What I can't get to work is how to calculate the observed values for 1's
and 0's in each of the bootstrap samples, which I need to do a
chi-square test for each sample. The methd I used above doesn't seem to
work the results for resamples. Does anyone have an idea on how to get
this to work? Or is there another easier way to do this? I hope it is
clear what I am trying to do!

I have tried looking on the internet and in the R archives, but I can't
find what I am looking for.

Thanks very much in advance for your help!
Geertje


Geertje van der Heijden
PhD student
Tropical Ecology
School of Geography
University of Leeds
Leeds LS2 9JT

Tel: (+44)(0)113 3433345 
Email: [EMAIL PROTECTED]



[[alternative HTML version deleted]]

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


Re: [R] Use and misuse of update function for non-models. Any views/recommendations??

2007-11-20 Thread Tobias Verbeke
Gabor Grothendieck wrote:
 If you write an update.X method where X is the class of your graph
 objects then it will work on
 your graph objects and yet still work on lm, glm, etc.

One example (for non-model objects) is e.g. the update method
for survey design objects (update.survey.design)
in the survey package by Thomas Lumley.

HTH,
Tobias

 On Nov 20, 2007 7:01 AM, Søren Højsgaard [EMAIL PROTECTED] wrote:
 Dear all,

 I wonder if it is bad style (or something worse) to create an update 
 function which does not work on model objects of the lm, glm etc. type. 
 Specifically, I have some graph objects (graphs as mathematical objects, not 
 as displays) which I want to alter and for that purpose I thought of writing 
 an update function. Would doing so violate a deeper philosophy in the R 
 system or have other unfortunate consequences. If so, I'm happy to hear 
 other suggestions...

 Regards
 Søren

-- 

Tobias Verbeke - Consultant
Business  Decision Benelux
Rue de la révolution 8
1000 Brussels - BELGIUM

+32 499 36 33 15
[EMAIL PROTECTED]

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


Re: [R] How to improve a function converting year, day of year, decimal hour into date ?

2007-11-20 Thread Ptit_Bleu

Thank you Gabor for your fast answer (received as I was reading R News 4/1)
Ptit Bleu.


library(chron)
chron(paste(1/1/, year, sep = )) + julday + hour/24

That produces a chron, i.e. dates/times class datetime.  If you want
it as a string use format(...above expression...)See the help desk
article in R News 4/1.

-- 
View this message in context: 
http://www.nabble.com/How-to-improve-a-function-converting-year%2Cday-of-year%2Cdecimal-hour-into-date---tf4843032.html#a13856584
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] Use and misuse of update function for non-models. Any views/recommendations??

2007-11-20 Thread Prof Brian Ripley
update() is generic, so the recommended approach would be to write a 
method for your objects.


Creating your own function update() in a package would probably not break 
too much, as namespaces would protect most functions using the generic in 
stats.  But it could be very confusing to users.


On Tue, 20 Nov 2007, Søren Højsgaard wrote:


Dear all,

I wonder if it is bad style (or something worse) to create an update 
function which does not work on model objects of the lm, glm etc. type. 
Specifically, I have some graph objects (graphs as mathematical objects, 
not as displays) which I want to alter and for that purpose I thought of 
writing an update function. Would doing so violate a deeper philosophy 
in the R system or have other unfortunate consequences. If so, I'm happy 
to hear other suggestions...


Regards
Søren

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



--
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] How to map clusters to a correlation matrix

2007-11-20 Thread Serguei Kaniovski

Dear All,

I have several socio-economic and geographic variables for the 27 EU
countries. I would to use these data to derive a correlation matrix between
groups of countries (for a different application).

I thought of using kmeans to cluster the groups, and then calibrate between
group correlations using distances between the centroids, and within group
correlations using distances in a cluster to the own centroid. To calibrate
is to transform a distance to a (positive) correlation coefficient using
some suitable function. Positive correlations reflect the strength of
common tendencies among the countries.

All the above seems crude to me, especially as you have to choice a
transformation function for a distance to a correlation coefficient. Are
there any better methods to do this?

Thanks is advance,
Serguei
[[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] plotting confidence intervals of regression line

2007-11-20 Thread Tim Holland
Hello,

I am trying to generate a confidence interval (90 or 95%) of a regression
line.  This is primarily just for illustration on a scatter plot (i.e. I am
trying to make this
http://www.ast.cam.ac.uk/~rgm/scratch/statsbook/graphics/anima4.gif).

I have been trying to use the predict.lm function, with interval set as
confidence, but this still seems to be giving me a prediction interval (as
below).  It is giving the interval based on the x value of a given point, as
opposed to the confidence interval of the regression line in general.  Is
predict.lm the correct function to be using, or is there something else more
appropriate?

 predict.lm(test, interval = c(confidence), level = 0.90)
fitlwr   upr
1  4.170807 -0.2171226  8.558738
2  5.807453  2.1283100  9.486597
3  6.625776  3.2397994 10.011753
4  8.262422  5.2795295 11.245315
5  9.080745  6.1821741 11.979317
6  9.899068  6.9954692 12.802667
7  7.444099  4.2947040 10.593495
8 13.172360  9.4577068 16.887014
9 20.537267 13.0143098 28.060224

I have also tried using package 'ggplot' as follows:

install.packages(ggplot)
library(ggplot)
qplot(wt, mpg, data=mtcars, type=c(point,smooth), method=lm)
(following Hadley Wickham on this help list)

This generates a plot that looks roughly like what I want, but there is some
customizing of the plot that I would prefer to do in the standard 'plot'
function of the 'graphics' package. Also, ggplot does not give me a vector
of the values of the CI themselves, which would be useful to have.

Any help would be very appreciated.

Thanks,
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.


[R] p.adjust on matrix of P-values from correlations

2007-11-20 Thread Muenchen, Robert A (Bob)
Hi All,

I'm stumped on something that must be trivial. I created a correlation
matrix on 4 variables (6 correlations) using Hmisc's rcorr function. I
wanted to correct the P-value matrix for the number of tests done, so I
ran it through the p.adjust function. That function adjusted for the 12
p-values it saw, rather than 6. I added the argument n=6 to p.adjust but
it requires that n be greater than the length of x. I guess its author
assumed you would always be correcting for more tests than it could see.

I changed the matrix into a long vector to see if that would matter. The
help file says it requires vector, but the result was the same. 

If I were using the conservative Bonferroni correction, I could divide
the corrected P-values by 2 to make n=6 after the fact. However, I'm
using Holm's sequential method, so that's no good. 

Any ideas?

Thanks,
Bob

P.S. I'm using R 2.6.0 Patched on Windows XP.

=
Bob Muenchen (pronounced Min'-chen), 
Manager, Statistical Consulting Center 
U of TN Office of Information Technology
Stokely Management Center, Suite 200
916 Volunteer Blvd., Knoxville, TN 37996-0520
Voice: (865) 974-5230
FAX: (865) 974-4810
Email: [EMAIL PROTECTED]
Web: http://oit.utk.edu/scc
Map: http://www.utk.edu/maps 
News: http://listserv.utk.edu/archives/statnews.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] Use and misuse of update function for non-models. Any views/recommendations??

2007-11-20 Thread Luke Tierney

On Tue, 20 Nov 2007, Prof Brian Ripley wrote:

update() is generic, so the recommended approach would be to write a method 
for your objects.


Creating your own function update() in a package would probably not break too 
much, as namespaces would protect most functions using the generic in stats. 
But it could be very confusing to users.


Maybe.  update is generic with a netral set of argument names; on the
other hand, the _documentation_ of update is not generic -- it is
specific to updating models. So there is opportunity for confusion
from that direction.

Best,

luke



On Tue, 20 Nov 2007, Søren Højsgaard wrote:


Dear all,

I wonder if it is bad style (or something worse) to create an update 
function which does not work on model objects of the lm, glm etc. type. 
Specifically, I have some graph objects (graphs as mathematical objects, 
not as displays) which I want to alter and for that purpose I thought of 
writing an update function. Would doing so violate a deeper philosophy in 
the R system or have other unfortunate consequences. If so, I'm happy to 
hear other suggestions...


Regards
Søren

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

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






--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
   Actuarial Science
241 Schaeffer Hall  email:  [EMAIL PROTECTED]
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] How to map clusters to a correlation matrix

2007-11-20 Thread Serguei Kaniovski


To Walter,

I am building a model of voting in the EU Council of Ministers. A voting
scenario assumes the probabilities of yes votes, possible different for
each country, and correlation coefficient between them.

The country variables (data) reflect the background characteristics that
are relevant for the likelihood of bloc formation in the Council. I would
like to cluster the countries in what I call probabilistic voting blocs,
and construct a correlation matrix between votes in different blocs and
between votes in each bloc.

I then use the probabilities and correlation coefficients to construct a
joint probability distribution on the set of all conceivable voting
outcomes and thus compute the probabilities of voting outcomes that are of
interest, such as probability of a country casting a decisive vote, etc.

Serguei

Austrian Institute of Economic Research (WIFO)

P.O.Box 91  Tel.: +43-1-7982601-231
1103 Vienna, AustriaFax: +43-1-7989386

Mail: [EMAIL PROTECTED]
http://www.wifo.ac.at/Serguei.Kaniovski
[[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] adding an image to a plot

2007-11-20 Thread Rajarshi Guha
Hi, I'm writing code to generate a plot, in which I draw a series of  
rectangles. So my code is of the form

plot.new()
plot.window( ... )

draw rectangle
draw rectangle
...

Is there a way for me to insert a PNG or PDF graphic at a specific  
position in the plot (ideally in  plot coordinates)? I realize that  
this might probably be better done in a separate image editor, but if  
it could be done programmatically that would be very handy

Thanks,

---
Rajarshi Guha  [EMAIL PROTECTED]
GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04  06F7 1BB9 E634 9B87 56EE
---
So the Zen master asked the hot-dog vendor,
Can you make me one with everything?
 - TauZero on Slashdot

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


Re: [R] adding an image to a plot

2007-11-20 Thread Gabor Grothendieck
Check out this thread:

http://tolstoy.newcastle.edu.au/R/e2/help/07/04/14273.html

On Nov 20, 2007 9:26 AM, Rajarshi Guha [EMAIL PROTECTED] wrote:
 Hi, I'm writing code to generate a plot, in which I draw a series of
 rectangles. So my code is of the form

 plot.new()
 plot.window( ... )

 draw rectangle
 draw rectangle
 ...

 Is there a way for me to insert a PNG or PDF graphic at a specific
 position in the plot (ideally in  plot coordinates)? I realize that
 this might probably be better done in a separate image editor, but if
 it could be done programmatically that would be very handy

 Thanks,

 ---
 Rajarshi Guha  [EMAIL PROTECTED]
 GPG Fingerprint: 0CCA 8EE2 2EEB 25E2 AB04  06F7 1BB9 E634 9B87 56EE
 ---
 So the Zen master asked the hot-dog vendor,
 Can you make me one with everything?
 - TauZero on Slashdot

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] plotting coxph results using survfit() function

2007-11-20 Thread Shoaaib Mehmood
stephen,

Thanks for your help. I want to draw a plot which shows separate
survival curves for each category of X on the same plot(same set of
axes). Your code produces a separate curve for each combination of X
and Y but I don't want curves for combinations of X and Y since Y has
many levels and also the values of Y don't have any significance in my
case. Is there  a way of doing what i want to do i.e. getting separate
survival curves for each level of X using the function survfit() on an
object mod.phm which is a coxph object such that:

mod.phm-coxph(formula=Surv(time,Flag_Death)~X+Y, data= datFrame)

Help

On Nov 14, 2007 9:08 AM, Stephen Weigand [EMAIL PROTECTED] wrote:
 On Nov 13, 2007 5:53 AM, Shoaaib Mehmood [EMAIL PROTECTED] wrote:

  i want to make survival plots for a coxph object using survfit
  function. mod.phm is an object of coxph class which calculated results
  using columns X and Y from the DataFrame. Both X and Y are
  categorical. I want survival plots which shows a single line for each
  of the categories of X i.e. '4' and 'C'. I am getting the following
  error:
 
   attach(DataFrame)
   DataFrame.X-data.frame(X=c('4','C'),Y=rep(mean(Y),2))
   detach()

 As you have it, Y in DataFrame.X will be created as numeric
 which isn't what you probably  want (since you say Y is
 categorical).

 Also, you will run into problems if you create newdata and it
 doesn't have all the levels of all the factors in your model. You
 can do this:

 newdat - expand.grid(X = c(4, C, plus all other levels),
   Y = c(2, plus all other levels))

 plot(survfit(cox.mod, newdata = subset(newdat, Y == 2)))


   plot(survfit(mod.phm, newdata=DataFrame.X), lty=c(1,2),ylim=c(.6,1))
  Error in `contrasts-`(`*tmp*`, value = contr.treatment) :
  contrasts can be applied only to factors with 2 or more levels
 
  any help will be appreciated.
 




-- 
Regards,
Rana Shoaaib Mehmood

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] reading graph metadata text from a file

2007-11-20 Thread Alexy Khrabrov
I've tried tetxplot() but it fills the whole frame.  I could either  
use mfrow but it would devote unnecessarily large space to the text.   
In fact I want it in a corner of my current plot, not occupied by the  
curves.  Here's what I ended up with -- it works, but I have to  
manually move top text down as it's cut off by the upper boundary of  
the graph.  Any better/shorter/nicer ways?

First I fetch the dimensions of the current plot:

max.xy - function() {
p - par()
x.max - p$usr[2]
y.max - p$usr[4]
xy.coords(x=x.max, y=y.max)
}

Then, after plotting, I say

plot(...)

xy.max - max.xy()

# top-right -- need to move a bit down or letters are cut off on top:
text(xy.max$x,xy.max$y*0.99,story$text,adj=c(1,1),col=blue)

# bottom-right -- no cut-off, a small nice gap comes free:
# story.text is story$text with some more appended details
text(xy.max$x, 0, story.text,adj=c(1,0),col=blue)

As for the original question -- I ended up creating, in each data  
directory, a file story.r, looking like this:

-
# R titles, labels, and story text for the plot
# when I assigned color=blue right in data.frame, it became an  
integer level!
story - data.frame(title=,x=,y=,text=,color=)
story$title - graph title
story$x - x units
story$y - y units
story$text - story text -- this data has come  long way.  Once upon  
a time there was R...
# we can separate colors of title, labels, and text like
# title.color, x.color, y.color, text.color
story$color - dark blue
-

First I create a data.frame and then assign to its components one by  
one for readability.  When I tried to assign color right in data.frame 
(..., color=blue), it became integer levels!  So I had to move it  
out along with others.  What's the logic here?

Cheers,
Alexy

On Nov 20, 2007, at 1:39 AM, Bert Gunter wrote:

 ... But is I understand correctly,this is certainly straightforward  
 without
 textplot,too...

 e.g.
 mylegend - Some text...\n Some more text
 mytitle - This is a title
 plot(0:1,0:1, main = mytitle)
 legend(.2,.2,leg=mylegend, bty=n)

 Naturally, this could all be functionized and the various text  
 arguments
 passed as arguments to the function (see ?plot.default or its  
 code); or they
 could be components of a list, or ...


 Bert Gunter
 Genentech Nonclinical Statistics


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
 project.org] On
 Behalf Of Greg Snow
 Sent: Monday, November 19, 2007 2:18 PM
 To: Alexy Khrabrov; r-help@r-project.org
 Subject: Re: [R] reading graph metadata text from a file

 You may want to use the textplot function from the gplots package  
 rather
 than the legend.

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



 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Alexy Khrabrov
 Sent: Monday, November 19, 2007 1:17 PM
 To: r-help@r-project.org
 Subject: [R] reading graph metadata text from a file

 I'd like to produce graphs with titles, axis labels, and
 legend as parameters read from a separate text file.
 Moreover, I'd like to use the legend for a short summary of
 the data -- not necessarily for describing the line colors
 per se.  How do we do this?

 Cheers,
 Alexy

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


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


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


[R] Friendly way to link R - MySQL and non-(R and Mysql) users ?

2007-11-20 Thread Ptit_Bleu

Thanks to your help, I managed to link R and a Mysql Database, send queries,
plot the results and put everything in a pdf document (with Sweave).

My co-workers find the job not bad but they would like to have a friendly
interface to send queries and see the graphs (the pdf document is not
necessary).
Something like this coul be a good starting point :

---
|  Name of the X columns : ___   |
|  Name of the Y colums   : ___   |
|  Send query Y/N   : ___   |
---

I read some posts about this topic but all need a server (if I read well).
I'd just want to use it on a local machine.
Is there a way to realize such an interface and to link it directly to an
R-script (which will send the query to MySQL and will plot the result of the
query) ?

Thanks for your help,
Ptit Bleu.

-- 
View this message in context: 
http://www.nabble.com/Friendly-way-to--link-R---MySQL-and-non-%28R-and-Mysql%29-users---tf4844081.html#a13858847
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] biplot

2007-11-20 Thread Prof Brian Ripley
On Tue, 20 Nov 2007, S Ellison wrote:

 Also check the asp= parameter in plot.default and plot.window; this sets
 the aspect ratio so that 1 unit in x is the same physicla length as 1
 unit in y. I don;t know whether it is respeced by your particular
 biplot, though.

That's not how biplot.default() does it: rather it always plots a square 
plot within the device window with axes it manages itself and which do 
ensure that the scales are the same in both directions.

I don't understand the request: the two quantities plotted on a 
conventional biplot are dimensionally different, so why would one want 
them to have the same scale?

 Bernardo Rangel Tura [EMAIL PROTECTED] 20/11/2007 10:51:12


 On Mon, 2007-11-19 at 13:51 -0500, Weiwei Shi wrote:
 Hi,

 I am wondering how to draw biplot with the same scales on both
 plots?
 For example, if the two plots have much different scales, generally
 the two x-y's are scaled so that the two plots are sitting in the
 center automatically. How to disable this?

 Thanks

 Hi WeiWei

 To solve your problem you must use the options xlim, ylim in your
 biplot


 par(mfrow=c(2,1))
 biplot(...,xlim=c(minimun,maximun),ylim=c(minimun,maximun),...)
 biplot(...,xlim=c(minimun,maximun),ylim=c(minimun,maximun),...)

Hmm: that is two biplots, each two superimposed plots.

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

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


[R] Move R to a clean Linux install from an old install

2007-11-20 Thread Pekka Horttanainen
Hi everybody! I just joined, I started using R a few weeks ago and it
seems to be a really versatile system. Last weekend I
half-accidentally installed all R packages to my computer. Independent
of this (at least I hope), I managed to break my Kubuntu's KDE and so
far haven't been able to repair it even with the Kubuntu Forums' help
(I can start KDE as root but apparently this has broken my install
even further :(

However, I found several links that may allow me to save my GBs of
downloaded Linux programs so that at least I would't have to download
everything again (which is nice, since I don't have internet at home,
only at work) when I do a clean reinstall of my Kubuntu, like
http://aptoncd.sourceforge.net/.

So this solves the problem of software repositories. But what about R?
What is the best way to transfer my R packages (I guess the R itself
goes with the Ubuntu downloaded files and I thought R's packages are
separate, if I'm wrong the problem does not even exist!) to the new
install? Although the installation of the packages actually took
longer than downloading them, I still prefer not to download them
again, if that's possible (due to the lack of internet at home).

I apologize if this subject has been dealt with, I tried to search
internet and the mail list archives, but the closest thing I found
dealt with new R version install (although the solution to my problem
must be similar).

BR,

Pekka Horttanainen

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] as.character(seq(-.35,.95,.1))

2007-11-20 Thread jim holtman
see FAQ 7.31

On Nov 20, 2007 10:50 AM, Ken Fullish [EMAIL PROTECTED] wrote:

   as.character(seq(-.25,.95,.1))
  [1] -0.25 -0.15 -0.05 0.05  0.15  0.25  0.35  0.45
 0.55  0.65  0.75  0.85  0.95

   as.character(seq(-.35,.95,.1))
  [1] -0.35   -0.25
 -0.15   -0.0499 0.05
  [6] 0.150.25
 0.350.450.55
 [11] 0.650.75
 0.850.95

 Not a big deal, just curiosity:
 Why do I obtain this ugly -0.0499 instead of the
 expected -0.05 ?

 Regards
 K.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 you are trying to solve?

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


Re: [R] as.character(seq(-.35,.95,.1))

2007-11-20 Thread Duncan Murdoch
On 11/20/2007 10:50 AM, Ken Fullish wrote:
   as.character(seq(-.25,.95,.1))
   [1] -0.25 -0.15 -0.05 0.05  0.15  0.25  0.35  0.45   
 0.55  0.65  0.75  0.85  0.95
 
   as.character(seq(-.35,.95,.1))
   [1] -0.35   -0.25
 -0.15   -0.0499 0.05
   [6] 0.150.25 
 0.350.450.55
 [11] 0.650.75 
 0.850.95
 
 Not a big deal, just curiosity:
 Why do I obtain this ugly -0.0499 instead of the  
 expected -0.05 ?

Because as.character() tries to do an accurate conversion, and the 
number in your vector is closer to -0.0499 than to -0.05.
You could get the -0.05 by something like round( seq(...), 2).

The reason seq() doesn't give you exactly -0.05 is that the starting 
values and step size you've chosen are not exactly representable in R's 
floating point format.   It can only store fractions exactly when the 
denominator is a power of 2.

Duncan Murdoch

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


Re: [R] xy.coords and log10

2007-11-20 Thread Duncan Murdoch
On 11/20/2007 10:41 AM, Alexy Khrabrov wrote:
 Is there a way to teach xy.coords, when given log=xy, or just x  
 or y separately, to do a decimal log10 instead of the natural log?


xy.coords doesn't do any transformation other than setting non-positive 
values to NA.  So your question doesn't make sense; could you elaborate 
on what you're seeing that you don't want to see?

Duncan Murdoch

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


[R] as.character(seq(-.35,.95,.1))

2007-11-20 Thread Ken Fullish

  as.character(seq(-.25,.95,.1))
  [1] -0.25 -0.15 -0.05 0.05  0.15  0.25  0.35  0.45   
0.55  0.65  0.75  0.85  0.95

  as.character(seq(-.35,.95,.1))
  [1] -0.35   -0.25
-0.15   -0.0499 0.05
  [6] 0.150.25 
0.350.450.55
[11] 0.650.75 
0.850.95

Not a big deal, just curiosity:
Why do I obtain this ugly -0.0499 instead of the  
expected -0.05 ?

Regards
K.

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

2007-11-20 Thread Alexy Khrabrov
Is there a way to teach xy.coords, when given log=xy, or just x  
or y separately, to do a decimal log10 instead of the natural log?

Cheers,
Alexy

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


[R] intercept in multiple regression

2007-11-20 Thread Irene Mantzouni
Hi all!
 
Is it possible to model a multiple regression in which the response becomes 
zero when one of the two covariates is zero?  
lm(y~ x1+x2) and y=0 if x1=0. 
However, when x1=0, y=x2+1(intercept). 
Does this mean I cannot have a second covariate and intercept or should I 
eliminate only the intercept?
 
thank you!

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Use and misuse of update function for non-models. Any views/recommendations??

2007-11-20 Thread Søren Højsgaard
Thanks, Luke Tierney - the documentation of update was exactly what prompted my 
question. Yet, I conclude that writing an update.myobject method is OK.
Regards
Søren
 
 
 



Fra: Luke Tierney [mailto:[EMAIL PROTECTED]
Sendt: ti 20-11-2007 14:54
Til: Prof Brian Ripley
Cc: Søren Højsgaard; [EMAIL PROTECTED]
Emne: Re: [R] Use and misuse of update function for non-models. Any 
views/recommendations??



On Tue, 20 Nov 2007, Prof Brian Ripley wrote:

 update() is generic, so the recommended approach would be to write a method
 for your objects.

 Creating your own function update() in a package would probably not break too
 much, as namespaces would protect most functions using the generic in stats.
 But it could be very confusing to users.

Maybe.  update is generic with a netral set of argument names; on the
other hand, the _documentation_ of update is not generic -- it is
specific to updating models. So there is opportunity for confusion
from that direction.

Best,

luke


 On Tue, 20 Nov 2007, Søren Højsgaard wrote:

 Dear all,

 I wonder if it is bad style (or something worse) to create an update
 function which does not work on model objects of the lm, glm etc. type.
 Specifically, I have some graph objects (graphs as mathematical objects,
 not as displays) which I want to alter and for that purpose I thought of
 writing an update function. Would doing so violate a deeper philosophy in
 the R system or have other unfortunate consequences. If so, I'm happy to
 hear other suggestions...

 Regards
 Søren

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




--
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa  Phone: 319-335-3386
Department of Statistics andFax:   319-335-3017
Actuarial Science
241 Schaeffer Hall  email:  [EMAIL PROTECTED]
Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu 
http://www.stat.uiowa.edu/  

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


Re: [R] Friendly way to link R - MySQL and non-(R and Mysql) users ?

2007-11-20 Thread Gabor Grothendieck
Simplest would be to use the select.list() R command:

xnames - select.list(colnames(iris))

For a prettier and more functional approach the gWidgets package provides
a layer over a number of lower level packages for creating GUI front
ends in R.
http://wiener.math.csi.cuny.edu/pmg/gWidgets

Other R GUI projects are listed here:
http://www.sciviews.org/_rgui/

On Nov 20, 2007 10:12 AM, Ptit_Bleu [EMAIL PROTECTED] wrote:

 Thanks to your help, I managed to link R and a Mysql Database, send queries,
 plot the results and put everything in a pdf document (with Sweave).

 My co-workers find the job not bad but they would like to have a friendly
 interface to send queries and see the graphs (the pdf document is not
 necessary).
 Something like this coul be a good starting point :

 ---
 |  Name of the X columns : ___   |
 |  Name of the Y colums   : ___   |
 |  Send query Y/N   : ___   |
 ---

 I read some posts about this topic but all need a server (if I read well).
 I'd just want to use it on a local machine.
 Is there a way to realize such an interface and to link it directly to an
 R-script (which will send the query to MySQL and will plot the result of the
 query) ?

 Thanks for your help,
 Ptit Bleu.

 --
 View this message in context: 
 http://www.nabble.com/Friendly-way-to--link-R---MySQL-and-non-%28R-and-Mysql%29-users---tf4844081.html#a13858847
 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] Trying to get around R

2007-11-20 Thread Loren Engrav
Good morning and thank you

One correction please

I was not the poster
I am [EMAIL PROTECTED]
Poster was Epselon [EMAIL PROTECTED]

What you say is most certainly true. But then the newbie corrections might
have the style displayed by Mr. Bolker to both educate and further promote
participation.

Loren Engrav
Univ Wash
Seattle


 From: ecatchpole [EMAIL PROTECTED]
 Date: Tue, 20 Nov 2007 17:07:23 +1100
 To: Loren Engrav [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Subject: Re: [R] Trying to get around R
 
 Loren,
 
 There's a good reason for replying to the list, rather than just to you
 personally: to let other readers of the list see the response, so that
 they don't duplicate it. Your original posting certainly looked like
 homework questions to me. This impression was reinforced by the fact
 that the posting was anonymous: this is surely a breach of general
 netiquette, rather than an R newbie error?
 
 Students do attempt to get people on this list to do their homework for
 them. It is important, for the integrity of their degrees, that we
 minimise the occurrence of this. Regular contributors to this list (and
 I am not one) perform a huge public service. we should all be grateful
 for this.
 
 Ted Catchpole.
 
  Visiting Fellow
  Univ of New South Wales at ADFA, Canberra, Australia
 _   and University of Kent, Canterbury, England
'v'   - www.pems.adfa.edu.au/~ecatchpole
   /   \   - fax: +61 2 6268 8786  
m m- ph:  +61 2 6268 8895
 
 
 
 
 Loren Engrav wrote on 11/20/2007 04:43 PM:
 I am a newbie to R and Bio emails and
 
 It is clear that newbies make mistakes, I made several which were pointed
 out and I am trying to fix them, and as I fix one I make another, in time
 perhaps I will know it all, but if it is like surgery, I will make
 mistakes until I retire
 
 But the response of the old-timers to these mistakes seems arrogant and
 cruel and off putting and does NOT encourage more participation. In fact
 it takes real stuff to continue after this putdown and that putdown.
 
 There are 3,783 links to posting guidelines, which took 1.5 hours to find
 and read and understand.
 
 Why not a link on how the mistakes of the newbies will be dealt with?
 
 Or a kindly response from the moderator personal to the newbie rather than
 to the entire world?
 
 Or a kindly general response as from Ben Bolker to my last infraction which
 was You might have better luck with this on the Bioconductor mailing list
 ...
 
 Rather than to the universe...
 Using the wrong list: this is for R-sig-mac, and the topic occcurred
 there recently.
 
 All in an effort to encourage promote useful and increasing exchange
 participation
 
 Or not
 
 Loren Engrav, MD
 Univ Washington
 
 
   
 From: Julian Burgos [EMAIL PROTECTED]
 Date: Mon, 19 Nov 2007 10:44:49 -0800
 To: Epselon [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Subject: Re: [R] Trying to get around R
 
 Hello Epselon (if that is your name),
 
 
 This sounds like homework questions.
   
 From the R-help posting guide:
 
 Basic statistics and classroom homework:
   
 R-help is not intended for
 
 these.
 
 If you have a specific question on R
   
 coding, do ask it (and provide
 
 reproducible code).  But you should not expect
   
 for people on the list to
 
 do your homework for you.  That is a big
   
 no-no.
 
 
 Cheers,
 
 Julian
 
 
   
 Epselon wrote:
   
 I have three problems I am trying to
 
 simulate, that I am having difficulty
   
 getting around with.
 
 Problem 1.
 
 I want to determine the 85 percentile (the x value for which the sum of
 
 
 probabilities becomes 0.85) of the following distributions (two binomials
   
 and a Poisson with rate Lmbda= np of the two binomials): X ~B(10, 0.3),
   
 Y~P(3) , 
   
 Z~B(30, 0.1). I want to show that  that Y is a good approximation
 
 for Z but
   
 not for X...(by examining these distributions for few
 different
 
 percentiles)
   
 Problem 2:
 For a binomial distribution X ~ B(20, 0.4), I
 
 want to use R to calculate
   
 P{|X - μ|  2} and verify that it is near or
 
 larger than 0.95. (Hint from
   
 the text book: Since μ = 8 and   2.3 then
 
 you 
 may want to read the
   
 weights, or probabilities, of the values 6:10, into a
 
 vector v and then use
   
 the command sum(v) to
 calculate the sum.) Repeat
 
 this for another set of parameters of your
   
 choice.
 
 Problem 3:
 Draw a
 
 sample of size 10, from a Poisson with Lambda= 5, and calculate the
   
 mean
 
 and 
 the standard deviation of this sample, Repeat this calculation with
   
 size 20
 
 and 30 and demonstrate
   
 that ¯X gets closer to μ as the sample size
 
 increases.
   
 Thanks.
 
 I would appreciate it if someone accompanied the
 
 codes with a brief
   
 explanation so I can be able to replicate it
 
 myself.
   
 
 

Re: [R] Canonical Correlation Analysis

2007-11-20 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Animesh Acharjee
 Sent: Tuesday, November 20, 2007 7:47 AM
 To: [EMAIL PROTECTED]
 Subject: [R] Canonical Correlation Analysis
 
 Dear Sir/Madam,
  This is Animesh working on Canonical
 Correlation Analysis ( CCA ) and I am using CCA package in R. 
 I have a doubt
 and it may be very basic question. Hope someone will  get 
 back to me with
 answer. I am trying to follow the documentation of CCA but 
 could not make
 out some of the stuffs.
 
 1) I simulated some of the data sets and got the result. I 
 want to ask you
 why there are two circles in the plots? and what does it 
 mean? And also how
 it decidces the center of the Circle.
 2) X and Y axis values in between 1 and -1 . Is it due to max 
 and min values
 of correlation .
 3) what is the dimensions means in X and Y axis?
 
 It will be very useful if someone help me out with probable solution.
 
 Thanks for your time
 
 Animesh
 

Animesh,

In order to get useful help, you should post the code you used to simulate your 
data, run the CCA, and create the plot, so we can see what you are seeing (as 
the posting guide suggests).

Dan

Daniel J. Nordlund
Research and Data Analysis
Washington State Department of Social and Health Services
Olympia, WA  98504-5204
 
 

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


Re: [R] adding an image to a plot

2007-11-20 Thread jombart
Selon Rajarshi Guha [EMAIL PROTECTED]:

 Hi, I'm writing code to generate a plot, in which I draw a series of
 rectangles. So my code is of the form

 plot.new()
 plot.window( ... )

 draw rectangle
 draw rectangle
 ...

 Is there a way for me to insert a PNG or PDF graphic at a specific
 position in the plot (ideally in  plot coordinates)? I realize that
 this might probably be better done in a separate image editor, but if
 it could be done programmatically that would be very handy

 Thanks,

Hi,

you can insert pixmaps at specified coordinates using s.logo in the ade4
package.

Regards,

Thibaut.

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

2007-11-20 Thread Animesh Acharjee
Dear Sir/Madam,
 This is Animesh working on Canonical
Correlation Analysis ( CCA ) and I am using CCA package in R. I have a doubt
and it may be very basic question. Hope someone will  get back to me with
answer. I am trying to follow the documentation of CCA but could not make
out some of the stuffs.

1) I simulated some of the data sets and got the result. I want to ask you
why there are two circles in the plots? and what does it mean? And also how
it decidces the center of the Circle.
2) X and Y axis values in between 1 and -1 . Is it due to max and min values
of correlation .
3) what is the dimensions means in X and Y axis?

It will be very useful if someone help me out with probable solution.

Thanks for your time

Animesh

[[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] print character

2007-11-20 Thread Luis Ridao Cruz
R-help,

Sorry if this question has been discussed/posted before
but I can't just find it myself.

How can I print the comment character () ?


Thanks in advance

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Use and misuse of update function for non-models. Any views/recommendations??

2007-11-20 Thread Gabor Grothendieck
update already has formula and packageStatus methods so its
being extended beyond models already even within core packages.

On Nov 20, 2007 8:54 AM, Luke Tierney [EMAIL PROTECTED] wrote:
 On Tue, 20 Nov 2007, Prof Brian Ripley wrote:

  update() is generic, so the recommended approach would be to write a method
  for your objects.
 
  Creating your own function update() in a package would probably not break 
  too
  much, as namespaces would protect most functions using the generic in stats.
  But it could be very confusing to users.

 Maybe.  update is generic with a netral set of argument names; on the
 other hand, the _documentation_ of update is not generic -- it is
 specific to updating models. So there is opportunity for confusion
 from that direction.

 Best,

 luke


 
  On Tue, 20 Nov 2007, Søren Højsgaard wrote:
 
  Dear all,
 
  I wonder if it is bad style (or something worse) to create an update
  function which does not work on model objects of the lm, glm etc. type.
  Specifically, I have some graph objects (graphs as mathematical objects,
  not as displays) which I want to alter and for that purpose I thought of
  writing an update function. Would doing so violate a deeper philosophy in
  the R system or have other unfortunate consequences. If so, I'm happy to
  hear other suggestions...
 
  Regards
  Søren
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 

 --
 Luke Tierney
 Chair, Statistics and Actuarial Science
 Ralph E. Wareham Professor of Mathematical Sciences
 University of Iowa  Phone: 319-335-3386
 Department of Statistics andFax:   319-335-3017
Actuarial Science
 241 Schaeffer Hall  email:  [EMAIL PROTECTED]
 Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.



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

2007-11-20 Thread Alexy Khrabrov
xy.coords can have a log=xy parameter which then plot interprets to  
use log scale.
I wonder whether plot can be instructed in a similar way to use log10  
scale instead of natural logs.

Cheers,
Alexy

On Nov 20, 2007, at 7:01 PM, Duncan Murdoch wrote:

 On 11/20/2007 10:41 AM, Alexy Khrabrov wrote:
 Is there a way to teach xy.coords, when given log=xy, or just  
 x  or y separately, to do a decimal log10 instead of the  
 natural log?

 xy.coords doesn't do any transformation other than setting non- 
 positive values to NA.  So your question doesn't make sense; could  
 you elaborate on what you're seeing that you don't want to see?

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

2007-11-20 Thread Martin Maechler
 LRC == Luis Ridao Cruz [EMAIL PROTECTED]
 on Tue, 20 Nov 2007 15:57:07 + writes:

LRC R-help,
LRC Sorry if this question has been discussed/posted before
LRC but I can't just find it myself.

LRC How can I print the comment character () ?

Note that  '  '  is *not* the comment character  (but '#' is)

What does 'print' mean ?  Maybe

  cat('My name is Luis, what\'s your name? \n')
 My name is Luis, what's your name? 

or equivalently

  cat(My name is \Luis\, what's your name? \n)
 My name is Luis, what's your name? 

Pay close attention to both single and double quotes
used above and to the use of '\' as escape character.

Note that 'character' (a vector of strings) is the basic type
R uses here.  Also see

 ?character
 ?Quotes

and the 'see also's inside them.

Martin Maechler, ETH Zurich

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] as.character(seq(-.35,.95,.1))

2007-11-20 Thread Marc Schwartz

On Tue, 2007-11-20 at 11:07 -0500, Duncan Murdoch wrote:
 On 11/20/2007 10:50 AM, Ken Fullish wrote:
as.character(seq(-.25,.95,.1))
[1] -0.25 -0.15 -0.05 0.05  0.15  0.25  0.35  0.45   
  0.55  0.65  0.75  0.85  0.95
  
as.character(seq(-.35,.95,.1))
[1] -0.35   -0.25
  -0.15   -0.0499 0.05
[6] 0.150.25 
  0.350.450.55
  [11] 0.650.75 
  0.850.95
  
  Not a big deal, just curiosity:
  Why do I obtain this ugly -0.0499 instead of the  
  expected -0.05 ?
 
 Because as.character() tries to do an accurate conversion, and the 
 number in your vector is closer to -0.0499 than to -0.05.
 You could get the -0.05 by something like round( seq(...), 2).
 
 The reason seq() doesn't give you exactly -0.05 is that the starting 
 values and step size you've chosen are not exactly representable in R's 
 floating point format.   It can only store fractions exactly when the 
 denominator is a power of 2.

In addition, if you want to take numeric values and format them for
output with a known number of fixed decimal places, use either ?formatC
or ?sprintf, the latter being generally preferred:

 sprintf(%.2f, seq(-.25,.95,.1))
 [1] -0.25 -0.15 -0.05 0.05  0.15  0.25  0.35  0.45 
 [9] 0.55  0.65  0.75  0.85  0.95 

 sprintf(%.2f, seq(-.35,.95,.1))
 [1] -0.35 -0.25 -0.15 -0.05 0.05  0.15  0.25  0.35 
 [9] 0.45  0.55  0.65  0.75  0.85  0.95 

HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 fonts on linux using GDD

2007-11-20 Thread michael watson (IAH-C)
Hi

Apologies for this question.

I have read the help for GDD and font mapping, and it tells me that the
config file, /usr/lib/R/library/GDD/fonts/basefont.mapping is
responsible for mapping fonts to the GDD library.

However:

 .GDD.font()
[1] /usr/X11R6/lib/X11/fonts/Type1/l048013t.afm
[2] /usr/X11R6/lib/X11/fonts/Type1/l048016t.afm
[3] /usr/X11R6/lib/X11/fonts/Type1/l048033t.afm
[4] /usr/X11R6/lib/X11/fonts/Type1/l048036t.afm
[5] NA

Those fonts aren't even mentioned in the basefont.mapping file, so how
exactly does the basefont.mapping file intervene?

I have this in basefont.mapping:

base.norm:/usr/share/fonts/default/TrueType/FreeSans.ttf
base.ital:/usr/share/fonts/default/TrueType/FreeSerifItalic.ttf
base.bold:/usr/share/fonts/default/TrueType/FreeSansBold.ttf
base.bita:/usr/share/fonts/default/TrueType/FreeSerifBoldItalic.ttf

I have the well rehearsed problem that my GDD plots do not display any
fonts.

My questions:

1) why are the defaults fonts, eg
/usr/X11R6/lib/X11/fonts/Type1/l048013t.afm, not in my basefont.mapping
file?
2) why do I not get a font displayed, despite the default font files
being present?
3) why when I edit basefont.mapping to point to some TrueType files does
this not affect anything?
4) how do I get my GDD images to display fonts?

Many thanks in advance for your help

Mick

The information contained in this message may be confide...{{dropped:14}}

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

2007-11-20 Thread pieterprovoost
Hello,

I'm trying to find out how I can move the y axis label of a horizontal barplot 
further away from the axis, in order to avoid overlap between the names (which 
I have rotated using las=1) and the label. I have been fiddling with the 
graphical parameters but nothing seems to work. Maybe a graphical 
representation of the graphical parameters would be helpful (cf the CSS box 
model).

Thanks!
Pieter

--
This message was sent on behalf of [EMAIL PROTECTED] at openSubscriber.com
http://www.opensubscriber.com/messages/[EMAIL PROTECTED]/topic.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] Use and misuse of update function for non-models. Any views/recommendations??

2007-11-20 Thread Gavin Simpson
On Tue, 2007-11-20 at 16:32 +0100, Søren Højsgaard wrote:
 Thanks, Luke Tierney - the documentation of update was exactly what
 prompted my question. Yet, I conclude that writing an update.myobject
 method is OK.

I think Luke's point was that whilst it would be OK if you wrote your
own method in as much as you wouldn't be breaking anything, you may
confuse people by having a method do one thing for one class of object
and something totally different for another class of object - this is
what I believe you are planning. Some may view this as not being OK.

Perhaps it would be better to choose a slightly different name, say
Update(), but that might be just as confusing! Or perhaps choose another
word that has the same meaning as update and one such candidate would be
amend().

Just a thought,

G

 Regards
 Søren
  
 
 
 
 
 
 Fra: Luke Tierney [mailto:[EMAIL PROTECTED]
 Sendt: ti 20-11-2007 14:54
 Til: Prof Brian Ripley
 Cc: Søren Højsgaard; [EMAIL PROTECTED]
 Emne: Re: [R] Use and misuse of update function for non-models. Any 
 views/recommendations??
 
 
 
 On Tue, 20 Nov 2007, Prof Brian Ripley wrote:
 
  update() is generic, so the recommended approach would be to write a method
  for your objects.
 
  Creating your own function update() in a package would probably not break 
  too
  much, as namespaces would protect most functions using the generic in stats.
  But it could be very confusing to users.
 
 Maybe.  update is generic with a netral set of argument names; on the
 other hand, the _documentation_ of update is not generic -- it is
 specific to updating models. So there is opportunity for confusion
 from that direction.
 
 Best,
 
 luke
 
 
  On Tue, 20 Nov 2007, Søren Højsgaard wrote:
 
  Dear all,
 
  I wonder if it is bad style (or something worse) to create an update
  function which does not work on model objects of the lm, glm etc. type.
  Specifically, I have some graph objects (graphs as mathematical objects,
  not as displays) which I want to alter and for that purpose I thought of
  writing an update function. Would doing so violate a deeper philosophy in
  the R system or have other unfortunate consequences. If so, I'm happy to
  hear other suggestions...
 
  Regards
  Søren
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 
 
 
 --
 Luke Tierney
 Chair, Statistics and Actuarial Science
 Ralph E. Wareham Professor of Mathematical Sciences
 University of Iowa  Phone: 319-335-3386
 Department of Statistics andFax:   319-335-3017
 Actuarial Science
 241 Schaeffer Hall  email:  [EMAIL PROTECTED]
 Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu 
 http://www.stat.uiowa.edu/  
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 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.


Re: [R] xy.coords and log10

2007-11-20 Thread ONKELINX, Thierry

Have a look at scale_x_log10() and scale_y_log10() from the ggplot2
package. The helpfile with some examples is at
http://had.co.nz/ggplot2/scale_continuous.html

HTH,

Thierry 




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

Do not put your faith in what statistics say until you have carefully
considered what they do not say.  ~William W. Watt
A statistical analysis, properly conducted, is a delicate dissection of
uncertainties, a surgery of suppositions. ~M.J.Moroney

-Oorspronkelijk bericht-
Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Namens Alexy Khrabrov
Verzonden: dinsdag 20 november 2007 17:23
Aan: Duncan Murdoch
CC: r-help@r-project.org
Onderwerp: Re: [R] xy.coords and log10

xy.coords can have a log=xy parameter which then plot interprets to
use log scale.
I wonder whether plot can be instructed in a similar way to use log10
scale instead of natural logs.

Cheers,
Alexy

On Nov 20, 2007, at 7:01 PM, Duncan Murdoch wrote:

 On 11/20/2007 10:41 AM, Alexy Khrabrov wrote:
 Is there a way to teach xy.coords, when given log=xy, or just x 
 or y separately, to do a decimal log10 instead of the natural log?

 xy.coords doesn't do any transformation other than setting non- 
 positive values to NA.  So your question doesn't make sense; could you

 elaborate on what you're seeing that you don't want to see?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] try FlexMix RE: mulitmodal distributions

2007-11-20 Thread Karen.Green
Hi, Marion,
 
I believe the package FlexMix provides a more generalized version of
finite mixture modeling than is found in mclust/mclust02.
Please see:
http://cran.r-project.org/doc/vignettes/flexmix/flexmix-intro.pdf
 
Karen
---

 Karen M. Green, Ph.D.

 [EMAIL PROTECTED]

 Research Investigator

 Drug Design Group

 Sanofi Aventis Pharmaceuticals

 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On
Behalf Of Marion Wittmann
Sent: Monday, November 19, 2007 2:57 PM
To: r-help@r-project.org
Subject: [R] mulitmodal distributions
 
Hello, 
 
I see that mclust is a pacakge that handles fitting mixtures of
normals.
Are there any other packages out that that can handle mixtures of gammas
or
other exponentials? 
 
Additionally, are there any packages out there that can fit bimodal
distributions without mixtures? i.e., Cobb et al. 1983 using moment
recursion relations? 
 
Thank you! 
 
mw
 
Marion Wittmann, Ph.D. candidate
Environmental Science  Management
University of California
Santa Barbara, CA  93106-5131 
Lab: (805) 893 5890
Mobile: (805) 448 8259
Email:  mailto:[EMAIL PROTECTED] [EMAIL PROTECTED]
Web:  http://www.bren.ucsb.edu/~mwittmann www.bren.ucsb.edu/~mwittmann

[[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] barplot problem

2007-11-20 Thread pieterprovoost
Here's an example of my problem:

modelledprofile -  c(7.072289e-01, 2.625354e-01, 2.932886e-02, 8.986474e-04, 
8.155270e-06, 2.537943e-08, 3.137954e-11, 1.729522e-14, 4.579875e-18, 
6.069698e-22, 4.100828e-26, 1.423359e-30, 1.272139e-35, 5.449925e-46, 
1.431925e-57, 1.629660e-70)
depthnames - 
c(0-0.5,0.5-1,1-1.5,1.5-2,2-2.5,2.5-3,3-3.5,3.5-4,4-4.5,4.5-5,5-5.5,5.5-6,6-7,7-8,8-9,9-10)
par(omi=c(0,0.5,0,0))
barplot(rev(modelledprofile),horiz=TRUE,xlim=c(0,1),col=cornflowerblue,names.arg=rev(depthnames),las=1,ylab=depth)

Thanks

--
This message was sent on behalf of [EMAIL PROTECTED] at openSubscriber.com
http://www.opensubscriber.com/message/r-help@r-project.org/8030546.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] Use and misuse of update function for non-models. Any views/recommendations??

2007-11-20 Thread Douglas Bates
On Nov 20, 2007 10:29 AM, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 update already has formula and packageStatus methods so its
 being extended beyond models already even within core packages.

Also, update methods are extensively used for the other kind of
graphs in the lattice package.  Deepayan encourages users to think of
storing and updating lattice objects.

 On Nov 20, 2007 8:54 AM, Luke Tierney [EMAIL PROTECTED] wrote:
  On Tue, 20 Nov 2007, Prof Brian Ripley wrote:
 
   update() is generic, so the recommended approach would be to write a 
   method
   for your objects.
  
   Creating your own function update() in a package would probably not break 
   too
   much, as namespaces would protect most functions using the generic in 
   stats.
   But it could be very confusing to users.
 
  Maybe.  update is generic with a netral set of argument names; on the
  other hand, the _documentation_ of update is not generic -- it is
  specific to updating models. So there is opportunity for confusion
  from that direction.
 
  Best,
 
  luke
 
 
  
   On Tue, 20 Nov 2007, Søren Højsgaard wrote:
  
   Dear all,
  
   I wonder if it is bad style (or something worse) to create an update
   function which does not work on model objects of the lm, glm etc. type.
   Specifically, I have some graph objects (graphs as mathematical objects,
   not as displays) which I want to alter and for that purpose I thought of
   writing an update function. Would doing so violate a deeper philosophy 
   in
   the R system or have other unfortunate consequences. If so, I'm happy to
   hear other suggestions...
  
   Regards
   Søren
  
   __
   R-help@r-project.org mailing list
   https://stat.ethz.ch/mailman/listinfo/r-help
   PLEASE do read the posting guide
   http://www.R-project.org/posting-guide.html
   and provide commented, minimal, self-contained, reproducible code.
  
  
  
 
  --
  Luke Tierney
  Chair, Statistics and Actuarial Science
  Ralph E. Wareham Professor of Mathematical Sciences
  University of Iowa  Phone: 319-335-3386
  Department of Statistics andFax:   319-335-3017
 Actuarial Science
  241 Schaeffer Hall  email:  [EMAIL PROTECTED]
  Iowa City, IA 52242 WWW:  http://www.stat.uiowa.edu
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 
 

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

2007-11-20 Thread Julian Burgos
Hi Loren,

It wasn't my intention to sound arrogant, cruel or off putting.
English is not my first language, and perhaps my message had a tone I
did not intended.  The person posting the message I responded was
literally asking for somebody on the list to do his/hers homework (there
are even references to hints from the textbook).  This is not only
academically non-kosher, is also not the purpose of the R-help list.  I
pointed this to this person and invited him/her to come back with
specific questions on R coding.

The posting guidelines are easily accessible.  The first line in the
Mailing Lists section of the R website
(http://www.r-project.org/mail.html) states Please read the
instructions below and the posting guide before sending anything to any
mailing list!, and displays a link to the guide.  There also a link to
the guide at the bottom of every message send through this list.  The
posting guide is not hard to find, and (in my opinion) it isn't long or
difficult to understand (in particular for anyone taking college level
statistics).

Julian

Loren Engrav wrote:
 I am a newbie to R and Bio emails and
 
 It is clear that newbies make mistakes, I made several which were pointed
 out and I am trying to fix them, and as I fix one I make another, in time
 perhaps I will know it all, but if it is like surgery, I will make
 mistakes until I retire
 
 But the response of the old-timers to these mistakes seems arrogant and
 cruel and off putting and does NOT encourage more participation. In fact
 it takes real stuff to continue after this putdown and that putdown.
 
 There are 3,783 links to posting guidelines, which took 1.5 hours to find
 and read and understand.
 
 Why not a link on how the mistakes of the newbies will be dealt with?
 
 Or a kindly response from the moderator personal to the newbie rather than
 to the entire world?
 
 Or a kindly general response as from Ben Bolker to my last infraction which
 was You might have better luck with this on the Bioconductor mailing list
 ...
 
 Rather than to the universe...
 Using the wrong list: this is for R-sig-mac, and the topic occcurred
 there recently.
 
 All in an effort to encourage promote useful and increasing exchange
 participation
 
 Or not
 
 Loren Engrav, MD
 Univ Washington
 
 
 From: Julian Burgos [EMAIL PROTECTED]
 Date: Mon, 19 Nov 2007 10:44:49 -0800
 To: Epselon [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Subject: Re: [R] Trying to get around R

 Hello Epselon (if that is your name),
 
 This sounds like homework questions.
 From the R-help posting guide: 
 Basic statistics and classroom homework:
 R-help is not intended for 
 these.
 
 If you have a specific question on R
 coding, do ask it (and provide 
 reproducible code).  But you should not expect
 for people on the list to 
 do your homework for you.  That is a big
 no-no.
 
 Cheers,
 
 Julian
 
 
 Epselon wrote:
 I have three problems I am trying to
 simulate, that I am having difficulty
 getting around with.

 Problem 1.
 I want to determine the 85 percentile (the x value for which the sum of

 probabilities becomes 0.85) of the following distributions (two binomials
 and a Poisson with rate Lmbda= np of the two binomials): X ~B(10, 0.3),
 Y~P(3) , 
 Z~B(30, 0.1). I want to show that  that Y is a good approximation
 for Z but
 not for X...(by examining these distributions for few
 different
 percentiles)
 Problem 2:
 For a binomial distribution X ~ B(20, 0.4), I
 want to use R to calculate
 P{|X - μ|  2} and verify that it is near or
 larger than 0.95. (Hint from
 the text book: Since μ = 8 and   2.3 then
 you 
 may want to read the
 weights, or probabilities, of the values 6:10, into a
 vector v and then use
 the command sum(v) to
 calculate the sum.) Repeat
 this for another set of parameters of your
 choice.

 Problem 3:
 Draw a
 sample of size 10, from a Poisson with Lambda= 5, and calculate the
 mean
 and 
 the standard deviation of this sample, Repeat this calculation with
 size 20
 and 30 and demonstrate
 that ¯X gets closer to μ as the sample size
 increases.
 Thanks.

 I would appreciate it if someone accompanied the
 codes with a brief
 explanation so I can be able to replicate it
 myself.
 
 __
 R-help@r-project.org
 mailing list
 https://stat.ethz.ch/mailman/listinfo/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, 

Re: [R] R and reading matlab compressed files

2007-11-20 Thread John C Frain
According to the Octave manual (page 146 of Edition 3 for Octave
version 2.9.16) Octave can read Matlab version 7 files.  It can also
output with similar options to Matlab.  As there are no issues or
licencing problems when running Octave and R on the one machine.  Note
that there is a new native Windows version of Octave now available
that does not require cygwin.

Best Reards

John

On 17/11/2007, Prof Leslie Smith [EMAIL PROTECTED] wrote:
 Is there any way to read these files (standard .mat files, created by
 matlab version 7 onwards are compressed)? I know that R.matlab doesn't
 read them (it even says in the file MatlabServer.m Matlab v7 saves
 compressed files, which is not recognized by R.matlab's readMat() (lines
 47-8)).

 I know I should be able to make R call Matlab and transfer data (not that
 I managed to make it work yet!), but I'd rather not run Matlab  R
 together: I'd like to use R to read matlab files on machines not licensed
 for matlab!

 Are there any ways to make this work?

 --Leslie Smith

 --
 Prof Leslie Smith
 Computing Science and Maths
 University of Stirling FK9 4LA
 Scotland
 Tel (44) 1786 467435

 --
 The University of Stirling is a university established i...{{dropped:11}}

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



-- 
John C Frain
Trinity College Dublin
Dublin 2
Ireland
www.tcd.ie/Economics/staff/frainj/home.html
mailto:[EMAIL PROTECTED]
mailto:[EMAIL PROTECTED]

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


Re: [R] Process multiple columns of data.frame

2007-11-20 Thread jim holtman
It really depends on what you want to set the values that contain NAs
to for the various type of the columns.  Do you always want numerics
=0, characters =, and factors =whatever?  Do you want to do this for
all the columns in a dataframe?  If you want to it for all the columns
in a matrix, it is easy, since all are the same type, and you are
setting them to zero (e.g., yourMatrix[is.na(yourMatrix)] - 0).

You can always write a function that can take in the names of the
columns and then depending on their types set the corresponding
values.  So it depends on what you mean by concisely and how often
you want to do it.

On Nov 20, 2007 12:27 PM, Thompson, David (MNR)
[EMAIL PROTECTED] wrote:
 Hello,

 How do I do the following more concisely?
Bout[is.na(Bout$bd.n), 'bd.n'] - 0
Bout[is.na(Bout$ht.n), 'ht.n'] - 0
Bout[is.na(Bout$dbh.n), 'dbh.n'] - 0

 Would the form of such a command be different
 between numeric, character and factor columns?

 . . . between data.frames and matrices?

 Thanx, DaveT.
 *
 Silviculture Data Analyst
 Ontario Forest Research Institute
 Ontario Ministry of Natural Resources
 [EMAIL PROTECTED]
 http://ofri.mnr.gov.on.ca

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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 you are trying to solve?

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


Re: [R] Adding points on top of lines in xyplot

2007-11-20 Thread Dylan Beaudette
On Tuesday 20 November 2007, Deepayan Sarkar wrote:
 On Nov 20, 2007 11:14 AM, David Afshartous [EMAIL PROTECTED] 
wrote:
  All,
 
  I'm trying to make a basic plot: data points superimposed upon the a line
  connecting the points w/ a different color.  Example below doesn't work
  as the first xyplot call doesn't remain.  Suggestions?

 xyplot(y ~ Hour, type = 'b', lwd = 2, pch= 16, col.symbol =  red, cex=3)

 or for finer control

 xyplot(y ~ Hour,
panel = function(x, y, ...) {
panel.lines(x, y, lwd = 2)
panel.points(x, y, pch = 16, cex = 3, col = red)
})

 -Deepayan


Deepayan,

is there any way to do something similar, but when the data used to plot the 
lines and the points come from different dataframes and a grouping variable 
is used?

thanks,

Dylan

  David
 
 
  Hour = c(NA,1,2,3,4)
  y = c(2,2,3,2,1.5)
 
  xyplot(y ~ Hour, xlab = list(Hour, font=2, cex=2), ylab= list(U_x *
  V, font=2, cex=2), type = 'l', scales = list( x= list(tick.number=5,
  cex=2, limits=c(0,4.5)), y=list(cex=0)), lines=TRUE, lwd = 2 , add=TRUE  
   )
 
 
  xyplot(y ~ Hour, xlab= , ylab=, pch= 16, col=  red, cex=3 , xlim =
  c(0, 4.5), add=TRUE)

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



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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


Re: [R] Adding points on top of lines in xyplot

2007-11-20 Thread Deepayan Sarkar
On Nov 20, 2007 11:14 AM, David Afshartous [EMAIL PROTECTED] wrote:

 All,

 I'm trying to make a basic plot: data points superimposed upon the a line
 connecting the points w/ a different color.  Example below doesn't work as
 the first xyplot call doesn't remain.  Suggestions?

xyplot(y ~ Hour, type = 'b', lwd = 2, pch= 16, col.symbol =  red, cex=3)

or for finer control

xyplot(y ~ Hour,
   panel = function(x, y, ...) {
   panel.lines(x, y, lwd = 2)
   panel.points(x, y, pch = 16, cex = 3, col = red)
   })

-Deepayan


 David


 Hour = c(NA,1,2,3,4)
 y = c(2,2,3,2,1.5)

 xyplot(y ~ Hour, xlab = list(Hour, font=2, cex=2), ylab= list(U_x * V,
 font=2, cex=2), type = 'l', scales = list( x= list(tick.number=5, cex=2,
 limits=c(0,4.5)), y=list(cex=0)), lines=TRUE, lwd = 2 , add=TRUE)


 xyplot(y ~ Hour, xlab= , ylab=, pch= 16, col=  red, cex=3 , xlim =
 c(0, 4.5), add=TRUE)

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


Re: [R] Adding points on top of lines in xyplot

2007-11-20 Thread Deepayan Sarkar
On 11/20/07, Dylan Beaudette [EMAIL PROTECTED] wrote:
 On Tuesday 20 November 2007, Deepayan Sarkar wrote:
  On Nov 20, 2007 11:14 AM, David Afshartous [EMAIL PROTECTED]
 wrote:
   All,
  
   I'm trying to make a basic plot: data points superimposed upon the a line
   connecting the points w/ a different color.  Example below doesn't work
   as the first xyplot call doesn't remain.  Suggestions?
 
  xyplot(y ~ Hour, type = 'b', lwd = 2, pch= 16, col.symbol =  red, cex=3)
 
  or for finer control
 
  xyplot(y ~ Hour,
 panel = function(x, y, ...) {
 panel.lines(x, y, lwd = 2)
 panel.points(x, y, pch = 16, cex = 3, col = red)
 })
 
  -Deepayan
 

 Deepayan,

 is there any way to do something similar, but when the data used to plot the
 lines and the points come from different dataframes and a grouping variable
 is used?

There's a way to do almost everything, but we need a reproducible
example (preferably minimal) and a clear statement of what you want to
do to help.

-Deepayan

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


Re: [R] Adding points on top of lines in xyplot

2007-11-20 Thread Rolf Turner

On 21/11/2007, at 8:40 AM, Deepayan Sarkar wrote:

 There's a way to do almost everything, but we need a reproducible
 example (preferably minimal) and a clear statement of what you want to
 do to help.

Is this a candidate for fortune() ?

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.


[R] asymptote

2007-11-20 Thread Alexy Khrabrov
I have a graph which looks like hyperbole.  I'd like to fit a  
straight line to the lower segment going to infinity, approaching the  
X axis -- I'm interested in the angle.  If I'd do it manually, I'd  
cut off a certain initial part of the range, [0..x_min], and then do  
an lm with the rest.  Yet I wonder whether those curve fitting  
packages mentioned earlier do something similar automatically?

Cheers,
Alexy

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


[R] Loc function in R??

2007-11-20 Thread Barb, Jennifer (NIH/CIT) [E]
Does anyone know which function (if any) will return the index of the
true locations in a Boolean vector?

 

For instance:

A=c(1,3,5,7,4);

B=c(2,4,77,3,3);

X=AB;

 

So X is:

 X

[1]  TRUE  TRUE  TRUE FALSE FALSE

 

I'd like to know if there is a function that will tell me the locations
of where the TRUE values are?  for instance a vector that will list that
the locations are at 1, 2, 3.  This function is sometimes called loc()
in other languages.

 

Thanks,

Jennifer

 


 

 

 


[[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] Adding points on top of lines in xyplot

2007-11-20 Thread Dylan Beaudette
On Tuesday 20 November 2007, Deepayan Sarkar wrote:
 On 11/20/07, Dylan Beaudette [EMAIL PROTECTED] wrote:
  On Tuesday 20 November 2007, Deepayan Sarkar wrote:
   On Nov 20, 2007 11:14 AM, David Afshartous [EMAIL PROTECTED]
 
  wrote:
All,
   
I'm trying to make a basic plot: data points superimposed upon the a
line connecting the points w/ a different color.  Example below
doesn't work as the first xyplot call doesn't remain.  Suggestions?
  
   xyplot(y ~ Hour, type = 'b', lwd = 2, pch= 16, col.symbol =  red,
   cex=3)
  
   or for finer control
  
   xyplot(y ~ Hour,
  panel = function(x, y, ...) {
  panel.lines(x, y, lwd = 2)
  panel.points(x, y, pch = 16, cex = 3, col = red)
  })
  
   -Deepayan
 
  Deepayan,
 
  is there any way to do something similar, but when the data used to plot
  the lines and the points come from different dataframes and a grouping
  variable is used?

 There's a way to do almost everything, but we need a reproducible
 example (preferably minimal) and a clear statement of what you want to
 do to help.

 -Deepayan


Of course! Sorry about that. 

Example:
library(lattice)

# generate some data:
resp - rnorm(100)
pred - resp*1.5 + rnorm(100)
d - data.frame(resp=resp, pred=pred)

# add a grouping factor:
d$grp - gl(4, 25, labels=letters[1:4])

# plot: looks ok!
main.plot - xyplot(resp ~ pred | grp, data=d, panel=function(x,y, ...) 
{panel.xyplot(x, y, ...) ; panel.lmline(x,y, ...) })

# however, we have some other information which needs to go in each panel
# note that the dimensions (i.e. no of obs) are not the same as the original 
# data, and the values are different, but on the same scale
resp.other - rnorm(20)
pred.other - resp.other*1.5 + rnorm(20)
d.other - data.frame(resp=resp.other, pred=pred.other)
d.other$grp - gl(4, 5, labels=letters[1:4])


The big question:
Now that we have the main plot (main.plot) looking ok, how can we add the data 
from d.other to the frames of main.plot without using subset() for each level 
of our grouping variable?


# after some messing around, how about this:
xyplot(resp ~ pred | grp, data=d, panel=function(x,y, ...)
{
panel.xyplot(x, y, ...) 
panel.lmline(x,y, ...) 
# now the other data:
panel.superpose(d.other$pred, d.other$resp, groups=d.other$grp, 
col=c('red', 'blue', 'green', 'orange')[as.numeric(d.other$grp)], pch=16, 
subscripts=TRUE)
}
)

#... hmm it doesn't look like the information from 'd.other' is being 
stratified into the panels setup in panel.xyplot() ... 

The main point to this rather contrived example is this : 

1. i have a data frame with continuous predictions, the response, and the 
grouping variable -- which plot nicely with the default use of xyplot()

2. I would like to embellish each panel with the original response and 
predictor values to illustrate the relationship between the original data and 
the smooth, fitted curve.

ideas?

thanks!

Dylan


-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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

2007-11-20 Thread Kuhn, Max
?which

 which(X)
[1] 1 2 3

Max 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Barb, Jennifer (NIH/CIT) [E]
Sent: Tuesday, November 20, 2007 3:07 PM
To: [EMAIL PROTECTED]
Subject: [R] Loc function in R??

Does anyone know which function (if any) will return the index of the
true locations in a Boolean vector?

 

For instance:

A=c(1,3,5,7,4);

B=c(2,4,77,3,3);

X=AB;

 

So X is:

 X

[1]  TRUE  TRUE  TRUE FALSE FALSE

 

I'd like to know if there is a function that will tell me the locations
of where the TRUE values are?  for instance a vector that will list that
the locations are at 1, 2, 3.  This function is sometimes called loc()
in other languages.

 

Thanks,

Jennifer

 


 

 

 


[[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] Loc function in R??

2007-11-20 Thread Rolf Turner
?which

On 21/11/2007, at 9:06 AM, Barb, Jennifer (NIH/CIT) [E] wrote:

 Does anyone know which function (if any) will return the index of the
 true locations in a Boolean vector?



 For instance:

 A=c(1,3,5,7,4);

 B=c(2,4,77,3,3);

 X=AB;



 So X is:

 X

 [1]  TRUE  TRUE  TRUE FALSE FALSE



 I'd like to know if there is a function that will tell me the  
 locations
 of where the TRUE values are?  for instance a vector that will list  
 that
 the locations are at 1, 2, 3.  This function is sometimes called loc()
 in other languages.


##
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] Loc function in R??

2007-11-20 Thread Benilton Carvalho
which(A  B)


On Nov 20, 2007, at 3:06 PM, Barb, Jennifer (NIH/CIT) [E] wrote:

 Does anyone know which function (if any) will return the index of the
 true locations in a Boolean vector?



 For instance:

 A=c(1,3,5,7,4);

 B=c(2,4,77,3,3);

 X=AB;



 So X is:

 X

 [1]  TRUE  TRUE  TRUE FALSE FALSE



 I'd like to know if there is a function that will tell me the locations
 of where the TRUE values are?  for instance a vector that will list 
 that
 the locations are at 1, 2, 3.  This function is sometimes called loc()
 in other languages.



 Thanks,

 Jennifer











   [[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] Loc function in R??

2007-11-20 Thread Dimitris Rizopoulos
try:

which(X)


Best,
Dimitris


Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/(0)16/336899
Fax: +32/(0)16/337015
Web: http://med.kuleuven.be/biostat/
  http://www.student.kuleuven.be/~m0390867/dimitris.htm


Quoting Barb, Jennifer (NIH/CIT) [E] [EMAIL PROTECTED]:

 Does anyone know which function (if any) will return the index of the
 true locations in a Boolean vector?



 For instance:

 A=c(1,3,5,7,4);

 B=c(2,4,77,3,3);

 X=AB;



 So X is:

 X

 [1]  TRUE  TRUE  TRUE FALSE FALSE



 I'd like to know if there is a function that will tell me the locations
 of where the TRUE values are?  for instance a vector that will list that
 the locations are at 1, 2, 3.  This function is sometimes called loc()
 in other languages.



 Thanks,

 Jennifer











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





Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm

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

2007-11-20 Thread David Scott


?which

On Tue, 20 Nov 2007, Barb, Jennifer (NIH/CIT) [E] wrote:

 Does anyone know which function (if any) will return the index of the
 true locations in a Boolean vector?



 For instance:

 A=c(1,3,5,7,4);

 B=c(2,4,77,3,3);

 X=AB;



 So X is:

 X

 [1]  TRUE  TRUE  TRUE FALSE FALSE



 I'd like to know if there is a function that will tell me the locations
 of where the TRUE values are?  for instance a vector that will list that
 the locations are at 1, 2, 3.  This function is sometimes called loc()
 in other languages.



 Thanks,

 Jennifer











   [[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, Tamaki Campus
The University of Auckland, PB 92019
Auckland 1142,NEW ZEALAND
Phone: +64 9 373 7599 ext 86830 Fax: +64 9 373 7000
Email:  [EMAIL PROTECTED]

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] Problem with code for bootstrapping chi square test with count data

2007-11-20 Thread Prof Brian Ripley
On Tue, 20 Nov 2007, Geertje Van der Heijden wrote:

 Hi,

 I'd like some advice on bootstrapping in R.

 I have a species x with 20 individuals and a factor containing 0 and 1's
 (in this case 5 zeros and 15 ones). I want to compare the frequency of
 the occurrence of 1 with a probability value. This code seems to work to
 do this in R.

 attach(test)
 p - c(0.5272, (1-0.5272))
 sp1_1 - length(subset(x, x==1))
 sp1_0 - length(subset(x, x==0))
 obs1_1 - c(sp1_1, sp1_0)
 chisq.test(obs1_1, p=p)

 However, I'd like to bootstrap these 20 individuals to produce a whole
 population of samples and I'd like to do a chi-square test for each of
 the bootstrap sample to create a distribution of the chi-square
 statistic.

And what do you want to do with that distribution?  It is 'a 
distribution', but it is not obviously connected with the test you say you 
want to do.  It seems to me that the real issue here is understanding the 
applicability of the bootstrap.

We can make your example reproducible by

x - c(rep(0,5), rep(1, 15))
N - sum(x) # 15
p - c(0.5272, (1-0.5272))
chisq.test(c(N, 20-N), p=p)

 I have bootstrapped the 0's and 1's of x 20 times using the following
 code:

 resamples - lapply(1:20, function(i) sample(x, replace=T))

 What I can't get to work is how to calculate the observed values for 1's
 and 0's in each of the bootstrap samples, which I need to do a
 chi-square test for each sample. The methd I used above doesn't seem to
 work the results for resamples. Does anyone have an idea on how to get
 this to work? Or is there another easier way to do this? I hope it is
 clear what I am trying to do!

You can make this easier by noticing that the number of ones will be 
binomial(20, 15/20).  So e.g.

res - replicate(1000, {N - rbinom(1, 20, 15/20);
 chisq.test(c(N, 20-N), p=p)$statistic})

Now what are you going to do with this?

It is not simulation under the null hypothesis, which would be

res - replicate(1000, {N - rbinom(1, 20, 0.5272);
 chisq.test(c(N, 20-N), p=p)$statistic})
mean(res  3.983)

and shows good agreement with the theoretical approximating distribution.

Also, why do you want a chisq test to do this?  We can use
binom.test(15, 20, 0.5272), which is exact.  (The only assumption it makes 
iid trials, which the bootstrap methods are also making.)

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

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


Re: [R] Adding points on top of lines in xyplot

2007-11-20 Thread Dylan Beaudette
On Tuesday 20 November 2007, Deepayan Sarkar wrote:
 On 11/20/07, Dylan Beaudette [EMAIL PROTECTED] wrote:

 [...]

  Example:
  library(lattice)
 
  # generate some data:
  resp - rnorm(100)
  pred - resp*1.5 + rnorm(100)
  d - data.frame(resp=resp, pred=pred)
 
  # add a grouping factor:
  d$grp - gl(4, 25, labels=letters[1:4])
 
  # plot: looks ok!
  main.plot - xyplot(resp ~ pred | grp, data=d, panel=function(x,y, ...)
  {panel.xyplot(x, y, ...) ; panel.lmline(x,y, ...) })
 
  # however, we have some other information which needs to go in each panel
  # note that the dimensions (i.e. no of obs) are not the same as the
  original # data, and the values are different, but on the same scale
  resp.other - rnorm(20)
  pred.other - resp.other*1.5 + rnorm(20)
  d.other - data.frame(resp=resp.other, pred=pred.other)
  d.other$grp - gl(4, 5, labels=letters[1:4])
 
 
  The big question:
  Now that we have the main plot (main.plot) looking ok, how can we add the
  data from d.other to the frames of main.plot without using subset() for
  each level of our grouping variable?

Hi,

 I would say you are asking the wrong question. The right question is:
 how do I manipulate my data so that it becomes easy to work with. Try

 combined - make.groups(d, d.other)

excellent! this makes complete sense...

 xyplot(resp ~ pred | grp, data=combined, groups = which,
panel = panel.superpose,
panel.groups = function(x,y, ...) {
panel.xyplot(x, y, ...)
panel.lmline(x,y, ...)
})

 Is that close to what you want? Does it extend to your real example?

 -Deepayan

This is close for the contrived example, but not quite what I need. I would 
like to plot the first 'group' of data as lines, and the second as points. I 
have tried specifying type=c('l', 'p') but this does not appear to work.

If I plot everything as point, the data plot correctly, but not in the symbols 
that I would like.

Cheers,

Dylan


  # after some messing around, how about this:
  xyplot(resp ~ pred | grp, data=d, panel=function(x,y, ...)
  {
  panel.xyplot(x, y, ...)
  panel.lmline(x,y, ...)
  # now the other data:
  panel.superpose(d.other$pred, d.other$resp, groups=d.other$grp,
  col=c('red', 'blue', 'green', 'orange')[as.numeric(d.other$grp)], pch=16,
  subscripts=TRUE)
  }
  )
 
  #... hmm it doesn't look like the information from 'd.other' is being
  stratified into the panels setup in panel.xyplot() ...
 
  The main point to this rather contrived example is this :
 
  1. i have a data frame with continuous predictions, the response, and the
  grouping variable -- which plot nicely with the default use of xyplot()
 
  2. I would like to embellish each panel with the original response and
  predictor values to illustrate the relationship between the original data
  and the smooth, fitted curve.
 
  ideas?
 
  thanks!
 
  Dylan
 
 
  --
  Dylan Beaudette
  Soil Resource Laboratory
  http://casoilresource.lawr.ucdavis.edu/
  University of California at Davis
  530.754.7341



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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


Re: [R] Adding points on top of lines in xyplot

2007-11-20 Thread Deepayan Sarkar
On 11/20/07, Dylan Beaudette [EMAIL PROTECTED] wrote:
 On Tuesday 20 November 2007, Deepayan Sarkar wrote:
  On 11/20/07, Dylan Beaudette [EMAIL PROTECTED] wrote:
 
  [...]
 
   Example:
   library(lattice)
  
   # generate some data:
   resp - rnorm(100)
   pred - resp*1.5 + rnorm(100)
   d - data.frame(resp=resp, pred=pred)
  
   # add a grouping factor:
   d$grp - gl(4, 25, labels=letters[1:4])
  
   # plot: looks ok!
   main.plot - xyplot(resp ~ pred | grp, data=d, panel=function(x,y, ...)
   {panel.xyplot(x, y, ...) ; panel.lmline(x,y, ...) })
  
   # however, we have some other information which needs to go in each panel
   # note that the dimensions (i.e. no of obs) are not the same as the
   original # data, and the values are different, but on the same scale
   resp.other - rnorm(20)
   pred.other - resp.other*1.5 + rnorm(20)
   d.other - data.frame(resp=resp.other, pred=pred.other)
   d.other$grp - gl(4, 5, labels=letters[1:4])
  
  
   The big question:
   Now that we have the main plot (main.plot) looking ok, how can we add the
   data from d.other to the frames of main.plot without using subset() for
   each level of our grouping variable?

 Hi,

  I would say you are asking the wrong question. The right question is:
  how do I manipulate my data so that it becomes easy to work with. Try
 
  combined - make.groups(d, d.other)

 excellent! this makes complete sense...

  xyplot(resp ~ pred | grp, data=combined, groups = which,
 panel = panel.superpose,
 panel.groups = function(x,y, ...) {
 panel.xyplot(x, y, ...)
 panel.lmline(x,y, ...)
 })
 
  Is that close to what you want? Does it extend to your real example?
 
  -Deepayan

 This is close for the contrived example, but not quite what I need. I would
 like to plot the first 'group' of data as lines, and the second as points. I
 have tried specifying type=c('l', 'p') but this does not appear to work.

Try adding 'distribute.type = TRUE' (see ?panel.superpose). My UseR!
2007 talk had some relevant examples, so you might find those slides
useful:

http://www.user2007.org/program/presentations/sarkar.pdf

-Deepayan

 If I plot everything as point, the data plot correctly, but not in the symbols
 that I would like.

 Cheers,

 Dylan


   # after some messing around, how about this:
   xyplot(resp ~ pred | grp, data=d, panel=function(x,y, ...)
   {
   panel.xyplot(x, y, ...)
   panel.lmline(x,y, ...)
   # now the other data:
   panel.superpose(d.other$pred, d.other$resp, groups=d.other$grp,
   col=c('red', 'blue', 'green', 'orange')[as.numeric(d.other$grp)], pch=16,
   subscripts=TRUE)
   }
   )
  
   #... hmm it doesn't look like the information from 'd.other' is being
   stratified into the panels setup in panel.xyplot() ...
  
   The main point to this rather contrived example is this :
  
   1. i have a data frame with continuous predictions, the response, and the
   grouping variable -- which plot nicely with the default use of xyplot()
  
   2. I would like to embellish each panel with the original response and
   predictor values to illustrate the relationship between the original data
   and the smooth, fitted curve.
  
   ideas?
  
   thanks!
  
   Dylan
  
  
   --
   Dylan Beaudette
   Soil Resource Laboratory
   http://casoilresource.lawr.ucdavis.edu/
   University of California at Davis
   530.754.7341



 --
 Dylan Beaudette
 Soil Resource Laboratory
 http://casoilresource.lawr.ucdavis.edu/
 University of California at Davis
 530.754.7341


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Process multiple columns of data.frame

2007-11-20 Thread Thompson, David (MNR)
I did specify only the three columns of interest
c('bd.n','ht.n','dbh.n')
as the second (column) index, and I did superficially check the results
which turned out as I had hoped. Only the three columns listed were
changed and existing values _in_ those columns were retained.
So, I appear to be on my way again.

Thanx again, DaveT.
*
-Original Message-
From: jim holtman [mailto:[EMAIL PROTECTED] 
Sent: November 20, 2007 04:21 PM
To: Thompson, David (MNR)
Cc: r-help@r-project.org
Subject: Re: [R] Process multiple columns of data.frame

The problem with that solution is that if any of the columns in a row
has an NA in it, then all the columns of that row will be set to zero.
 Is the what you want, or do you only want the specific entries set to
0?

On Nov 20, 2007 4:07 PM, Thompson, David (MNR)
[EMAIL PROTECTED] wrote:
 Jim,

 What I'm getting at is my lack of understanding when manipulating
 data frame indices. I have tried something like your matrix example
 with variants of: Bout[ 
is.na(Bout[,c('bd.n','ht.n','dbh.n')]), ] - 0

 only to receive the following error message:
 Error in `[-.data.frame`(`*tmp*`, is.na(Bout[, c(bd.n, ht.n,
 dbh.n)]),  :
non-existent rows not allowed

 My questions were not focussed on the assignment value but,
 on the selection of multiple columns (of a single type) to process.
 Which is what I meant by concisely.

 And, lo and behold, in my attempts to reframe my questions I 
(finally)
 came upon a solution:
 Bout[is.na(Bout$bd.n) | is.na(Bout$ht.n) | is.na(Bout$dbh.n),
 c('bd.n','ht.n','dbh.n')] - 0

 Thank you for your time, DaveT.
 *

 -Original Message-
 From: jim holtman [mailto:[EMAIL PROTECTED]
 Sent: November 20, 2007 02:25 PM
 To: Thompson, David (MNR)
 Cc: r-help@r-project.org
 Subject: Re: [R] Process multiple columns of data.frame
 
 It really depends on what you want to set the values that 
contain NAs
 to for the various type of the columns.  Do you always want numerics
 =0, characters =, and factors =whatever?  Do you want to 
do this for
 all the columns in a dataframe?  If you want to it for all 
the columns
 in a matrix, it is easy, since all are the same type, and you are
 setting them to zero (e.g., yourMatrix[is.na(yourMatrix)] - 0).
 
 You can always write a function that can take in the names of the
 columns and then depending on their types set the corresponding
 values.  So it depends on what you mean by concisely and how often
 you want to do it.
 
 On Nov 20, 2007 12:27 PM, Thompson, David (MNR)
 [EMAIL PROTECTED] wrote:
  Hello,
 
  How do I do the following more concisely?
 Bout[is.na(Bout$bd.n), 'bd.n'] - 0
 Bout[is.na(Bout$ht.n), 'ht.n'] - 0
 Bout[is.na(Bout$dbh.n), 'dbh.n'] - 0
 
  Would the form of such a command be different
  between numeric, character and factor columns?
 
  . . . between data.frames and matrices?
 
  Thanx, DaveT.
  *
  Silviculture Data Analyst
  Ontario Forest Research Institute
  Ontario Ministry of Natural Resources
  [EMAIL PROTECTED]
  http://ofri.mnr.gov.on.ca
 
  __
  R-help@r-project.org mailing list
  https://stat.ethz.ch/mailman/listinfo/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 you are trying to solve?
 




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

What is the problem you are trying to solve?


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


Re: [R] Problems with NA's

2007-11-20 Thread J. R. M. Hosking
Thomas L Jones, PhD wrote:
 Difficulty handling NA's:
 Assume that I have a numeric vector y. For simplicity, assume that it has 10 
 elements. Assume that the third element has the value NA. I give it the 
 following:
 NA_test - function (){
 y - numeric (10)
 y [3] - NA
 if (y [3] != NA){(print (no)}
 print (Leaving NA_test)
 return ()
 }# End of function
 
 -
 Unfortunately, things become confused involving the NA element.
 Here is the output, starting with the loading process:
 
 --
 NA_test - function (){
 + y - numeric (10)
 + y [3] - NA
 + if (y [3] != NA){(print (no)}
 Error: syntax error in:
 y [3] - NA
 if (y [3] != NA){(print (no)}
 print (Leaving NA_test)
 [1] Leaving NA_test
 return ()
 Error: no function to return from, jumping to top level
 }# End of function
 Error: syntax error in }
 -
 I have enclosed the print operation in braces to avoid possible problems 
 with it.
 
 Your advice?
 
 Tom Jones

What Messrs. Schwartz and Olshansky told you is valid, but will not cure 
syntax errors.  My advice is to check the matching of parentheses in the 
line

  if (y [3] != NA){(print (no)}



J. R. M. Hosking

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


Re: [R] Adding points on top of lines in xyplot [solved]

2007-11-20 Thread Dylan Beaudette
On Tuesday 20 November 2007, Deepayan Sarkar wrote:
 On 11/20/07, Dylan Beaudette [EMAIL PROTECTED] wrote:
  On Tuesday 20 November 2007, Deepayan Sarkar wrote:
   On 11/20/07, Dylan Beaudette [EMAIL PROTECTED] wrote:
  
   [...]
  
Example:
library(lattice)
   
# generate some data:
resp - rnorm(100)
pred - resp*1.5 + rnorm(100)
d - data.frame(resp=resp, pred=pred)
   
# add a grouping factor:
d$grp - gl(4, 25, labels=letters[1:4])
   
# plot: looks ok!
main.plot - xyplot(resp ~ pred | grp, data=d, panel=function(x,y,
...) {panel.xyplot(x, y, ...) ; panel.lmline(x,y, ...) })
   
# however, we have some other information which needs to go in each
panel # note that the dimensions (i.e. no of obs) are not the same as
the original # data, and the values are different, but on the same
scale resp.other - rnorm(20)
pred.other - resp.other*1.5 + rnorm(20)
d.other - data.frame(resp=resp.other, pred=pred.other)
d.other$grp - gl(4, 5, labels=letters[1:4])
   
   
The big question:
Now that we have the main plot (main.plot) looking ok, how can we add
the data from d.other to the frames of main.plot without using
subset() for each level of our grouping variable?
 
  Hi,
 
   I would say you are asking the wrong question. The right question is:
   how do I manipulate my data so that it becomes easy to work with. Try
  
   combined - make.groups(d, d.other)
 
  excellent! this makes complete sense...
 
   xyplot(resp ~ pred | grp, data=combined, groups = which,
  panel = panel.superpose,
  panel.groups = function(x,y, ...) {
  panel.xyplot(x, y, ...)
  panel.lmline(x,y, ...)
  })
  
   Is that close to what you want? Does it extend to your real example?
  
   -Deepayan
 
  This is close for the contrived example, but not quite what I need. I
  would like to plot the first 'group' of data as lines, and the second as
  points. I have tried specifying type=c('l', 'p') but this does not appear
  to work.

That was the trick! Here was the general concept:

xyplot(a + b + c ~ d, panel=panel.superpose, distribute.type = TRUE, 
type=c('l', 'l', 'p'))

I will work up an example and post it on the lab website so Google will catch 
similar calls for help.

Thanks again Deepayan, I am only starting to grasp the time-saving potential 
of lattice graphics... but like the output!

Dylan

 Try adding 'distribute.type = TRUE' (see ?panel.superpose). My UseR!
 2007 talk had some relevant examples, so you might find those slides
 useful:

 http://www.user2007.org/program/presentations/sarkar.pdf

 -Deepayan

  If I plot everything as point, the data plot correctly, but not in the
  symbols that I would like.
 
  Cheers,
 
  Dylan
 
# after some messing around, how about this:
xyplot(resp ~ pred | grp, data=d, panel=function(x,y, ...)
{
panel.xyplot(x, y, ...)
panel.lmline(x,y, ...)
# now the other data:
panel.superpose(d.other$pred, d.other$resp, groups=d.other$grp,
col=c('red', 'blue', 'green', 'orange')[as.numeric(d.other$grp)],
pch=16, subscripts=TRUE)
}
)
   
#... hmm it doesn't look like the information from 'd.other' is being
stratified into the panels setup in panel.xyplot() ...
   
The main point to this rather contrived example is this :
   
1. i have a data frame with continuous predictions, the response, and
the grouping variable -- which plot nicely with the default use of
xyplot()
   
2. I would like to embellish each panel with the original response
and predictor values to illustrate the relationship between the
original data and the smooth, fitted curve.
   
ideas?
   
thanks!
   
Dylan
   
   
--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341
 
  --
  Dylan Beaudette
  Soil Resource Laboratory
  http://casoilresource.lawr.ucdavis.edu/
  University of California at Davis
  530.754.7341



-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

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

2007-11-20 Thread Loren Engrav
Hi and thank you

Discussion is surely tough via the web
And I have trouble with tone also, and English

My only point was that Epselon [EMAIL PROTECTED] received education
but not much encouragement IMO and

With the method of Bolker, it might be possible to achieve both for newbies,
ie both education and encouragement

But some might say and why is that your problem? which has some validity

And some might say can't stand the heat? Then perhaps try leaving the
kitchen, which has some truth also

Probably best now return to makeGOGraph and postscript output as at this
point I either have a decorum point or I don't

Thank you for discussing/listening

Loren Engrav
Univ Wash
Seattle



 From: Julian Burgos [EMAIL PROTECTED]
 Date: Tue, 20 Nov 2007 11:12:45 -0800
 To: Loren Engrav [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Subject: Re: [R] Trying to get around R
 
 Hi Loren,
 
 It wasn't my intention to sound arrogant, cruel or off putting.
 English is not my first language, and perhaps my message had a tone I
 did not intended.  The person posting the message I responded was
 literally asking for somebody on the list to do his/hers homework (there
 are even references to hints from the textbook).  This is not only
 academically non-kosher, is also not the purpose of the R-help list.  I
 pointed this to this person and invited him/her to come back with
 specific questions on R coding.
 
 The posting guidelines are easily accessible.  The first line in the
 Mailing Lists section of the R website
 (http://www.r-project.org/mail.html) states Please read the
 instructions below and the posting guide before sending anything to any
 mailing list!, and displays a link to the guide.  There also a link to
 the guide at the bottom of every message send through this list.  The
 posting guide is not hard to find, and (in my opinion) it isn't long or
 difficult to understand (in particular for anyone taking college level
 statistics).
 
 Julian
 
 Loren Engrav wrote:
 I am a newbie to R and Bio emails and
 
 It is clear that newbies make mistakes, I made several which were pointed
 out and I am trying to fix them, and as I fix one I make another, in time
 perhaps I will know it all, but if it is like surgery, I will make
 mistakes until I retire
 
 But the response of the old-timers to these mistakes seems arrogant and
 cruel and off putting and does NOT encourage more participation. In fact
 it takes real stuff to continue after this putdown and that putdown.
 
 There are 3,783 links to posting guidelines, which took 1.5 hours to find
 and read and understand.
 
 Why not a link on how the mistakes of the newbies will be dealt with?
 
 Or a kindly response from the moderator personal to the newbie rather than
 to the entire world?
 
 Or a kindly general response as from Ben Bolker to my last infraction which
 was You might have better luck with this on the Bioconductor mailing list
 ...
 
 Rather than to the universe...
 Using the wrong list: this is for R-sig-mac, and the topic occcurred
 there recently.
 
 All in an effort to encourage promote useful and increasing exchange
 participation
 
 Or not
 
 Loren Engrav, MD
 Univ Washington
 
 
 From: Julian Burgos [EMAIL PROTECTED]
 Date: Mon, 19 Nov 2007 10:44:49 -0800
 To: Epselon [EMAIL PROTECTED]
 Cc: r-help@r-project.org
 Subject: Re: [R] Trying to get around R
 
 Hello Epselon (if that is your name),
 
 This sounds like homework questions.
 From the R-help posting guide:
 Basic statistics and classroom homework:
 R-help is not intended for
 these.
 
 If you have a specific question on R
 coding, do ask it (and provide
 reproducible code).  But you should not expect
 for people on the list to
 do your homework for you.  That is a big
 no-no.
 
 Cheers,
 
 Julian
 
 
 Epselon wrote:
 I have three problems I am trying to
 simulate, that I am having difficulty
 getting around with.
 
 Problem 1.
 I want to determine the 85 percentile (the x value for which the sum of
 
 probabilities becomes 0.85) of the following distributions (two binomials
 and a Poisson with rate Lmbda= np of the two binomials): X ~B(10, 0.3),
 Y~P(3) , 
 Z~B(30, 0.1). I want to show that  that Y is a good approximation
 for Z but
 not for X...(by examining these distributions for few
 different
 percentiles)
 Problem 2:
 For a binomial distribution X ~ B(20, 0.4), I
 want to use R to calculate
 P{|X - μ|  2} and verify that it is near or
 larger than 0.95. (Hint from
 the text book: Since μ = 8 and   2.3 then
 you 
 may want to read the
 weights, or probabilities, of the values 6:10, into a
 vector v and then use
 the command sum(v) to
 calculate the sum.) Repeat
 this for another set of parameters of your
 choice.
 
 Problem 3:
 Draw a
 sample of size 10, from a Poisson with Lambda= 5, and calculate the
 mean
 and 
 the standard deviation of this sample, Repeat this calculation with
 size 20
 and 30 and demonstrate
 that ~X gets closer to μ as the sample size
 increases.
 Thanks.
 
 I would 

Re: [R] display basename

2007-11-20 Thread Bert Gunter
z=read.table(chosen - file.choose(),dec=.,header=TRUE) 

will assign the return value of file.choose (the path names of the file as a
character string) to chosen.

This sort of code is seductive, but I find it quite difficult to read. I
have also gotten myself into trouble from time to time doing it sloppily.

Bert Gunter
Genentech Nonclinical Statistics


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of mysimbaa
Sent: Tuesday, November 20, 2007 2:30 PM
To: r-help@r-project.org
Subject: [R] display basename


Hello everybody,

I'm sorry for asking a dumb question, but I don't find how to loos it.

I need to display the name of the choosing file using this command :

z=read.table(file.choose(),dec=.,header=TRUE)

Thanks for any help.
-- 
View this message in context:
http://www.nabble.com/display-basename-tf4846650.html#a13866718
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] skewness: generating distribution and estimating M3.

2007-11-20 Thread Milton Cezar Ribeiro
Dear all,

How can I generate values which distrituions have left or rigth skewness.
After that, which function compute the skewness of each distributions?

Kind regards.

miltinho



 para armazenamento!

[[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] barplot problem

2007-11-20 Thread pieterprovoost
Thanks guys, that's exactly what I was looking for!

Pieter

--
This message was sent on behalf of [EMAIL PROTECTED] at openSubscriber.com
http://www.opensubscriber.com/message/r-help@r-project.org/8030546.html

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


[R] Vectorization/Speed Problem

2007-11-20 Thread Tom Johnson
Hi,

I cannot find a 'vectorized' solution to this 'for loop' kind of problem.
Do you see a vectorized, fast-running solution?

Objective:
Take the value of X at each timepoint and calculate the corresponding value
of Y.  Leading 0's and all 1's for X are assigned to Y; otherwise Y is
incremented by the number of 0's adjacent to the last 1.  The frequency and
distribution of X vary widely and may have ~100 repeated 0's or 1's in a
vector of 10k timepoints.

Example:
time 1   2   3   4   5   6   7   8   9   10  11  12  13  14  15
X0   1   0   1   0   1   0   0   1   1   1   0   0   0   . .
Y0   1   2   1   2   1   2   3   1   1   1   2   3   4   . .

What I have done:
My for() and apply()-related standard solutions are too slow.  They are 6
times slower than my prototype, vectorized code which uses cumsum().
However(!)... my results are inaccurate and I can't correct them without
introducing a for()!  Here is my shot at a vectorized solution, as far as I
can take it.

Preliminary Vectorized Code:
X   - matrix(sample(c(1,0,0,0,0), 500, replace = TRUE), 25, 20, byrow=TRUE)
colnames(X) - c(paste(a, 1:20, sep=))
noX - X; noX[X!=0] - 0; cumX - noX; cumNoX - noX; Y1 - noX; Y2 - X; Y3
- X

for (e in 1:ncol(X)) {
cumX[,e] - cumsum(X[,e])
noX[X[,e]  1  cumsum(X[,e])  0 ,e] - 1
cumNoX[,e] - cumsum(noX[,e])
}
Y1[cumNoX  0] - cumNoX[cumNoX  0] + 1
Y2[X == 0  noX  0] - Y1[X == 0  noX  0]
Y3 - Y2
Y3[cumX  1  noX  0] - Y2[cumX  1  noX  0] - cumX[cumX  1  noX  0]
X; Y3

Your help would be greatly appreciated!  I'm stuck.
Thank you,

Tom
Johnson

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

2007-11-20 Thread Bert Gunter
Of course. I was just putting it inline to be as minimalist as possible...
I'm in a minimal mood today...

-- Bert 


Bert Gunter
Nonclinical Statistics
7-7374

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
Behalf Of Henrik Bengtsson
Sent: Tuesday, November 20, 2007 3:25 PM
To: Bert Gunter
Cc: mysimbaa; r-help@r-project.org
Subject: Re: [R] display basename

So why not suggest

pathname - file.choose()
z - read.table(pathname, dec=., header=TRUE)

instead.

/Henrik

On Nov 20, 2007 2:58 PM, Bert Gunter [EMAIL PROTECTED] wrote:
 z=read.table(chosen - file.choose(),dec=.,header=TRUE)

 will assign the return value of file.choose (the path names of the file as
a
 character string) to chosen.

 This sort of code is seductive, but I find it quite difficult to read. I
 have also gotten myself into trouble from time to time doing it sloppily.

 Bert Gunter
 Genentech Nonclinical Statistics



 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On
 Behalf Of mysimbaa
 Sent: Tuesday, November 20, 2007 2:30 PM
 To: r-help@r-project.org
 Subject: [R] display basename


 Hello everybody,

 I'm sorry for asking a dumb question, but I don't find how to loos it.

 I need to display the name of the choosing file using this command :

 z=read.table(file.choose(),dec=.,header=TRUE)

 Thanks for any help.
 --
 View this message in context:
 http://www.nabble.com/display-basename-tf4846650.html#a13866718
 Sent from the R help mailing list archive at Nabble.com.

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

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


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


Re: [R] Logarithmic axis

2007-11-20 Thread Julian Burgos
Hey John,

You can do simply

plot(reizstaerke, kennlinie1, ylim=c(0, max(kennlinie1, 
kennlinie2)),log=x)

but if you want to fine tune where the tick marks are, you can do it by 
hand.

kennlinie1 -  c(8.0746909, 3.9916973, 9.9789444, 19.962869);
kennlinie2 -  c(6.0994206, 8.9661081, 19.924883, 31.879496);
reizstaerke - c(76, 92, 108, 124);
plot(log10(reizstaerke), kennlinie1, ylim=c(0, max(kennlinie1, 
kennlinie2)),axes=F)
box()
axis(1,at=log10(seq(75,125,by=5)),label=seq(75,125,by=5))
axis(2)

The obvious reason that you are getting a plot with a single 100 and 
nothing else is that the range of the values in the reizstaerke vector 
is away from 10 and from 1000.  If you really want to have the log scale 
in the way you described, you could do something like this:

plot(log10(reizstaerke), kennlinie1, ylim=c(0, max(kennlinie1, 
kennlinie2)),axes=F,xlim=log10(c(1,1000)))
box()
axis(1,at=log10(c(1,10,100,1000)),label=c(1,10,100,1000))
axis(2)

Julian


John Wiedenhoeft wrote:
 Hi there,
 
 I guess this must be a standard issue, but I'm starting to go crazy with it. 
 I 
 simply want a plot with the x axis being logarithmic, having labels 1, 10, 
 100..., and ten unlabelled ticks between each of them - just as they 
 introduce logarithmic axis at school. I've played around a bit with log=x, 
 xlog=T (where exactly is the difference here?), xaxp, and xaxt (unfortunately 
 xaxt=l isn't implemented). The best I get is a plot with an axis having a 
 single 100 and nothing else...
 
 here is what I've tried:
 
 pdf(file=kennlinien.pdf);
 par(log=x, xlog=TRUE);
 kennlinie1 -  c(8.0746909, 3.9916973, 9.9789444, 19.962869);
 kennlinie2 -  c(6.0994206, 8.9661081, 19.924883, 31.879496);
 reizstaerke - c(76, 92, 108, 124);
 #plot(reizstaerke, kennlinie1, ylim=c(0, max(kennlinie1, kennlinie2)), 
 xlim=c(0, max(reizstaerke)), log=x, xlog=TRUE, xaxp=c(1, 2, 1), type=b);
 #plot(reizstaerke, kennlinie1, type=b, log=x, xlog=TRUE, xaxp=c(1, 2, 3));
 plot(reizstaerke, kennlinie1, type=b,usr=c(min(reizstaerke), 
 max(reizstaerke), min(kennlinie1, kennlinie2), max(kennlinie1, kennlinie2)), 
 log=x, xlog=TRUE, xaxp=c(1, 2, 3));
 #points(reizstaerke, kennlinie2, xlog=TRUE, xaxp=c(1, 3, 3), type=b);
 dev.off();
 
 Certainly I've missed something, but I can't figure it out.
 
 Any help appreciated,
 Cheers, 
 John
 
 
 
 platform   i486-pc-linux-gnu
 arch   i486
 os linux-gnu
 system i486, linux-gnu
 status
 major  2
 minor  4.1
 year   2006
 month  12
 day18
 svn rev40228
 language   R
 version.string R version 2.4.1 (2006-12-18)
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] Logarithmic axis

2007-11-20 Thread Julian Burgos
Like always, there is much to be learned from the R-help list!  Another 
message had a much simpler approach.

plot(xy.coords(reizstaerke, kennlinie1, log=x), log=x)

Julian


Julian Burgos wrote:
 Hey John,
 
 You can do simply
 
 plot(reizstaerke, kennlinie1, ylim=c(0, max(kennlinie1, 
 kennlinie2)),log=x)
 
 but if you want to fine tune where the tick marks are, you can do it by 
 hand.
 
 kennlinie1 -  c(8.0746909, 3.9916973, 9.9789444, 19.962869);
 kennlinie2 -  c(6.0994206, 8.9661081, 19.924883, 31.879496);
 reizstaerke - c(76, 92, 108, 124);
 plot(log10(reizstaerke), kennlinie1, ylim=c(0, max(kennlinie1, 
 kennlinie2)),axes=F)
 box()
 axis(1,at=log10(seq(75,125,by=5)),label=seq(75,125,by=5))
 axis(2)
 
 The obvious reason that you are getting a plot with a single 100 and 
 nothing else is that the range of the values in the reizstaerke vector 
 is away from 10 and from 1000.  If you really want to have the log scale 
 in the way you described, you could do something like this:
 
 plot(log10(reizstaerke), kennlinie1, ylim=c(0, max(kennlinie1, 
 kennlinie2)),axes=F,xlim=log10(c(1,1000)))
 box()
 axis(1,at=log10(c(1,10,100,1000)),label=c(1,10,100,1000))
 axis(2)
 
 Julian
 
 
 John Wiedenhoeft wrote:
 Hi there,

 I guess this must be a standard issue, but I'm starting to go crazy 
 with it. I simply want a plot with the x axis being logarithmic, 
 having labels 1, 10, 100..., and ten unlabelled ticks between each of 
 them - just as they introduce logarithmic axis at school. I've played 
 around a bit with log=x, xlog=T (where exactly is the difference 
 here?), xaxp, and xaxt (unfortunately xaxt=l isn't implemented). The 
 best I get is a plot with an axis having a single 100 and nothing else...

 here is what I've tried:

 pdf(file=kennlinien.pdf);
 par(log=x, xlog=TRUE);
 kennlinie1 -  c(8.0746909, 3.9916973, 9.9789444, 19.962869);
 kennlinie2 -  c(6.0994206, 8.9661081, 19.924883, 31.879496);
 reizstaerke - c(76, 92, 108, 124);
 #plot(reizstaerke, kennlinie1, ylim=c(0, max(kennlinie1, kennlinie2)), 
 xlim=c(0, max(reizstaerke)), log=x, xlog=TRUE, xaxp=c(1, 2, 1), 
 type=b);
 #plot(reizstaerke, kennlinie1, type=b, log=x, xlog=TRUE, xaxp=c(1, 
 2, 3));
 plot(reizstaerke, kennlinie1, type=b,usr=c(min(reizstaerke), 
 max(reizstaerke), min(kennlinie1, kennlinie2), max(kennlinie1, 
 kennlinie2)), log=x, xlog=TRUE, xaxp=c(1, 2, 3));
 #points(reizstaerke, kennlinie2, xlog=TRUE, xaxp=c(1, 3, 3), type=b);
 dev.off();

 Certainly I've missed something, but I can't figure it out.

 Any help appreciated,
 Cheers, John



 platform   i486-pc-linux-gnu
 arch   i486
 os linux-gnu
 system i486, linux-gnu
 status
 major  2
 minor  4.1
 year   2006
 month  12
 day18
 svn rev40228
 language   R
 version.string R version 2.4.1 (2006-12-18)

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

2007-11-20 Thread Gabor Grothendieck
Let x be the input vector and cx be the cumulative running sum of it.
Then seq_along(cx) - match(cx, cx) gives increasing sequences
starting at 0 and for those after the leading zeros we start them
at 1 by adding cummax(x).

x - c(0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0) # input

cx - cumsum(x)
seq_along(cx) - match(cx, cx) + cummax(x)

On Nov 20, 2007 6:42 PM, Tom Johnson [EMAIL PROTECTED] wrote:
 Hi,

 I cannot find a 'vectorized' solution to this 'for loop' kind of problem.
 Do you see a vectorized, fast-running solution?

 Objective:
 Take the value of X at each timepoint and calculate the corresponding value
 of Y.  Leading 0's and all 1's for X are assigned to Y; otherwise Y is
 incremented by the number of 0's adjacent to the last 1.  The frequency and
 distribution of X vary widely and may have ~100 repeated 0's or 1's in a
 vector of 10k timepoints.

 Example:
 time 1   2   3   4   5   6   7   8   9   10  11  12  13  14  15
 X0   1   0   1   0   1   0   0   1   1   1   0   0   0   . .
 Y0   1   2   1   2   1   2   3   1   1   1   2   3   4   . .

 What I have done:
 My for() and apply()-related standard solutions are too slow.  They are 6
 times slower than my prototype, vectorized code which uses cumsum().
 However(!)... my results are inaccurate and I can't correct them without
 introducing a for()!  Here is my shot at a vectorized solution, as far as I
 can take it.

 Preliminary Vectorized Code:
 X   - matrix(sample(c(1,0,0,0,0), 500, replace = TRUE), 25, 20, 
 byrow=TRUE)
colnames(X) - c(paste(a, 1:20, sep=))
 noX - X; noX[X!=0] - 0; cumX - noX; cumNoX - noX; Y1 - noX; Y2 - X; Y3
 - X

 for (e in 1:ncol(X)) {
cumX[,e] - cumsum(X[,e])
noX[X[,e]  1  cumsum(X[,e])  0 ,e] - 1
cumNoX[,e] - cumsum(noX[,e])
}
 Y1[cumNoX  0] - cumNoX[cumNoX  0] + 1
 Y2[X == 0  noX  0] - Y1[X == 0  noX  0]
 Y3 - Y2
 Y3[cumX  1  noX  0] - Y2[cumX  1  noX  0] - cumX[cumX  1  noX  0]
 X; Y3

 Your help would be greatly appreciated!  I'm stuck.
 Thank you,

 Tom
 Johnson

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Is there a simpler way to do this?

2007-11-20 Thread Anup Nandialath
Dear Friends,

My objective is to do element wise multiplication of two vectors. For example 
suppose I have 

a - (1,1,1)
b - (2,4)

My output should be (2,4,2,4,2,4). I managed to write it down with loops as 
follows

r - c(1,1,1)
l - c(2,4)
x - 1
for (j in 1:3)
{
  for (i in 1:2)
{
  new[x,] - r[j]*l[i]
  x - x+1
}
}


Is there a simpler solution to this without using the loops?


Thanks and Regards

Anup

   
-
Be a better sports nut! Let your teams follow you with Yahoo Mobile. Try it now.
[[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] Is there a simpler way to do this?

2007-11-20 Thread Marc Schwartz

On Tue, 2007-11-20 at 17:13 -0800, Anup Nandialath wrote:
 Dear Friends,
 
 My objective is to do element wise multiplication of two vectors. For example 
 suppose I have 
 
 a - (1,1,1)
 b - (2,4)
 
 My output should be (2,4,2,4,2,4). I managed to write it down with loops as 
 follows
 
 r - c(1,1,1)
 l - c(2,4)
 x - 1
 for (j in 1:3)
 {
   for (i in 1:2)
 {
   new[x,] - r[j]*l[i]
   x - x+1
 }
 }
 
 
 Is there a simpler solution to this without using the loops?
 
 
 Thanks and Regards
 
 Anup

Try this:

 as.vector(t(a %o% b))
[1] 2 4 2 4 2 4


See ?outer for more information.

HTH,

Marc Schwartz

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] rowSums() and is.integer()

2007-11-20 Thread Tim Hesterberg
I wrote the original rowSums (in S-PLUS).
There, rowSums() does not coerce integer to double.

However, one advantage of coercion is to avoid integer overflow.

Tim Hesterberg

...  So, why does rowSums() coerce to double (behaviour
that is undesirable for me)?

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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 select rows with identical index from two matrix?

2007-11-20 Thread C.S. Liu
Dear list,

I have two martix like these, each rows with name in the matrix. 

I try to select rows with identical name from two matrix and calculate 
their correlation.

Matrix1:
2-Sep9 5.51 7.18 10.08 139.45
2-Sep7 4.915   8.22 61.68  9 123.62
4-Sep
5-Sep
AAMP
A2M
A2M
.
.
.

Matrix2:

2-Sep 4 71 6.8 128  19.4
2-Sep  2815   2.2 6.8   12 13.2
4-Sep
AAMP
AAMP
ABCA5
A2M
A2M

I try to select rows with identical name from two matrix and calculate their 
correlation.

However, I got trouble when loading these two matrix into R as header=TRUE. 

So I use header=FLASE and these name become character in the first column.  

How do I extract the first column of matrix 1 and compare to the first column 
of matrix 2?

And if they are identical I compute their correlation?


SIncerely yours,
Chiahsin Liu

[[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] Manipulating x axis in stripchart

2007-11-20 Thread Judith Flores
Hi all,

   I I need to manipulate the x axis in a stripchart.
I will use one of the data sets included in R to
explain what I need to do.

attach(ToothGrowth)

stripchart(len[supp=='VC']~dose[supp=='VC'],
vertical=TRUE, group.names=c('A','A','A'))

stripchart(len[supp=='OJ']~dose[supp=='OJ'], add=TRUE,
vertical=TRUE, at=c(1:3)+.1,
group.names=c('B','B','B'))

As you can read from the code above, I wanted to add
the 'B' to the x axis to diffrenciate each pair of
strips from each other. But only the 'A's appear.

I tried something like this too, but now '.5','1' and
'2' along with the 'A' and 'B'.

attach(ToothGrowth)

stripchart(len[supp=='VC']~dose[supp=='VC'],
vertical=TRUE)
axis(side=1,labels=c('A','B','A','B','A','B'),
at=c(.4,.5,.9,1.1,1.9,2.1))


stripchart(len[supp=='OJ']~dose[supp=='OJ'], add=TRUE,
vertical=TRUE, at=c(1:3)+.1)

And finally I tried setting par(xaxt='n') before
stripchart, but then I can't add anything to the x
axis.

  Is there a way to manipulate the x axis in a
stripchart like this?

Thank you very much in advance for your help,

Judith

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/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] Manipulating x axis in stripchart

2007-11-20 Thread Gabor Grothendieck
If its ok to use lattice try this:

library(lattice)

# no attach needed

# we want VC to be first level, not OJ
ToothGrowth$supp - relevel(ToothGrowth$supp, VC)

# rename levels
levels(ToothGrowth$supp) - c(A, B)

# plot
dotplot(len ~ supp | dose, ToothGrowth, layout = c(3, 1))


On Nov 20, 2007 10:04 PM, Judith Flores [EMAIL PROTECTED] wrote:
 Hi all,

   I I need to manipulate the x axis in a stripchart.
 I will use one of the data sets included in R to
 explain what I need to do.

 attach(ToothGrowth)

 stripchart(len[supp=='VC']~dose[supp=='VC'],
 vertical=TRUE, group.names=c('A','A','A'))

 stripchart(len[supp=='OJ']~dose[supp=='OJ'], add=TRUE,
 vertical=TRUE, at=c(1:3)+.1,
 group.names=c('B','B','B'))

 As you can read from the code above, I wanted to add
 the 'B' to the x axis to diffrenciate each pair of
 strips from each other. But only the 'A's appear.

 I tried something like this too, but now '.5','1' and
 '2' along with the 'A' and 'B'.

 attach(ToothGrowth)

 stripchart(len[supp=='VC']~dose[supp=='VC'],
 vertical=TRUE)
 axis(side=1,labels=c('A','B','A','B','A','B'),
 at=c(.4,.5,.9,1.1,1.9,2.1))


 stripchart(len[supp=='OJ']~dose[supp=='OJ'], add=TRUE,
 vertical=TRUE, at=c(1:3)+.1)

 And finally I tried setting par(xaxt='n') before
 stripchart, but then I can't add anything to the x
 axis.

  Is there a way to manipulate the x axis in a
 stripchart like this?

 Thank you very much in advance for your help,

 Judith

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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] skewness: generating distribution and estimating M3.

2007-11-20 Thread Matthias Kohl
Dear Milton,

package distrEx has methods to compute skewness.

library(distrEx)
?skewness

To generate new distributions you could use package distr.

hth,
Matthias


Milton Cezar Ribeiro wrote:
 Dear all,

 How can I generate values which distrituions have left or rigth skewness.
 After that, which function compute the skewness of each distributions?

 Kind regards.

 miltinho



  para armazenamento!

   [[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] problem modeling time series

2007-11-20 Thread eugen pircalabelu
Good afternoon!

I'm trying to model a ts but unfortunately i'.m very new to this kind of 
modeling  so i 'll be very grateful if you have an advice. 

This was my syntax:

t-c(16115,17391,19011,20256,19034,18851,20016,18088,19166,21163,18463,19397,15800,16113,18879,20598,17252,19753,19110,19605,20836,18868,20204,24384,15817,18223,19884,21059,18545,19853,20027,20061,21679,20210,20351,21322,16891,17111,20166,18735,16821,17891,17058,19250)
plot.ts(t)
acf(t)
pacf(t)
arima(t,order=c(13,2,0), seasonal=list(order=c(1,1,1)))-fit
predict(fit, n.ahead=1) 


Now, choosing my order, was a trial and error process where i used the acf, pcf 
and AIC  (which  is minimized by taking those specific values)  but as you can 
imagine   this is something made by ear. I want to know if there is some test 
which can give me the proper values for the order? (i haven't found some full 
examples which describe the process fully from head to toe) 

Second, if this is the best fitting model for that specific ts, now don't you 
think that those standard errors are huge! Say, if the novice 
client eliminates  that  great rise/damp in the series and wants to predict 
solely based on his impressions from the time series he would probably give me 
the same interval, as the arima gave me, and i can't give him some  new  piece 
of info.  Is there something wrong with my ts, or with my arima model, and  how 
 could i make that confidence  interval smaller ?

Thank you and have a great day! 

   
-

[[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 NA's

2007-11-20 Thread leffgh

somewhere I read that  !is.na(your_vector) is better than your_vector!=NA
.


Thomas L Jones, PhD wrote:
 
 Difficulty handling NA's:
 Assume that I have a numeric vector y. For simplicity, assume that it has
 10 
 elements. Assume that the third element has the value NA. I give it the 
 following:
 NA_test - function (){
 y - numeric (10)
 y [3] - NA
 if (y [3] != NA){(print (no)}
 print (Leaving NA_test)
 return ()
 }# End of function
 
 -
 Unfortunately, things become confused involving the NA element.
 Here is the output, starting with the loading process:
 
 --
 NA_test - function (){
 + y - numeric (10)
 + y [3] - NA
 + if (y [3] != NA){(print (no)}
 Error: syntax error in:
 y [3] - NA
 if (y [3] != NA){(print (no)}
 print (Leaving NA_test)
 [1] Leaving NA_test
 return ()
 Error: no function to return from, jumping to top level
 }# End of function
 Error: syntax error in }

 -
 I have enclosed the print operation in braces to avoid possible problems 
 with it.
 
 Your advice?
 
 Tom Jones
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/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/Problems-with-NA%27s-tf4840964.html#a13872489
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.