RE: [R] Adding labels to variables

2004-08-24 Thread Martin Maechler
References: <[EMAIL PROTECTED]>
X-Mailer: VM 7.18 under Emacs 21.3.1
Reply-To: Martin Maechler <[EMAIL PROTECTED]>
FCC: ~maechler/F/out
--text follows this line--
> "AustinM" == Austin, Matt <[EMAIL PROTECTED]>
> on Tue, 24 Aug 2004 22:15:15 -0700 writes:

AustinM> Check out the Hmisc library.

It's a *package*, not a library !

Note that there are also the  "comment" and
"comment<-"  function pair (in R's base) that you could use :

  > x <- 1:10
  > comment(x) <- "this is the price of the R stock"
  > x
   [1]  1  2  3  4  5  6  7  8  9 10
  > comment(x)
  [1] "this is the price of the R stock"

  > comment(x+4)
  [1] "this is the price of the R stock"


[these are probably among the oldest R (non-S) functions,
 maybe not known for this reason, and not really used in other
 public functions AFAIK]

Martin Maechler

AustinM> -Original Message-
AustinM> [mailto:[EMAIL PROTECTED] Behalf Of Neil Leonard
AustinM> Sent: Tuesday, August 24, 2004 22:0 PM
AustinM> To: [EMAIL PROTECTED]
AustinM> Subject: [R] Adding labels to variables

AustinM> Hi,

AustinM> Is it possible to add labels to variables in R (so
AustinM> as to have a better description of what the
AustinM> variables represent)?

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


Re: [R] Adding labels to variables

2004-08-24 Thread Gabor Grothendieck
Neil Leonard  tartarus.uwa.edu.au> writes:

: Is it possible to add labels to variables in R (so as to have a better 
: description of what the variables represent)?

One can add arbitrarily named attributes to objects.  For example,
we can add an attribute which we shall call memo to object z:

R> z <- 3
R> attr(z,"memo") <- "very important number"

R> # sometime later
R> z
[1] 3
attr(,"memo")
[1] "very important number"

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


RE: [R] Adding labels to variables

2004-08-24 Thread Austin, Matt
Check out the Hmisc library.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Neil Leonard
Sent: Tuesday, August 24, 2004 22:0 PM
To: [EMAIL PROTECTED]
Subject: [R] Adding labels to variables


Hi,

Is it possible to add labels to variables in R (so as to have a better 
description of what the variables represent)?


Thanks,
Neil

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

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


[R] Adding labels to variables

2004-08-24 Thread Neil Leonard
Hi,
Is it possible to add labels to variables in R (so as to have a better 
description of what the variables represent)?

Thanks,
Neil
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] Boxplot across levels of a factor

2004-08-24 Thread Paul Boutros
Thank you: works like a charm.
Paul

> -Original Message-
> From: Prof Brian Ripley [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, August 24, 2004 2:28 AM
> To: Paul Boutros
> Cc: R-Help
> Subject: Re: [R] Boxplot across levels of a factor
> 
> 
> On Tue, 24 Aug 2004, Paul Boutros wrote:
> 
> > Hello,
> > 
> > I have a data-frame in which one-column is a factor:
> > 
> > > str(data);
> > `data.frame':   194 obs. of  8 variables:
> >  $ Type : Factor w/ 3 levels "Nuclear-Rec..",..: 1 2 2 
> 2 2 2 2 2 2 2
> > ...
> >  $ Locus: num  0.000571 0.004000 0.001429 0.004857 0.007429 ...
> > 
> > And I'd like to make a boxplot of the data$Locus values, where 
> each level of
> > the factor gets its own box-and-whiskers plot.  I'm weak in R, 
> but I thought
> > there might be some shortcut to automating this instead of just 
> creating a
> > new data-structure with all the separate values?
> 
> There are two.  The simpler is
> 
>   boxplot(Locus ~ Type, data=data)
> 
> and you can also use
> 
>   with(data, boxplot(split(Locus, Type)))
> 
> (split() does automate the construction of a suitable data structure.)
> 
> -- 
> 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
>

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


Re: [R] stem() bug?

2004-08-24 Thread Jack Tanner

First, I'm curious. Is there any reason why the leaves are squished together 
with no delimeters?

Second, the crucial point that seems to be missing from the stem help page 
(and one I can't glean without going through the code) is how bins are 
determined. If that can be explained to the reader, the explanation of scale 
follows naturally.

Third, feel free to incorporate the following text into the help page as 
necessary; I've tried to make it helpful (but clarity is obviously in the 
eye of the beholder).

stem produces a stem-and-leaf plot of the elements in x. Each element is 
placed in a bin ranging [low, high); that is, if y is an element, it is 
placed in the bin iff low <= element < high. The size of the bin is 
determined by... .

The stem that is listed for the bin is not necessarily the stem of all (or 
any) of the leaves in the bin; the true stems must be equal to or higher 
than the listed stems, but they will all be smaller than the  lowerst stem 
of the next highest bin. (Observe how the bin for the stem 4 changes with 
the two examples below.)

Leaves are ordered within a bin. If leaves seem unordered (e.g., 4 | 0306), 
then the scale of the plot may be too compressed: that bin contains leaves 
from multiple different stems. The parameter scale can be used to expand the 
scale of the plot.

Arguments
x 	a numeric vector.
scale 	This controls the number of bins. A value of scale=2 will cause the 
plot to be twice as long as the default by using roughly twice as many bins.
width 	The desired width of the plot, in characters.
atom 	a tolerance [This needs better text.]

Examples
stem(c(30, 32, 50, 52, 60, 62, 70, 72, 80, 82))
stem(c(30, 32, 50, 52, 60, 62, 70, 72, 80, 82), scale=2)
Original Message Follows
From: Prof Brian Ripley <[EMAIL PROTECTED]>
To: Ramzi Nahhas <[EMAIL PROTECTED]>
CC: [EMAIL PROTECTED], <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
Subject: Re: [R] stem() bug?
Date: Tue, 24 Aug 2004 09:17:08 +0100 (BST)
It is as intended.  The answer is correct but your interpretation of it is
not, and the help page is woefully lacking.
Note that the bins in your problem are [20, 40), [40, 60), [60, 80) and
[80, 100) and they are correctly labelled.  In such bins e.g. 20 and 30
are both represented in the same way.
Does stem(seq(30, 92, 5)) help you see the pattern?
Please would one of those bemoaning R's documentation recently submit to
R-bugs an enhanced help page for stem?
On Tue, 24 Aug 2004, Ramzi Nahhas wrote:
>
> Is the following a bug with stem() or is there something else that I am
> missing? I ran stem() on the vector x below and got stem(x-10) instead of
> stem(x). If I subtract 1 from x, I get a correct answer. If I add 1 to x, 
I
> still get a wrong answer. If I add 10 to x, I get a correct answer. I'm 
not
> sure what to make of this, other than to think it is a bug.
>
> Can anyone tell me if this is a bug?
>
> I am running R 1.9.1 on Windows XP (SP2).
>
> Sincerely,
> 	Ramzi Nahhas
>
> PS In your reply, please copy me at [EMAIL PROTECTED] as I am not
> subscribed to this list. Thank you.
>
> > x
>  [1] 30 70 90 75 70 95 75 70 60 55
> > stem(x)
>
>   The decimal point is 1 digit(s) to the right of the |
>
>   2 | 0
>   4 | 5
>   6 | 55
>   8 | 05
>
> > stem(x-1)
>
>   The decimal point is 1 digit(s) to the right of the |
>
>   2 | 9
>   4 | 49
>   6 | 99944
>   8 | 94
>
> > stem(x+1)
>
>   The decimal point is 1 digit(s) to the right of the |
>
>   2 | 1
>   4 | 6
>   6 | 66
>   8 | 16
>
> > stem(x+10)
>
>   The decimal point is 1 digit(s) to the right of the |
>
>4 | 0
>6 | 50
>8 | 00055
>   10 | 05
>
> ---
>
>
>
>
>
> 	[[alternative HTML version deleted]]
>
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html
>
>

--
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
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] analyzing cluster sample

2004-08-24 Thread Paul von Hippel
I am analyzing a survey where ~20,000 cases were sampled in ~1000 clusters. 
I would like to analyze the data using, for example, gam. What is the best 
way to account for the clustering? I've tried including the cluster ID as a 
factor in the model formula, but the default response is to try and 
estimate the unique effect of each cluster, which given 1000 clusters is 
impossibly time consuming. What I want instead is an estimate of the 
variance due to clusters, or perhaps an intraclass correlation, and 
cluster-adjusted standard errors for the effects of other variables in the 
model.

I expect I can account for clustering by using lme with clusters as a 
random effect, but then I can't use the flexible smooths available in gam.

If it's not possible to get both clustering and smooths, I may use gam and 
adjust the standard errors using an estimate of the design effect.

Many thanks for any advice,
Paul
Paul von Hippel
Department of Sociology / Initiative in Population Research
Ohio State University
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] bug or no?

2004-08-24 Thread Gabor Grothendieck

Note that R requires that anything placed AFTER the ... 
to be matched exactly so one can force exact matching
on sb by putting it after the ... like this:

R> temp<-function(...,sb) print(sb)
R> temp(2,s=3)
Error in print(sb) : Argument "sb" is missing, with no default



Chuck Cleland  optonline.net> writes:

: 
: I don't think it's a bug, it's partial matching of 
: argument names.  To avoid it, use exact argument names in 
: your call to the function:
: 
: temp(sb=2,s=3)
: [1] 2
: 
:From the R language definition:
: 
: "Argument matching: Formal arguments are matched to supplied 
: arguments first by exact matching on tags, then by partial 
: matching on tags, and finally by positional matching."
: 
: http://cran.r-project.org/doc/contrib/R_language.pdf
: 
: Richard Morey wrote:
: > The following code prints [1] 2, as it should
: > 
: > temp<-function(ab,...){
: > print(ab)
: > }
: > temp(2,s=3)
: > 
: > However, this code prints [1] 3:
: > 
: > temp<-function(sb,...){
: > print(sb)
: > }
: > temp(2,s=3)
: > 
: > It should still print [1] 2. It appears
: > that if a variable in ... begins with the same letter as another variable,
: > the value in the variable in ... overwrites the value in the variable with
: > the same first letter.
: > 
: > I didn't see this bug reported elsewhere.
: > 
: > Richard Morey
: > 
: > Is this a bug or am I missing something?
: > 
: > output of R.version
: > platform i686-pc-linux-gnu
: > arch i686
: > os   linux-gnu
: > system   i686, linux-gnu
: > status
: > major1
: > minor9.1
: > year 2004
: > month06
: > day  21
: > language R
: > 
: > 
:

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


Re: [R] bug or no?

2004-08-24 Thread Chuck Cleland
  I don't think it's a bug, it's partial matching of 
argument names.  To avoid it, use exact argument names in 
your call to the function:

temp(sb=2,s=3)
[1] 2
  From the R language definition:
"Argument matching: Formal arguments are matched to supplied 
arguments first by exact matching on tags, then by partial 
matching on tags, and finally by positional matching."

http://cran.r-project.org/doc/contrib/R_language.pdf
Richard Morey wrote:
The following code prints [1] 2, as it should
temp<-function(ab,...){
print(ab)
}
temp(2,s=3)
However, this code prints [1] 3:
temp<-function(sb,...){
print(sb)
}
temp(2,s=3)
It should still print [1] 2. It appears
that if a variable in ... begins with the same letter as another variable,
the value in the variable in ... overwrites the value in the variable with
the same first letter.
I didn't see this bug reported elsewhere.
Richard Morey
Is this a bug or am I missing something?
output of R.version
platform i686-pc-linux-gnu
arch i686
os   linux-gnu
system   i686, linux-gnu
status
major1
minor9.1
year 2004
month06
day  21
language R


--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 452-1424 (M, W, F)
fax: (917) 438-0894
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] bug or no?

2004-08-24 Thread Sundar Dorai-Raj

Richard Morey wrote:
The following code prints [1] 2, as it should
temp<-function(ab,...){
print(ab)
}
temp(2,s=3)
However, this code prints [1] 3:
temp<-function(sb,...){
print(sb)
}
temp(2,s=3)
It should still print [1] 2. It appears
that if a variable in ... begins with the same letter as another variable,
the value in the variable in ... overwrites the value in the variable with
the same first letter.
I didn't see this bug reported elsewhere.
Richard Morey
Is this a bug or am I missing something?
You are missing something. Mainly, reading section 4.3 of "R Language 
Definition", which should come with your distribution or is accessible 
from CRAN.

http://cran.r-project.org/doc/manuals/R-lang.pdf
--sundar
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] bug or no?

2004-08-24 Thread Richard Morey
The following code prints [1] 2, as it should

temp<-function(ab,...){
print(ab)
}
temp(2,s=3)

However, this code prints [1] 3:

temp<-function(sb,...){
print(sb)
}
temp(2,s=3)

It should still print [1] 2. It appears
that if a variable in ... begins with the same letter as another variable,
the value in the variable in ... overwrites the value in the variable with
the same first letter.

I didn't see this bug reported elsewhere.

Richard Morey

Is this a bug or am I missing something?

output of R.version
platform i686-pc-linux-gnu
arch i686
os   linux-gnu
system   i686, linux-gnu
status
major1
minor9.1
year 2004
month06
day  21
language R


-- 
Richard Morey
Graduate Research Assistant, Cognition and Neuroscience
University of Missouri-Columbia

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


[R] R/S-plus Course***September, 2004***R/Splus Fundamentals and Programming Techniques

2004-08-24 Thread elvis
XLSolutions Corporation (www.xlsolutions-corp.com) is proud 
to announce August 2004 2-day "R/S-plus Fundamentals and 
Programming Techniques". 

Washington, DC --> September, 23-24
Chicago, IL--> September, 16-17

Interested in our R/Splus Advanced Programming course? Please email 
us! 
Reserve your seat now at the early bird rates! Payment due AFTER the 
class. 


Course Description: 
This two-day beginner to intermediate R/S-plus course focuses 
on a broad spectrum of topics, 
from reading raw data to a comparison of R and S. We will learn 
the essentials of data manipulation, graphical visualization 
and R/S-plus programming. We will explore statistical data analysis 
tools,including graphics with data sets. How to enhance your plots. 
We will perform basic statistics and fit linear regression models. 
Participants are encouraged to bring data for interactive sessions 


With the following outline: 
- An Overview of R and S 
- Data Manipulation and Graphics 
- Using Lattice Graphics 
- A Comparison of R and S-Plus 
- How can R Complement SAS? 
- Writing Functions 
- Avoiding Loops 
- Vectorization 
- Statistical Modeling 
- Project Management 
- Techniques for Effective use of R and S 
- Enhancing Plots 
- Using High-level Plotting Functions 
- Building and Distributing Packages (libraries) 


Email us for group discounts. 
Email Sue Turner: [EMAIL PROTECTED] 

Visit us: www.xlsolutions-corp.com/training.htm 
Please let us know if you and your colleagues are interested in this 
classto take advantage of group discount. Register now to secure your 
seat! 
Interested in R/Splus Advanced course? email us. 


Cheers, 
Elvis Miller, PhD 
Manager Training. 
XLSolutions Corporation 
206 686 1578 
www.xlsolutions-corp.com 
[EMAIL PROTECTED]

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


[R] "how to set the number format to pure numeric?" was SOLVED

2004-08-24 Thread lichi
Thank you for your kind help. I am done now.

regards,
lichi

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


Re: [R] (no subject)

2004-08-24 Thread Tony Plate
Looks like there might have been some truncation of Jonathon Baron's message.
Here's one way of computing the sample mode of a vector.
> set.seed(1)
> x <- sample(1:5,20,rep=T)
> x
 [1] 2 2 3 5 2 5 5 4 4 1 2 1 4 2 4 3 4 5 2 4
> table(x)
x
1 2 3 4 5
2 6 2 6 4
> names(which.max(table(x)))
[1] "2"
>
Note that this method returns the first max value in the case of ties.
hope this helps,
Tony Plate
At Tuesday 11:01 AM 8/24/2004, Jonathan Baron wrote:
On 08/24/04 13:50, Paolo Tommasini wrote:
>Hi my name is Paolo Tommasini does anyone know how to compute a "mode"
>( most frequent element ) for a distribution ?
which.max
--
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
R search page: http://finzi.psych.upenn.edu/
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] how to set the number format to pure numeric?

2004-08-24 Thread David Brahm
lichi shi <[EMAIL PROTECTED]> wrote:
> I want to export a numeric matrix in pure numeric format, i.e. I want
> 0.0001 to appear as "0.0001". But it seems the default setting for
> write.table is scientific notation, i.e. it will appear as "1e-04". how
> to set the number format to pure numeric?

Try:
R> options(scipen=99)
which sets a very high SCIentific notation PENalty.
-- 
  -- David Brahm ([EMAIL PROTECTED])

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


Re: [R] apply ( , , table)

2004-08-24 Thread Tony Plate
apply() tries to be a bit smart about what it does (sometimes maybe too 
smart), but it actually is pretty useful a lot of the time.  It's extremely 
widely used, so changing the behavior is not an option -- changing the 
behavior would break a lot of existing code.  (Personally, I'd prefer it if 
apply() put its dimensions back together in a slightly more intelligent 
way, i.e., if apply(x, 1, c) and apply(x, 2, c) returned the same thing, 
but apply is how it is.)

In situations where you don't want apply() to try to construct a matrix 
from your results, you can wrap the results in a list, to force apply() to 
return just a list of results, e.g. (the outer "lapply()" strips off an 
unnecessary level of list depth):

> b2 <- lapply(apply (a, 1, function(x) list(table(x))), "[[", 1)
> length(b2)
[1] 4
> b2[[1]]
x
1 2 6 7
2 1 1 1
> attributes(b2[[1]])
$dim
[1] 4
$dimnames
$dimnames$x
[1] "1" "2" "6" "7"
$class
[1] "table"
Your particular case might benefit from more information given to table, 
which allows it to provide results in a more uniform format, e.g.:

> b1 <- apply (a, 1, function(x) table(factor(x, levels=0:9)))
> b1
  [,1] [,2] [,3] [,4]
00100
12112
21001
30100
40220
50011
61001
71000
80010
90000
>
hope this helps,
Tony Plate
At Tuesday 10:42 AM 8/24/2004, [EMAIL PROTECTED] wrote:


a <- matrix (c(
7, 1, 1, 2, 6,
3, 4, 0, 1, 4,
5, 1, 8, 4, 4,
6, 1, 1, 2, 5), nrow=4, byrow=TRUE)
b <- apply (a, 1, table)
"apply" documentation says clearly that if the rows of the result of FUN
are the same length, then an array will be returned.  And column-major
would be the appropriate order in R.  But "b" above is pretty opaque
compared to what one would expect, and what one would get from "apply (
, , table)" if the rows were not of equal length.  One needs to do
something like
n <- matrix (apply (a, 1, function (x) unique (sort (x))), nrow=nrow(a))
to get the corresponding "names" of "b" to figure out the counts.
Denis White
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] mode of a distribution - was (no subject)

2004-08-24 Thread Charles Annis, P.E.
Perhaps a time out might be helpful.

?which.max will produce the location (index) of the maximum of a numeric
vector, but Paolo doesn't want that.  He wants the location of the most
frequent observation which would be the maximum of the probability density,
which he doesn't have.  

It would be useful to estimate what kind of density represents the data and
then, given this, determine its interesting statistics, including the mode.


Charles Annis, P.E.
 
[EMAIL PROTECTED]
phone: 561-352-9699
eFax:  503-217-5849
http://www.StatisticalEngineering.com

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jonathan Baron
Sent: Tuesday, August 24, 2004 1:01 PM
To: Paolo Tommasini
Cc: [EMAIL PROTECTED]
Subject: Re: [R] (no subject)

On 08/24/04 13:50, Paolo Tommasini wrote:
>Hi my name is Paolo Tommasini does anyone know how to compute a "mode"
>( most frequent element ) for a distribution ?

which.max

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
R search page: http://finzi.psych.upenn.edu/

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

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


RE: [R] (no subject)

2004-08-24 Thread Berton Gunter
No, this is not quite right: 

which.max

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
R search page: http://finzi.psych.upenn.edu/

You need to be more careful 

1. For a continuous distribution, the mode is ** not ** the most frequent
value (this has no meaning) -- it is the maximum of the density function. So
you must fit a density function and then estimate the mode, perhaps by using
which.max() on a discretization of the fitted density. Or, if you have the
fitted density in closed form (and it is unimodal) you can use calculus.

2. For a discrete distribution, which could be the sample empirical
distribution,use which.max(table()). 

-- Bert Gunter

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


RE: [R] The "Green" Book?

2004-08-24 Thread Sam Chapman
Thank you for your perspective . . . I see what you mean, and that's actually
more or less how I had interpreted Professor Ripley's remarks. I'll have to
investigate further the advantages of using S4 classes in my work. I suspect
they'll eventually prove their worth. Thanks again for the clarification. SC

Quoting "Liaw, Andy" <[EMAIL PROTECTED]>:

> Sam,
>
> What BDR meant (I believe) is that it depends on _how_ you intend to use R,
> not what your background is.  If you are going to develop code using the new
> S4 classes, the green book will be relevant.  If you are going to use R for
> data analysis, there's probably little to gain by reading the green book.
>
> Best,
> Andy
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf Of Sam Chapman
> > Sent: Monday, August 23, 2004 10:16 AM
> > To: Prof Brian Ripley
> > Cc: Thomas Lumley; [EMAIL PROTECTED]
> > Subject: Re: [R] The "Green" Book?
> >
> >
> > Thank you for your responses. I should have mentioned that I
> > am new to R, but
> > not to programming. Nevertheless, the insights are valued and
> > appreciated!
> >
> >
> > Quoting Prof Brian Ripley <[EMAIL PROTECTED]>:
> >
> > > On Fri, 20 Aug 2004, Thomas Lumley wrote:
> > >
> > > > On Fri, 20 Aug 2004, Sam Chapman wrote:
> > > >
> > >
> > > [A quote from `An Introduction to R' has been excised here]
> > >
> > > > > There is no mention of 'Programming with Data: A Guide
> > to the S Language'
> > > by
> > > > > John M. Chambers. Is this newest ("Green") book also
> > suitable as a
> > > reference
> > > > > for R? Thank you for your time and attention!
> > > > >
> > > >
> > > > Yes. The system implemented in the "methods" package is
> > not identical to
> > > > that in the Green Book, but it's pretty similar.
> > >
> > > Well, it is suitable as reference for programmers using the
> > "methods"
> > > package in R, not quite the question asked.  At the level of `An
> > > Introduction to R' it is not really a suitable reference as
> > it has limited
> > > coverage at that level.  (The Green Book itself recommends
> > other books for
> > > end users.)
> > >
> > > --
> > > 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
> > >
> > >
> >
> >
> > Sincerely,
> >
> > Sam Chapman
> >
> > __
> > [EMAIL PROTECTED] mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
> >
>
>
> --
> Notice:  This e-mail message, together with any attachments, contains
> information of Merck & Co., Inc. (One Merck Drive, Whitehouse Station, New
> Jersey, USA 08889), and/or its affiliates (which may be known outside the
> United States as Merck Frosst, Merck Sharp & Dohme or MSD and in Japan, as
> Banyu) that may be confidential, proprietary copyrighted and/or legally
> privileged. It is intended solely for the use of the individual or entity
> named on this message.  If you are not the intended recipient, and have
> received this message in error, please notify us immediately by reply e-mail
> and then delete it from your system.
> --
>


Sincerely,

Sam Chapman

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


Re: [R] (no subject)

2004-08-24 Thread Jonathan Baron
On 08/24/04 13:50, Paolo Tommasini wrote:
>Hi my name is Paolo Tommasini does anyone know how to compute a "mode"
>( most frequent element ) for a distribution ?

which.max

-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
R search page: http://finzi.psych.upenn.edu/

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


[R] (no subject)

2004-08-24 Thread Paolo Tommasini
Hi my name is Paolo Tommasini does anyone know how to compute a "mode"  
( most frequent element ) for a distribution ?

thanks
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] apply ( , , table)

2004-08-24 Thread White . Denis




a <- matrix (c(
7, 1, 1, 2, 6,
3, 4, 0, 1, 4,
5, 1, 8, 4, 4,
6, 1, 1, 2, 5), nrow=4, byrow=TRUE)

b <- apply (a, 1, table)

"apply" documentation says clearly that if the rows of the result of FUN
are the same length, then an array will be returned.  And column-major
would be the appropriate order in R.  But "b" above is pretty opaque
compared to what one would expect, and what one would get from "apply (
, , table)" if the rows were not of equal length.  One needs to do
something like

n <- matrix (apply (a, 1, function (x) unique (sort (x))), nrow=nrow(a))

to get the corresponding "names" of "b" to figure out the counts.

Denis White

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


Re: [R] firewall or proxy problems

2004-08-24 Thread Uwe Ligges
Sergio Anguissola wrote:
Hi, I right now installed the R and then I tried to download and install the
get bioC package, but I receive an error message saying that the software
couldn't connect trough the port 80. I went to the FAQ and I found that I
have to type somewhere -internet 2
So you are on Windows?
You are going to *invoke* R the way mentioned there. Just change the 
link that calls R in the described manner (BTW: it says "--internet2"!). 
If you don't know how to change a link, please contact local Windows 
support.

Uwe Ligges

, but I couldn't understand when and
where, could you help me?
Thanks.
Sergio.
 

Sergio Anguissola Ph.D 
Dept. of Physiology 
RCSI, Education & Research Center 
Smurfit Building, Beaumont Hospital 
Dublin 9 
Republic of Ireland 
Tel: 01-809-3861 
Fax: 01-809-3837 
Email: [EMAIL PROTECTED]

 


This email and any files transmitted with it are confidentia...{{dropped}}
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] how to in XML on windows XP for R 1.9.1

2004-08-24 Thread Prof Brian Ripley
On Tue, 24 Aug 2004 [EMAIL PROTECTED] wrote:

> Hello, Uwe,
> Thank you all for your reply!
> I installed binary packages XML_0.97.0.zip by "Install package(s) from local zip
> file" and followed instruction in the doc:

That's not the instructions in the README!

>  you will have to add the XML/libs
> directory to your path.  Putting them into the
> directory which contains Rgui.exe and Rterm.exe for this
> version of R is probably best.
> I then put add the XML/libs directory to director rw1091/bin, but it still gave
> messagae like this:

What it actually says is

but to use it in R, you will have to add the XML/libs
directory to your path or copy the files
  libxml2.dll zlib.dll iconv.dll
to a directory in your path.  Putting them into the
directory which contains Rgui.exe and Rterm.exe for this
version of R is probably best.

and there are no such files in the distribution.

> > library("XML")
> Error in dyn.load(x, as.logical(local), as.logical(now)) :
> unable to load shared library
> "C:/PROGRA~1/R/rw1091/library/XML/libs/XML.dll":
>   LoadLibrary failure:  The specified module could not be found.
> Error in library("XML") : package/namespace load failed
> What should I do now?

Asking Uwe questions about a package his ReadMe explicitly says he does
not support is unfair.  

Since XML_0.97-0 is not a CRAN package, please ask its author 
directly.  It depends on a libxml2.dll (etc) he has not included.

[This is part of the reason why I statically link libxml into the port of
XML that I make available.  Another is that with a dynamic link the 
internet connection possibilities do not work correctly, at least when I 
build it.

Another issue is that you need different builds for different versions of
R, and www.omegahat.org/RSXML does not say which it was built for.]

> Josh
> Quoting Uwe Ligges <[EMAIL PROTECTED]>:
> 
> > Prof Brian Ripley wrote:
> > > On Tue, 24 Aug 2004 [EMAIL PROTECTED] wrote:
> > >
> > >
> > >>I tried two ways to install Package:XML on windows xp for R 1.9.1, all
> > failed.
> > >
> > >
> > > But you did not read the ReadMe's.
> > >
> > > Do read the ReadMe at http://cran.r-project.org/bin/windows/contrib/1.9.
> >
> > Additionally, after you have got the right package, read the docs how to
> > install binary packages from the local hard disc.
> >
> > Uwe Ligges
> >
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 
> 

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

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


[R] firewall or proxy problems

2004-08-24 Thread Sergio Anguissola
Hi, I right now installed the R and then I tried to download and install the
get bioC package, but I receive an error message saying that the software
couldn't connect trough the port 80. I went to the FAQ and I found that I
have to type somewhere -internet 2, but I couldn't understand when and
where, could you help me?

Thanks.

Sergio.

 

Sergio Anguissola Ph.D 
Dept. of Physiology 
RCSI, Education & Research Center 
Smurfit Building, Beaumont Hospital 
Dublin 9 
Republic of Ireland 
Tel: 01-809-3861 
Fax: 01-809-3837 
Email: [EMAIL PROTECTED]

 


This email and any files transmitted with it are confidentia...{{dropped}}

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


Re: [R] how to in XML on windows XP for R 1.9.1

2004-08-24 Thread Uwe Ligges
[EMAIL PROTECTED] wrote:
Hello, Uwe,
Thank you all for your reply!
I installed binary packages XML_0.97.0.zip 
Hear, hear. To my knowledge, there are the versions
0.94-1 and 0.95-6 of XML available at the URL given in the ReadMe cited 
by Brian Ripley. Note that this ReadMe points to 
http://www.stats.ox.ac.uk/pub/RWin/ !!!

Uwe Ligges

> by "Install package(s) from local zip
file" and followed instruction in the doc:
 you will have to add the XML/libs
directory to your path.  Putting them into the
directory which contains Rgui.exe and Rterm.exe for this
version of R is probably best.
I then put add the XML/libs directory to director rw1091/bin, but it still gave
messagae like this:
library("XML")
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
"C:/PROGRA~1/R/rw1091/library/XML/libs/XML.dll":
  LoadLibrary failure:  The specified module could not be found.
Error in library("XML") : package/namespace load failed
What should I do now?
Josh
Quoting Uwe Ligges <[EMAIL PROTECTED]>:

Prof Brian Ripley wrote:
On Tue, 24 Aug 2004 [EMAIL PROTECTED] wrote:

I tried two ways to install Package:XML on windows xp for R 1.9.1, all
failed.
But you did not read the ReadMe's.
Do read the ReadMe at http://cran.r-project.org/bin/windows/contrib/1.9.
Additionally, after you have got the right package, read the docs how to
install binary packages from the local hard disc.
Uwe Ligges

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


Re: [R] how to set the number format to pure numeric?

2004-08-24 Thread Prof Brian Ripley
On Tue, 24 Aug 2004 [EMAIL PROTECTED] wrote:

> I want to export a numeric matrix in pure numeric format, i.e. I want
> 0.0001 to appear as "0.0001". But it seems the default setting for
> write.table is scientific notation, i.e. it will appear as "1e-04". how to
> set the number format to pure numeric? Thank you very much for your help.

It's not the default, BTW.  Try 0.002, say.
See ?options and look at `scipen' to alter the rules.

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

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


Re: [R] how to in XML on windows XP for R 1.9.1

2004-08-24 Thread szhan
Hello, Uwe,
Thank you all for your reply!
I installed binary packages XML_0.97.0.zip by "Install package(s) from local zip
file" and followed instruction in the doc:
 you will have to add the XML/libs
directory to your path.  Putting them into the
directory which contains Rgui.exe and Rterm.exe for this
version of R is probably best.
I then put add the XML/libs directory to director rw1091/bin, but it still gave
messagae like this:
> library("XML")
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
"C:/PROGRA~1/R/rw1091/library/XML/libs/XML.dll":
  LoadLibrary failure:  The specified module could not be found.
Error in library("XML") : package/namespace load failed
What should I do now?
Josh
Quoting Uwe Ligges <[EMAIL PROTECTED]>:

> Prof Brian Ripley wrote:
> > On Tue, 24 Aug 2004 [EMAIL PROTECTED] wrote:
> >
> >
> >>I tried two ways to install Package:XML on windows xp for R 1.9.1, all
> failed.
> >
> >
> > But you did not read the ReadMe's.
> >
> > Do read the ReadMe at http://cran.r-project.org/bin/windows/contrib/1.9.
>
> Additionally, after you have got the right package, read the docs how to
> install binary packages from the local hard disc.
>
> Uwe Ligges
>

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


[R] how to set the number format to pure numeric?

2004-08-24 Thread lichi
Hello,

I want to export a numeric matrix in pure numeric format, i.e. I want
0.0001 to appear as "0.0001". But it seems the default setting for
write.table is scientific notation, i.e. it will appear as "1e-04". how to
set the number format to pure numeric? Thank you very much for your help.

cheers,
lichi shi

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


Re: [R] ROracle and vector elements

2004-08-24 Thread David James
Hi Laura,

Sorry for the delay, but I was away and I'm finally catching up...

I do have a windows binary at
   http://stat.bell-labs.com/RS-DBI/download/
but note that you need to have the Oracle's client software.

Hope this helps,

--
David

Laura Holt wrote:
> Hi there!
> 
> Is ROracle available for Windows, please?
> 
> I found a download site, but it's really for UNIX/Linux.
> 
> Here is a "thought question", please:  Why do the vector elements start at 
> location 1 rather than zero, as C does?
> 
> Thanks in advance!
> 
> R Version 1.9.1 Windows
> Sincerely,
> Laura Holt
> mailto: [EMAIL PROTECTED]
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
David A. James
Statistics Research, Room 2C-253Phone:  (908) 582-3082   
Bell Labs, Lucent Technologies  Fax:(908) 582-3340
Murray Hill, NJ 09794-0636

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


Re: [R] rgl installation problems

2004-08-24 Thread Xun Liu
It is indeed the following problem. I used the RPM installation as of July 20, 2004 
and had the same problem installing rgl. After fixing the following line in the 
Makeconf file ("-share" is missing), the installation of rgl went successfully.

>This is a little strange.  I'm now building RPMS for older Red Hat versions on FC2 
>using a tool called Mach.  There is a possibility that
>there is some configuration problem, but I can't see it. As Brian has pointed out, 
>you are missing the crucial "-shared" flag when building
>the shared library for rgl. This comes from the line
>
>SHLIB_CXXLDFLAGS = -shared
>
>in the file /usr/lib/R/etc/Makeconf.  This is present in my latest RPM for Red Hat ( 
>R-1.9.1-0.fdr.2.rh90.i386.rpm ) so I don't know why it
>isn't working for you.

>>Here's what should happen on RH9 (with the latest libpng and gcc in /usr/local/lib) 
>>
>>g++ -shared -L/usr/local/lib -o rgl.so x11lib.o x11gui.o types.o math.o fps.o 
>>pixmap.o gui.o api.o device.o devicemanager.o rglview.o scene.o 
>>glgui.o -L/usr/X11R6/lib -L/usr/local/lib -Wl,-rpath,/usr/local/lib -lpng12 -lz -lm 
>>-lstdc++ -lX11 -lXext -lGL -lGLU -lpng12 -lz -lm 

>>Note that he had no --shared but did have crt1.o, that is was trying to build a 
>>standalone executable and not a shared object. 

>>Something is wrong with the R installation's rules to make shared libraries. 

>>On Fri, 25 Jun 2004, Duncan Murdoch wrote: 

>> On Fri, 25 Jun 2004 17:36:30 +, "E GCP" <[EMAIL PROTECTED]> wrote : 
>> 
>> >Hi! 
>> > 
>> >I'm new to R, but have worked with Splus before. I installed several 
>> >packages in R (R-1.9.1) without problems, but when I try to install rgl 
>> >(rgl_0.64-13.tar.gz). I get the following, and the package does not install. 
>> >Any help would be greatly appreciated. I'm running R in redhat 9. 
>> 
>> The missing reference R_InputHandlers is declared in the 
>> $RHOME/src/include/R_ext/eventloop.h file, and I believe is compiled 
>> into the library R_X11 (with some extension). You don't seem to have 
>> that in the list of libraries: 
>> 
>> >g++ -L/usr/local/lib -o rgl.so x11lib.o x11gui.o types.o math.o fps.o 
>> >pixmap.o 
>> >gui.o api.o device.o devicemanager.o rglview.o scene.o glgui.o 
>> >-L/usr/X11R6/lib 
>> >-L/usr/lib -lstdc++ -lX11 -lXext -lGL -lGLU -lpng 
>> >/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/../../../crt1.o(.text+0x18): In 
>> >functio 
>> >n `_start': 
>> >../sysdeps/i386/elf/start.S:77: undefined reference to `main' 
>> >x11lib.o(.text+0x84): In function `set_R_handler': 
>> >/tmp/R.INSTALL.8663/rgl/src/x11gui.h:33: undefined reference to 
>> >`R_InputHandlers 
>> 
>> I don't know what you'll need to do to fix this, since I'm using 
>> Windows, so none of this stuff happens there, and I could be 
>> completely wrong about it.

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


Re: [R] how to in XML on windows XP for R 1.9.1

2004-08-24 Thread Prof Brian Ripley
On Tue, 24 Aug 2004 [EMAIL PROTECTED] wrote:

> I tried two ways to install Package:XML on windows xp for R 1.9.1, all failed.

But you did not read the ReadMe's.

Do read the ReadMe at http://cran.r-project.org/bin/windows/contrib/1.9.

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

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


[R] how to in XML on windows XP for R 1.9.1

2004-08-24 Thread szhan
Dear R experts:
I tried two ways to install Package:XML on windows xp for R 1.9.1, all failed.
Messages are given as bellows:
1> download from CRAN
> install.packages("XML", CRAN = getOption("CRAN"),
+ contriburl = contrib.url("http://cran.r-project.org";),
+ available = NULL, destdir = NULL,
+ installWithVers = FALSE)
trying URL `http://cran.r-project.org/bin/windows/contrib/1.9/PACKAGES'
Content type `text/plain; charset=iso-8859-1' length 20065 bytes
opened URL
downloaded 19Kb

Warning message:
No package "XML" on CRAN. in: download.packages(pkgs, destdir = tmpd, available
= available,

2> Download binary code XML_0.97.0.zip from http://www.omegahat.org/RSXML/
unzipt to goXML directory:
> install.packages("C:/goXML/XML")
trying URL `http://cran.r-project.org/bin/windows/contrib/1.9/PACKAGES'
Content type `text/plain; charset=iso-8859-1' length 20065 bytes
opened URL
downloaded 19Kb

Warning message:
No package "C:/goXML/XML" on CRAN. in: download.packages(pkgs, destdir = tmpd,
available = available,

Could you please help me install it sucessfully?
Thank you for your hellp!

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


RE: [R] Maxima/minima of loess line?

2004-08-24 Thread Jari Oksanen
On Tue, 2004-08-24 at 15:23, Liaw, Andy wrote:
> Just take range() of the fitted loess values.
> 
Or if you really want to investigate the *line* instead of some random
*points*, you may need something like:

> optimize(function(x, mod) predict(mod, data.frame(speed=x)), c(0,20),
maximum=TRUE, mod=cars.lo)
$maximum
[1] 19.5
 
$objective
[1] 56.44498

This elaborates the ?loess example with the result object cars.lo (and,
of course is a bad example since the fit is monotone and solutions is
forced to the margin). Use maximum=FALSE for *a* minimum.

If you have several predictors, you either need to supply constant
values for those in optimize, or for simultaneous search in all use
optim or nlm.

cheers, jari oksanen
> 
> > From: Fredrik Karlsson
> > 
> > Dear list,
> > 
> > I've produced a loess line that I would like to investigate 
> > in terms of 
> > local/global maxima and minima. How would you do this?
> > 
> > Thank you in advance.
> > 
> > /Fredrik Karlsson
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
-- 
Jari Oksanen <[EMAIL PROTECTED]>

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


RE: [R] Maxima/minima of loess line?

2004-08-24 Thread Liaw, Andy
Just take range() of the fitted loess values.

Andy

> From: Fredrik Karlsson
> 
> Dear list,
> 
> I've produced a loess line that I would like to investigate 
> in terms of 
> local/global maxima and minima. How would you do this?
> 
> Thank you in advance.
> 
> /Fredrik Karlsson

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


RE: [R] help with knn from class library

2004-08-24 Thread Liaw, Andy
> From: Martin Olivier
> 
> Hi all,
> 
> I made some computations with the knn function from the class library.
> If I execute this function several times (with the same parameters k, 
> training set and test set), I obtain different results.
> I don't understand why the results for my test set are 
> different. Could 
> you give me some explanations?
> Is the solution for  a k-nearest-neighbor classifier  unique?

Could it be that you have ties in the data?  There's a `use.all' argument:

 use.all: controls handling of ties. If true, all distances equal to
  the 'k'th largest are included. If false, a random selection
  of distances equal to the 'k'th is chosen to use exactly 'k'
  neighbours. 

So you may want to try that.  The other thing to try is to set.seed() before
calling knn().

Andy

 
> Best regards.

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


[R] help with knn from class library

2004-08-24 Thread Martin Olivier
Hi all,
I made some computations with the knn function from the class library.
If I execute this function several times (with the same parameters k, 
training set and test set), I obtain different results.
I don't understand why the results for my test set are different. Could 
you give me some explanations?
Is the solution for  a k-nearest-neighbor classifier  unique?

Best regards.
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


Re: [R] Run function in BATCH mode?

2004-08-24 Thread Uwe Ligges
[EMAIL PROTECTED] wrote:
Hi,
I am working on a shell script where i need to start a R function defined in a
script. I know how to run the script; with 
R CMD BATCH script 
which would be equal to 
source("script") in R. 
But how do I run a function(param) of that script in the BATCH mode? 
Thanks in advance.

__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Say you have a function MyFoo defined in foo.R then you create a file 
call.R that sources foo.r (source("foo.R")) and calls your function by, 
e.g., MyFoo(a, b, x).

Then just say "R CMD BATCH call.R" ...
Uwe Ligges
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


[R] Run function in BATCH mode?

2004-08-24 Thread purmann
Hi,

I am working on a shell script where i need to start a R function defined in a
script. I know how to run the script; with 
R CMD BATCH script 
which would be equal to 
source("script") in R. 
But how do I run a function(param) of that script in the BATCH mode? 
Thanks in advance.

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


[R] Run function in BATCH mode?

2004-08-24 Thread purmann
Hi,

I am working on a shell script where i need to start a R function defined in a
script. I know how to run the script; with 
R CMD BATCH script 
which would be equal to 
source("script") in R. 
But how do I run a function(param) of that script in the BATCH mode? 
Thanks in advance.

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


[R] Maxima/minima of loess line?

2004-08-24 Thread Fredrik Karlsson
Dear list,

I've produced a loess line that I would like to investigate in terms of 
local/global maxima and minima. How would you do this?

Thank you in advance.

/Fredrik Karlsson

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


Re: [R] Test of significance in estimation of correlation coefficients

2004-08-24 Thread Prof Brian Ripley
On Tue, 24 Aug 2004, Jonathan Baron wrote:

> BTW, there is a small bug in the documentation for cor: cor.test
> is no longer in the ctest package, but in stats.

Your information is not up to date: that page has been changed in
R-patched and R-devel. 

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

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


Re: [R] Test of significance in estimation of correlation coefficients

2004-08-24 Thread Jonathan Baron
On 08/24/04 15:05, Vikas Rawal wrote:
>I estimated spearman's correlation coefficient using cor(). How do I
>test for significance?

cor.test

You could find this many ways, but one is to look at the help
document for cor.  cor.test is listed is at the bottom.  In
general, it is a good idea to look at help before posting here.

BTW, there is a small bug in the documentation for cor: cor.test
is no longer in the ctest package, but in stats.

Jon
-- 
Jonathan Baron, Professor of Psychology, University of Pennsylvania
Home page: http://www.sas.upenn.edu/~baron
R search page: http://finzi.psych.upenn.edu/

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


[R] Test of significance in estimation of correlation coefficients

2004-08-24 Thread Vikas Rawal
I estimated spearman's correlation coefficient using cor(). How do I 
test for significance?

Vikas
__
[EMAIL PROTECTED] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


RE: [R] rgdal under windows?

2004-08-24 Thread Benjamin Lloyd-Hughes
Success!

I'm pleased to inform that Roger's recipe worked a treat for compiling
rgdal_0.2-7 in conjunction with gdal-1.2.1 and proj-4.4.8.  Using
MinGW-3.1.0 with MYS-1.0.8 on an xp pro box (SP1) Proj-4 compiled straight
out of the box. Gdal needed a couple of minor tweaks wrt how the boolean
type is defined.  I suspect that gcc is being strict about name spaces.  My
hack was an explicit typedef in jpeglib.h: typedef unsigned char boolean;
and to comment out the definition in jmorecfg.h
After that it was plain sailing except for the curious behaviour of the
MinGW dlltool.exe which refused to to pick up R.dll unless it was given the
full path _irrespective_ of what was placed in $PATH.

Big thanks to Roger and Brian for their helpful advice.  Complicated? Not if
you learn to read!

Cheers, Ben

-Original Message-
From: Roger Bivand [mailto:[EMAIL PROTECTED] 
Sent: 19 August 2004 19:27
To: Prof Brian Ripley
Cc: Benjamin Lloyd-Hughes; [EMAIL PROTECTED]
Subject: Re: [R] rgdal under windows?

On Thu, 19 Aug 2004, Prof Brian Ripley wrote:

> On Thu, 19 Aug 2004, Benjamin Lloyd-Hughes wrote:
> 
> > Has anyone had any joy getting the rgdal package to compile under
windows?
> 
> First you need to meet the system requirements:
> 
> SystemRequirements: GDAL library from 
> http://www.remotesensing.org/gdal/download.html
> 
> Since that has build instructions which say
> 
>   GDAL can be built on Windows using MS VC++ 6.x and MS Visual Studio .NET

>   (C++) at the DOS command line.
> 
> you will first need to get a copy of DOS and those compilers.  (I suspect
> they mean the Windows command prompt, but they don't seem to know the
> difference which is not confidence-inspiring.  I also suspect they mean
> `or' not `and'.)  Then you will have to fathom out how to link against a
> VC++ DLL which since this C++ is very unlikely to work with MinGW.  So you
> probably need to make the package's rgdal.dll under VC++ -- see
> README.packages.
> 
> I have tried and failed to make GDAL with MinGW.
> 
> > I've been trying with MinGW using Duncan Murdoch's Rtools but to no
avail.
> 
> Do read README.packages and follow the advice at the top.  You don't have 
> the (mis-attributed) tools in your path.  But that is probably the least 
> of your potential problems.
> 

Exactly. The closest anyone has got so far is Hisaji Ono, who used MSYS 
(http://www.mingw.org/) to build PROJ.4 and GDAL (GDAL depends on PROJ.4, 
PROJ.4 needs a PATH to metadata files for projection and transformation), 
and then hand-pasted the paths to the GDAL headers and library into 
src/Makevars, running Rcmd INSTALL rgdal at the Windows command prompt as 
usual. All of this can be repeated, but is not portable, and does not suit 
the very valuable standard binary package build system for Windows. 
Roughly:

1. Download everything you need to build source packages under Windows and 
make sure it works;

2. Download MSYS and make sure it works;

3. Download the GDAL and PROJ.4 source tarballs, and possibly other
libraries you want to use with GDAL, and *within MSYS* untar, ./configure
with the appropriate arguments, at least make but maybe also make install
- now leave MSYS;

4. Download the rgdal source package, and *at the Windows command prompt*
untar it, change the name of configure to something else, create
src/Makevars manually from src/Makevars.in, insert the correct values of:
PKG_CPPFLAGS as -I, PKG_LIBS
as -L< ... GDAL libraries> -lgdal, run Rcmd INSTALL rgdal (better first 
Rcmd check rgdal), and repeat until all the problems are resolved.

5. The installation should work locally, but some paths are compiled into 
the resulting *.dll, so it will, most likely, not be portable.

Both Hisaji and I were surprised that this actually seemed to work (as of
late Autumn last year for the versions of MinGW and MSYS available then;  
further fragility is introduced by much of GDAL being written in C++); it
is not wholly impossible that it could be made available portably as a
Windows binary with an installer, but not through the regular R binary
package repositories.

> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: [EMAIL PROTECTED]

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


[R] How to get Dunnett's table value?

2004-08-24 Thread Laurent Houdusse
Hi,

I want to retrieve a value in the Dunnett's tables.
I know the comparisons type, the percent of level,the number of traitments
and the degrees of freedom.
Is there a function to retrieve this value with this?



Laurent Houdusse 
Analyste Programmeur

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


Re: [R] stem() bug?

2004-08-24 Thread Prof Brian Ripley
It is as intended.  The answer is correct but your interpretation of it is 
not, and the help page is woefully lacking.

Note that the bins in your problem are [20, 40), [40, 60), [60, 80) and 
[80, 100) and they are correctly labelled.  In such bins e.g. 20 and 30 
are both represented in the same way.

Does stem(seq(30, 92, 5)) help you see the pattern?

Please would one of those bemoaning R's documentation recently submit to
R-bugs an enhanced help page for stem?

On Tue, 24 Aug 2004, Ramzi Nahhas wrote:

> 
> Is the following a bug with stem() or is there something else that I am
> missing? I ran stem() on the vector x below and got stem(x-10) instead of
> stem(x). If I subtract 1 from x, I get a correct answer. If I add 1 to x, I
> still get a wrong answer. If I add 10 to x, I get a correct answer. I'm not
> sure what to make of this, other than to think it is a bug.
> 
> Can anyone tell me if this is a bug?
> 
> I am running R 1.9.1 on Windows XP (SP2).
> 
> Sincerely,
>   Ramzi Nahhas
> 
> PS In your reply, please copy me at [EMAIL PROTECTED] as I am not
> subscribed to this list. Thank you.
> 
> > x
>  [1] 30 70 90 75 70 95 75 70 60 55
> > stem(x)
> 
>   The decimal point is 1 digit(s) to the right of the |
> 
>   2 | 0
>   4 | 5
>   6 | 55
>   8 | 05
> 
> > stem(x-1)
> 
>   The decimal point is 1 digit(s) to the right of the |
> 
>   2 | 9
>   4 | 49
>   6 | 99944
>   8 | 94
> 
> > stem(x+1)
> 
>   The decimal point is 1 digit(s) to the right of the |
> 
>   2 | 1
>   4 | 6
>   6 | 66
>   8 | 16
> 
> > stem(x+10)
> 
>   The decimal point is 1 digit(s) to the right of the |
> 
>4 | 0
>6 | 50
>8 | 00055
>   10 | 05
> 
> ---
> 
> 
> 
>  
> 
>   [[alternative HTML version deleted]]
> 
> __
> [EMAIL PROTECTED] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
> 
> 

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

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


Re: [R] do linux-version r has gui?

2004-08-24 Thread asemeria
R-cmdr package is nice R-gui.
Help.start() work if your browser support java script,
then I think you haven't a java-plugin installed on your browser
Best regards!

A.S.



Alessandro Semeria
Models and Simulations Laboratory
Montecatini Environmental Research Center (Edison Group),
Via Ciro Menotti 48,
48023 Marina di Ravenna (RA), Italy
Tel. +39 544 536811
Fax. +39 544 538663
E-mail: [EMAIL PROTECTED]

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


[R] stem() bug?

2004-08-24 Thread Ramzi Nahhas

Is the following a bug with stem() or is there something else that I am
missing? I ran stem() on the vector x below and got stem(x-10) instead of
stem(x). If I subtract 1 from x, I get a correct answer. If I add 1 to x, I
still get a wrong answer. If I add 10 to x, I get a correct answer. I'm not
sure what to make of this, other than to think it is a bug.

Can anyone tell me if this is a bug?

I am running R 1.9.1 on Windows XP (SP2).

Sincerely,
Ramzi Nahhas

PS In your reply, please copy me at [EMAIL PROTECTED] as I am not
subscribed to this list. Thank you.

> x
 [1] 30 70 90 75 70 95 75 70 60 55
> stem(x)

  The decimal point is 1 digit(s) to the right of the |

  2 | 0
  4 | 5
  6 | 55
  8 | 05

> stem(x-1)

  The decimal point is 1 digit(s) to the right of the |

  2 | 9
  4 | 49
  6 | 99944
  8 | 94

> stem(x+1)

  The decimal point is 1 digit(s) to the right of the |

  2 | 1
  4 | 6
  6 | 66
  8 | 16

> stem(x+10)

  The decimal point is 1 digit(s) to the right of the |

   4 | 0
   6 | 50
   8 | 00055
  10 | 05

---



 

[[alternative HTML version deleted]]

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


Re: [R] Boxplot across levels of a factor

2004-08-24 Thread Prof Brian Ripley
On Tue, 24 Aug 2004, Ivar Herfindal wrote:

> I think Paul wanted one plot for each box, not all boxes in one plot (sorry 
> if I misunderstand).
> 
> One way to solve this can be like this:
> 
> par(mfrow=c(1,3))
> with(data, by(1:nrow(data), Type, function(x) boxplot(Locus[x]~data[x]))

Actually, that does not come close to working.  Did you try it?
(Please read the documentation for by().)  The following does work

by(data, Type, function(x) boxplot(x$Locus, 
   main=paste("Type", unique(x$Type

but that would be a very unusual plot, and one in which the three plots
had different scalings so the boxplots could not be compared.

For something like that, lattice's bwplot is a better option.

bwplot(Locus ~ Type, data=data)  1 panel
bwplot(Locus ~ factor(rep(1, 182)) | Type, data=data) 3 panels

> 
> Hope this works for you.
> 
> Ivar
> 
> On Tue, 24 Aug 2004 07:27:57 +0100 (BST), Prof Brian Ripley 
> <[EMAIL PROTECTED]> wrote:
> 
> > On Tue, 24 Aug 2004, Paul Boutros wrote:
> >
> >> Hello,
> >>
> >> I have a data-frame in which one-column is a factor:
> >>
> >> > str(data);
> >> `data.frame':   194 obs. of  8 variables:
> >> $ Type : Factor w/ 3 levels "Nuclear-Rec..",..: 1 2 2 2 2 2 2 2 
> >> 2 2
> >> ...
> >> $ Locus: num  0.000571 0.004000 0.001429 0.004857 0.007429 ...
> >>
> >> And I'd like to make a boxplot of the data$Locus values, where each 
> >> level of
> >> the factor gets its own box-and-whiskers plot.  I'm weak in R, but I 
> >> thought
> >> there might be some shortcut to automating this instead of just creating 
> >> a
> >> new data-structure with all the separate values?
> >
> > There are two.  The simpler is
> >
> > boxplot(Locus ~ Type, data=data)
> >
> > and you can also use
> >
> > with(data, boxplot(split(Locus, Type)))
> >
> > (split() does automate the construction of a suitable data structure.)
> >
> 
> 
> 
> 

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

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