RE: [R] Using files as connections

2003-08-29 Thread maj
I nearly forgot to thank Andy Liaw and Tony Plate for their help with this
problem. BTW Andy's method does run faster than the natural fix-up of my
original code.

Murray Jorgensen


 You are using the connection the wrong way.  You need to do something
 like:

 fcon - file(c:/data/perry/data.csv, open=r)
 for (iline in 1:slines) {
 isel - isel + 1
 cline - readLines(fcon, n=1)
 ...
 }
 close(fcon)

 BTW, here's how I'd do it (not tested!):

 strvec - rep(,slines)
 selected - sort(sample(flines, slines))
 skip - c(0, diff(selected) - 1)
 fcon - file(c:/data/[erry/data.csv, open=r)
 for (i in 1:length(skip)) {
 ## skip to the selected line
 readLines(fcon, n=skip[i])
 strvec[i] - readLines(fcon, n=1)
 }
 close(fcon)

 HTH,
 Andy


 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, August 27, 2003 7:19 PM
 To: [EMAIL PROTECTED]
 Subject: [R] Using files as connections


 I have been trying to read a random sample of lines from a
 file into a data frame using readLines(). The help indicates
 that readLines() will start from the current line if the
 connection is open, but presented with a closed connection it
 will open it, start from the beginning, and close it when finished.

 In the code that follows I tried to open the file before
 reading but apparently without success, because the result
 was repeated copies of the first line:

 flines - 107165
 slines - 100
 selected - sort(sample(flines,slines))
 strvec - rep(,slines)
 file(c:/data/perry/data.csv,open=r)
 isel - 0
 for (iline in 1:slines) {
   isel - isel + 1
   cline - readLines(c:/data/perry/data.csv,n=1)
   if (iline == selected[isel]) strvec[isel] - cline else
 isel - isel - 1
 }
 close(c:/data/perry/data.csv)
 sel.flows - read.table(textConnection(strvec), header=FALSE, sep=,)


 There was also an error no applicable method  for close.

 Comments gratefully received.

 Murray Jorgensen

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo /r-help


 --
 Notice:  This e-mail message, together with any
 attachments,...{{dropped}}

 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Creating a new table from a set of constraints

2003-08-29 Thread Francisco J. Bido
Hi Everyone,

Here's a silly newbie question.  How do I remove unwanted rows from an 
R table?  Say that I read my data as:

X - read.table(mydata.txt)

and say that there are columns for age and gender.  Call these X[5] and 
X[10], respectively.
Here, X[5]  is a column of positive integers and X[10] is binary valued 
i.e., zero (for male) and one (for female)

Now, say that I want to form a new table called Y which has the 
following constraints:

1.  Only females that are between 18 and 40 years old.
2.  Only males that are between 20 and 30 years old
I can do this using a typical procedural approach (no different than C 
programmer would) but it seems
to me that R has many shortcuts and so I thought I ask first before 
heading on an inefficient path. What's
a good way of doing this, my data set is very large?

Thanks,
-Francisco
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] Creating a new table from a set of constraints

2003-08-29 Thread Dowkiw, Arnaud
Hi Francisco,

what I would do :

names(X)[c(5,10)]-c(Age,Gender)

Xnew1-X[X$Gender==1  X$Age=18  X$Age =40,]

Xnew2-X[X$Gender==0  X$Age=20  X$Age =30,]

Xnew-rbind(Xnew1,Xnew2)

But there must be something more elegant,

Good luck,

Arnaud


-Original Message-
From: Francisco J. Bido [mailto:[EMAIL PROTECTED]
Sent: Friday, 29 August 2003 4:10 PM
To: [EMAIL PROTECTED]
Subject: [R] Creating a new table from a set of constraints


Hi Everyone,

Here's a silly newbie question.  How do I remove unwanted rows from an 
R table?  Say that I read my data as:

X - read.table(mydata.txt)

and say that there are columns for age and gender.  Call these X[5] and 
X[10], respectively.
Here, X[5]  is a column of positive integers and X[10] is binary valued 
i.e., zero (for male) and one (for female)

Now, say that I want to form a new table called Y which has the 
following constraints:

1.  Only females that are between 18 and 40 years old.
2.  Only males that are between 20 and 30 years old

I can do this using a typical procedural approach (no different than C 
programmer would) but it seems
to me that R has many shortcuts and so I thought I ask first before 
heading on an inefficient path. What's
a good way of doing this, my data set is very large?

Thanks,
-Francisco

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help 

DISCLAIMER**...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] mtext / expression and font type of bold

2003-08-29 Thread Uwe Ligges
Al Piszcz wrote:

mtext does not appear to be rendering a 'bold' expression.
Is there another parameter to set? Thx.
example (does not create bold (font=2) on plot)
  mtext( font=2, expression(paste(y,  = ,  x + z), side=3 )
Mathematical expressions are handled differently from normal text.

You might want to use
  mtext(expression(bold(y == x + z)), side = 3)
See ?plotmath for details.

Uwe Ligges

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Creating a new table from a set of constraints

2003-08-29 Thread Francisco J. Bido
Thanks everyone!  I now see how to handle the situation.  This has to 
be the most responsive mailing list ever...

Best,
-Francisco
On Friday, August 29, 2003, at 01:39 AM, Andrew Hayen wrote:

Also see this page: http://www.ats.ucla.edu/stat/SPLUS/faq/subset_R.htm

A

-Original Message-
From: Francisco J. Bido [mailto:[EMAIL PROTECTED]
Sent: Friday, 29 August 2003 4:10 PM
To: [EMAIL PROTECTED]
Subject: [R] Creating a new table from a set of constraints
Hi Everyone,

Here's a silly newbie question.  How do I remove unwanted rows from an
R table?  Say that I read my data as:
X - read.table(mydata.txt)

and say that there are columns for age and gender.  Call these X[5] and
X[10], respectively.
Here, X[5]  is a column of positive integers and X[10] is binary valued
i.e., zero (for male) and one (for female)
Now, say that I want to form a new table called Y which has the
following constraints:
1.  Only females that are between 18 and 40 years old.
2.  Only males that are between 20 and 30 years old
I can do this using a typical procedural approach (no different than C
programmer would) but it seems
to me that R has many shortcuts and so I thought I ask first before
heading on an inefficient path. What's
a good way of doing this, my data set is very large?
Thanks,
-Francisco
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] extract numerical variables from a data frame

2003-08-29 Thread Vincent Spiesser
Hi

I try to create from a data frame a new one which contains only the 
numerical variables (or factorial ones).

Is there any function which does this task directly ?
Or, is there any function which return the mode of each columns of a data 
frame. ?

Thanks a lot for any help you can offer me,

Vincent Spiesser

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] extract numerical variables from a data frame

2003-08-29 Thread Prof Brian Ripley
On Fri, 29 Aug 2003, Vincent Spiesser wrote:

 Hi
 
 I try to create from a data frame a new one which contains only the 
 numerical variables (or factorial ones).
 
 Is there any function which does this task directly ?
 Or, is there any function which return the mode of each columns of a data 
 frame. ?

I think you want the class, as in

sapply(adf, class)

You could use mode if you really wanted it, but watch out for e.g. the 
mode of a factor being numeric.

However, for your original question I would use

numeric columns:

DF[sapply(DF, is.numeric)]

factor columns:

DF[sapply(DF, is.factor)]

and similar code is found throughout the R sources.

-- 
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://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] extract numerical variables from a data frame

2003-08-29 Thread Simon Fear
for data.frame called dframe:

newframe - dframe[ , lapply(dframe, is.numeric)]

For the mode of the columns

lapply(dframe, mode)

See ?lapply !!

 -Original Message-
 From: Vincent Spiesser [mailto:[EMAIL PROTECTED]
 Sent: 29 August 2003 10:08
 To: [EMAIL PROTECTED]
 Subject: [R] extract numerical variables from a data frame
 
 
 Security Warning:
 If you are not sure an attachment is safe to open please contact 
 Andy on x234. There are 0 attachments with this message.
 
 
 Hi
 
 I try to create from a data frame a new one which contains only the 
 numerical variables (or factorial ones).
 
 Is there any function which does this task directly ?
 Or, is there any function which return the mode of each columns of a
 data 
 frame. ?
 
 Thanks a lot for any help you can offer me,
 
 Vincent Spiesser
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

 

Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 69
Fax: +44 (0) 1379 65
email: [EMAIL PROTECTED]
web: http://www.synequanon.com
 
Number of attachments included with this message: 0
 
This message (and any associated files) is confidential and\...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] What fontfamily x11() device normally uses?

2003-08-29 Thread M.Kondrin
Hello!
Can I somehow set x11 device to use font different from default 
helvetica-arial (times for example?)? Is this font hardcoded into R or 
can I substitute some other system font? Does x11 device use 
standard/user-supplied .Xresources file (under Linux)?
The questions are the same for gtk() device (with .gtkrc substituted for 
.Xresources).
Thanks in advance.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] levelplot behaviour when at cuts the z range

2003-08-29 Thread Edzer J. Pebesma
Consider the following examples:

library(lattice)
x = c(1,1,2,2)
y = c(1,2,1,2)
z = 1:4
levelplot(z~x+y,at=c(.5, 1.5, 2.5, 3.5, 4.5)) # correct
levelplot(z~x+y,at=c(.5, 1.5, 2.5))   # ?
The second plot is clearly incorrect. However, I don't know
what correct behaviour is: ignore everything above 2.5 and
issue a warning? Reject at values that do not cover the
data range, and issue an error message? I think I prefer
the second, as it does not hide extremes.
--
Edzer
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] What fontfamily x11() device normally uses?

2003-08-29 Thread Prof Brian Ripley
You have the sources (for each), so why not read them?

The Unix X11 device has this helvetica hardcoded: what has arial to do 
with it?   If you would like more flexibility, please supply a patch 
against the current R-devel sources.

On Fri, 29 Aug 2003, M.Kondrin wrote:

 Can I somehow set x11 device to use font different from default 
 helvetica-arial (times for example?)? Is this font hardcoded into R or 
 can I substitute some other system font? Does x11 device use 
 standard/user-supplied .Xresources file (under Linux)?
 The questions are the same for gtk() device (with .gtkrc substituted for 
 .Xresources).


-- 
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://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] R and pointer

2003-08-29 Thread Laetitia Marisa
Hi everyone,

I want to write a function that modify directly variables passed as 
parameters (the equivalent in C language of  *ptr/ptr) so that I don't 
have to return a list and to reaffect all my variables.
Is it possible to do so in R?

Thanks a lot.

Laetitia Marisa.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] R and pointer

2003-08-29 Thread Jeff Gentry
 I want to write a function that modify directly variables passed as
 parameters (the equivalent in C language of *ptr/ptr) so that I don't
 have to return a list and to reaffect all my variables. Is it possible
 to do so in R? Thanks a lot.

You can use environments as they're passed by reference.

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] R and pointer

2003-08-29 Thread Prof Brian Ripley
On Fri, 29 Aug 2003, Laetitia Marisa wrote:

 I want to write a function that modify directly variables passed as 
 parameters (the equivalent in C language of  *ptr/ptr) so that I don't 
 have to return a list and to reaffect all my variables.
 Is it possible to do so in R?

Yes, with the .Call/.External interface (and there are examples in the ts 
package).  To a limited extent it is possible with .C(DUP=FALSE), but you 
really don't want to go there.

I would want a very good understanding of R's copying semantics before 
doing this (and those are liable to change, too).

-- 
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://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Creating a new table from a set of constraints

2003-08-29 Thread Roger D. Peng
I would use the subset() function.  Assuming the data frame has variable 
names Gender and Age, you could do:

Y1 - subset(X, Gender == 1  Age = 18  Age = 40)
Y2 - subset(X, Gender == 0  Age = 20  Age = 30)
-roger

Francisco J. Bido wrote:

Hi Everyone,

Here's a silly newbie question.  How do I remove unwanted rows from an 
R table?  Say that I read my data as:

X - read.table(mydata.txt)

and say that there are columns for age and gender.  Call these X[5] 
and X[10], respectively.
Here, X[5]  is a column of positive integers and X[10] is binary 
valued i.e., zero (for male) and one (for female)

Now, say that I want to form a new table called Y which has the 
following constraints:

1.  Only females that are between 18 and 40 years old.
2.  Only males that are between 20 and 30 years old
I can do this using a typical procedural approach (no different than C 
programmer would) but it seems
to me that R has many shortcuts and so I thought I ask first before 
heading on an inefficient path. What's
a good way of doing this, my data set is very large?

Thanks,
-Francisco
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] R and pointer

2003-08-29 Thread Henrik Bengtsson
Three references that are of interest (the two first are related to the
idea of using environments to do the job):

 [1] http://www.maths.lth.se/help/R/ImplementingReferences/
 [2] http://www.maths.lth.se/help/R/R.oo/
 [3] http://www.omegahat.org/OOP/

All of the above are written in the light object-oriented programming,
but from [1] you quite easily get what is needed for just emulating
pointers. Be careful though as R is a functional language.

Best wishes

Henrik Bengtsson
Lund University

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Jeff Gentry
 Sent: den 29 augusti 2003 14:34
 To: Laetitia Marisa
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] R and pointer
 
 
  I want to write a function that modify directly variables passed as 
  parameters (the equivalent in C language of *ptr/ptr) so 
 that I don't 
  have to return a list and to reaffect all my variables. Is 
 it possible 
  to do so in R? Thanks a lot.
 
 You can use environments as they're passed by reference.
 
 __
 [EMAIL PROTECTED] mailing list 
 https://www.stat.math.ethz.ch/mailman/listinfo /r-help
 


__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] vardiag package help

2003-08-29 Thread Monica Palaseanu-Lovejoy
Hi,

First of all a big THANK YOU to all who answered me 
yesterday. 

I am back to my problems with outliers. I did a qqnorm on my 
data (as somebody suggested), but I will like to compare results 
doing other plots as well. I used ‘cook.distance’ on lm and glm 
objects, but still I am not happy with that. 

So now I am loading the “vardiag” package. First thing is to 
transform my data (frame.data) into a matrix – which I did with 
‘as.matrix’. I verify my new object as being amatrix – and it is, 
and I list it to be sure that in is a matrix of n rows with 3 colums.

Now I want to use the command ‘varobj’ to transform my 
matrix into a variogram object.

The param are:
varobj(m, iter = 50, tolerance = 2e-04, trace = 1, loo = F)
where, m is a n by 3 matrix with spatial data.

My matrix has a column for x value, for y value and for pah16 
concentrations.

I always get the following error:
Error in matrix(i1[row(i1)  col(i1)], n1, n1) : 
cannot allocate vector of length 1223600400

What does this means and what I am doing wrong?

Thank you in advance,

Monica

Monica Palaseanu-Lovejoy
University of Manchester
School of Geography
Mansfield Cooper Building 
Oxford Road, Manchester
M13 9PL, UK. 
email: [EMAIL PROTECTED]

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] R and pointer

2003-08-29 Thread Barry Rowlingson
Henrik Bengtsson wrote:

All of the above are written in the light object-oriented programming,
but from [1] you quite easily get what is needed for just emulating
pointers. Be careful though as R is a functional language.


Cutting to what I think was the gist of the original poster's question, 
can I write a function, foo, that does this:

 x - 3
 foo(x)
 x
[1] 9
for any x, in any situation? I'm guessing its doable, but ugly...

Baz

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


RE: [R] R and pointer

2003-08-29 Thread Simon Fear
foo - function(y) assign(deparse(substitute(y)), y^2, parent.frame())

assigns to the calling frame. Or you could put the required frame as
a second argument.

 -Original Message-
 From: Barry Rowlingson [mailto:[EMAIL PROTECTED]
 Cutting to what I think was the gist of the original poster's 
 question, 
 can I write a function, foo, that does this:
 
   x - 3
   foo(x)
   x
 [1] 9
 
 for any x, in any situation? I'm guessing its doable, but ugly...
 
 
 Baz
 
 __
 [EMAIL PROTECTED] mailing list
 https://www.stat.math.ethz.ch/mailman/listinfo/r-help

 

Simon Fear
Senior Statistician
Syne qua non Ltd
Tel: +44 (0) 1379 69
Fax: +44 (0) 1379 65
email: [EMAIL PROTECTED]
web: http://www.synequanon.com
 
Number of attachments included with this message: 0
 
This message (and any associated files) is confidential and\...{{dropped}}

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Six axis y with axis function?

2003-08-29 Thread solares
Hi, 


I am trying to plot a time serie of six colum of data sets on one plot but 
with using a different y-axis ranges for each - preferably with one shown 
on each side of the graph.  I'm trying with axis function but not good luck
i will for each they plot with our proper scale and range for example

time  ABC...etc
08:00:01  1000  15  2
08:00:02  2200  17  5
08:00:03  2500  19  7
...plot.ts(..);axis(what parameter?)
How i'cant plot six axis with your proper scale and range?
thanks. Ruben

Is there a function that will allow me to do this

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Six axis y with axis function?

2003-08-29 Thread Spencer Graves
The following works is tuned for S-Plus 6.1, but these tools can be used 
to produce what I hear in your question:

par(mar=c(5,7,4,7)+.1)# create space for 2 axes on each side
plot(0:1, 0:1, type=l, ylab=y1)
axis(side=2, at=(1:2)/3, labels=(1:2)/3, line=4)
mtext(text=y2, side=2, line=6.5)
axis(side=4, at=(1:3)/4, labels=2^(1:3))
mtext(text=y3, side=4, line=1.5)
axis(side=4, at=(1:4)/5, labels=letters[1:4], line=3.5)
mtext(text=y4, side=4, line=5)
hope this helps.  spencer graves

[EMAIL PROTECTED] wrote:
Hi, 

I am trying to plot a time serie of six colum of data sets on one plot but 
with using a different y-axis ranges for each - preferably with one shown 
on each side of the graph.  I'm trying with axis function but not good luck
i will for each they plot with our proper scale and range for example

time  ABC...etc
08:00:01  1000  15  2
08:00:02  2200  17  5
08:00:03  2500  19  7
...plot.ts(..);axis(what parameter?)
How i'cant plot six axis with your proper scale and range?
thanks. Ruben
Is there a function that will allow me to do this

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] levelplot behaviour when at cuts the z range

2003-08-29 Thread Deepayan Sarkar
On Friday 29 August 2003 05:22, Edzer J. Pebesma wrote:
 Consider the following examples:

 library(lattice)
 x = c(1,1,2,2)
 y = c(1,2,1,2)
 z = 1:4
 levelplot(z~x+y,at=c(.5, 1.5, 2.5, 3.5, 4.5)) # correct
 levelplot(z~x+y,at=c(.5, 1.5, 2.5))   # ?

 The second plot is clearly incorrect. However, I don't know
 what correct behaviour is: ignore everything above 2.5 and
 issue a warning? Reject at values that do not cover the
 data range, and issue an error message? I think I prefer
 the second, as it does not hide extremes.

Definitely a bug, the color vector was just being recycled. I seem to have 
inadverdently fixed this a couple of days ago while making some related 
changes, and now the z-values that are out of bounds are simply not shown (as 
would happen if the corresponding z-values were NA). Does that sound 
acceptable ? I don't like your second option because users may knowingly want 
to do something like this (sort of what xlim and ylim are for). 

I'll send you the modifications off-list for you to try out.

Deepayan

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Lattice plot questions

2003-08-29 Thread Paul, David A
Win2k, R1.7.1:

I am currently working with some growth curve data from a 
biotoxicology experiment.  Each of 12 subjects had their blood
drawn at 0, 2, 4, 6, 8, and 10 weeks.  For the purposes of the 
project, it would be helpful if I were able to do the following:

a.  Produce 12 panels, each displaying the *same* data, with
the strip at the top of a particular panel showing
exactly one of the subject id's
b.  For a particular panel, plot the time course data for
the subject whose id appears in the strip in some
really obvious color (like yellow, red, or blue),
with circles at each time point, and connecting the
dots.  In the same panel, those subjects whose id's
did NOT appear in the strip would ideally have their
data plotted in black, possibly with no symbols at
any of the time points, but still connecting the
dots.

I apologize if the description of what is needed is vague.
It is possible to address (a) by duplicating the data set
twelve times and cbind()ing a factor variable so that each
of the duplicated data sets is associated with exactly one
of the subject id's.  I have done this, and the code

subjects - foo$subject.id
superpose.symbol - trellis.par.get(superpose.symbol)
xyplot(log.response ~ week | factor.variable, data = foo, 
panel = panel.superpose,
groups = subjects,
key = list(space = top, columns = 6, transparent = TRUE, 
text = list(levels(subjects)),
points = Rows(superpose.symbol,1:7))
   )

works, with factor.variable corresponding to the cbind()ed
factor variable.  Unfortunately, I have been unable to figure
out how to do (b).  I would also like to determine a more
memory efficient way of doing (a) -- even though my current
data set is small (only 10 weeks of data per subject), that will 
change.

Also, an examination of superpose.symbol reveals the
following:


 superpose.symbol - trellis.par.get(superpose.symbol)
 superpose.symbol
$cex
[1] 0.8 0.8 0.8 0.8 0.8 0.8 0.8

$col
[1] #00 #ff00ff #00ff00 #ff7f00 #007eff #00 #ff

$font
[1] 1 1 1 1 1 1 1

$pch
[1] o o o o o o o


This seems to indicate that lattice graphics are restricted to
no more than seven colors, though I cannot believe that this is true.  
Where might I search/read/learn about the available colors for
lattice plots and how to denote them?  (I find #ff7f00 to be
a little cryptic, for example.)  Is there a table that relates
these ?hexadecimal? numbers to descriptions like navy blue
for Win2k?

Finally, is it possible to cause superpose.symbol to default to
more than 7 $cex/$col/$font/$pch values?  Since I am working with
12 subjects, plots that assign a different color to each wind up
duplicating colors and symbols at some point.


Much thanks in advance,
  david paul

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] difference between - and =

2003-08-29 Thread Levi Larkey
Hi,

I'm somewhat new to R and I'm trying to figure out the difference 
between the operators - and =.

I've noticed that - cannot be used to bind arguments to values in 
function definitions and calls.  That is, f(x - 2) sets x to 2 in the 
calling frame and then calls f(2) because the expression x - 2 returns 
a value of 2, whereas f(x = 2) sets x = 2 in the evaluation frame and 
not in the calling frame.  From what I can tell, = is only different 
than - in the context of function definitions and calls.

Is there any reason for using one operator over the other outside of 
function definitions and calls?  Can someone point me to a precise 
specification of what each operator does?  Any help would be appreciated!

Levi

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] difference between - and =

2003-08-29 Thread Thomas Petzoldt
Levi Larkey schrieb:
Hi,

I'm somewhat new to R and I'm trying to figure out the difference 
between the operators - and =.
- is an assignement operator
=  is primarily used for named arguments
Some thoughts about the use of = as assignement operator can be found on:

http://developer.r-project.org/equalAssign.html

Thomas

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] Lattice plot questions

2003-08-29 Thread Deepayan Sarkar

Let's consider this simulated data:

foo - data.frame(resp = do.call(c, lapply(as.list(rep(6, 12)),
  function(x) sort(rnorm(x,
  week = rep(2*0:5, 12),
  id = factor(rep(1:12, each = 6)))

Does the following give you what you want ?

xyplot(resp ~ week | id, foo,

   panel = function(x, y, col = sup.sym$col, panel.number, ...) {

   ## this part accesses the data frame directly, and needs to
   ## be adjusted accordingly if the name of the variables
   ## therein change. This draws the part meant for the whole
   ## data set

   panel.superpose(x = foo$week, y = foo$resp,
   subscripts = TRUE, groups = foo$id,
   type = 'l', col = black)

   ## this part draws the colored lines, each overwriting one
   ## of the background lines

   sup.sym - trellis.par.get(superpose.symbol)
   col.this - col[1 + ((panel.number - 1) %% length(col))]
   panel.xyplot(x, y, type = 'b', col = col.this, 
lwd = 2, cex = 1.2, ...)
   
   })

This will by default use the colors in superpose.symbol, but you can override 
that by specifying your own color as an argument to xyplot, perhaps something 
like 

xyplot(resp ~ week | id, foo, col = c(red, yellow, blue),
   panel = 

I personally don't see the point of using different colors though (that would 
seem useful to me only if the different colors appeared within the same 
panel).

There's no restriction on the length of the elements of 
trellis.par.get(superpose.symbol). 7 (which is just as good a number as any 
other) is the default choice, inspired by Trellis in S. Set it to whatever 
you want with trellis.par.set() or lset() (or just supply the colors to 
xyplot(), which is usually more convenient for specific tasks like this).

Names like navy blue are just a convenience, and I doubt that all 256^3 
colors in the RGB space have been named, so trying to get a name for 
#ff7f00 may not get you anywhere. R has a function col2rgb() that converts 
colors to RGB, e.g.

 col2rgb(#ff7f00)
  [,1]
red255
green  127
blue 0
 col2rgb(navyblue)
  [,1]
red  0
green0
blue   128

If you are more comfortable with named colors, use them--- R accepts them 
everywhere. A list of names it recognizes is produced by 

 colors()

The help pages for colors and col2rgb have more information.

HTH,

Deepayan

On Friday 29 August 2003 11:14, Paul, David A wrote:
 Win2k, R1.7.1:

 I am currently working with some growth curve data from a
 biotoxicology experiment.  Each of 12 subjects had their blood
 drawn at 0, 2, 4, 6, 8, and 10 weeks.  For the purposes of the
 project, it would be helpful if I were able to do the following:

   a.  Produce 12 panels, each displaying the *same* data, with
   the strip at the top of a particular panel showing
   exactly one of the subject id's
   b.  For a particular panel, plot the time course data for
   the subject whose id appears in the strip in some
   really obvious color (like yellow, red, or blue),
   with circles at each time point, and connecting the
   dots.  In the same panel, those subjects whose id's
   did NOT appear in the strip would ideally have their
   data plotted in black, possibly with no symbols at
   any of the time points, but still connecting the
   dots.

 I apologize if the description of what is needed is vague.
 It is possible to address (a) by duplicating the data set
 twelve times and cbind()ing a factor variable so that each
 of the duplicated data sets is associated with exactly one
 of the subject id's.  I have done this, and the code

 subjects - foo$subject.id
 superpose.symbol - trellis.par.get(superpose.symbol)
 xyplot(log.response ~ week | factor.variable, data = foo,
   panel = panel.superpose,
   groups = subjects,
   key = list(space = top, columns = 6, transparent = TRUE,
   text = list(levels(subjects)),
   points = Rows(superpose.symbol,1:7))
)

 works, with factor.variable corresponding to the cbind()ed
 factor variable.  Unfortunately, I have been unable to figure
 out how to do (b).  I would also like to determine a more
 memory efficient way of doing (a) -- even though my current
 data set is small (only 10 weeks of data per subject), that will
 change.

 Also, an examination of superpose.symbol reveals the

 following:
  superpose.symbol - trellis.par.get(superpose.symbol)
  superpose.symbol

 $cex
 [1] 0.8 0.8 0.8 0.8 0.8 0.8 0.8

 $col
 [1] #00 #ff00ff #00ff00 #ff7f00 #007eff #00 #ff

 $font
 [1] 1 1 1 1 1 1 1

 $pch
 [1] o o o o o o o


 This seems to indicate that lattice graphics are restricted to
 no more than seven colors, though I cannot believe that this is 

RE: [R] Lattice plot questions

2003-08-29 Thread Paul, David A
Thank you VERY much!  That does address my questions.

Respectfully,
  david paul

-Original Message-
From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 29, 2003 1:54 PM
To: Paul, David A; '[EMAIL PROTECTED]'
Subject: Re: [R] Lattice plot questions



Let's consider this simulated data:

foo - data.frame(resp = do.call(c, lapply(as.list(rep(6, 12)),
  function(x) sort(rnorm(x,
  week = rep(2*0:5, 12),
  id = factor(rep(1:12, each = 6)))

Does the following give you what you want ?

xyplot(resp ~ week | id, foo,

   panel = function(x, y, col = sup.sym$col, panel.number, ...) {

   ## this part accesses the data frame directly, and needs to
   ## be adjusted accordingly if the name of the variables
   ## therein change. This draws the part meant for the whole
   ## data set

   panel.superpose(x = foo$week, y = foo$resp,
   subscripts = TRUE, groups = foo$id,
   type = 'l', col = black)

   ## this part draws the colored lines, each overwriting one
   ## of the background lines

   sup.sym - trellis.par.get(superpose.symbol)
   col.this - col[1 + ((panel.number - 1) %% length(col))]
   panel.xyplot(x, y, type = 'b', col = col.this, 
lwd = 2, cex = 1.2, ...)
   
   })

This will by default use the colors in superpose.symbol, but you can
override 
that by specifying your own color as an argument to xyplot, perhaps
something 
like 

xyplot(resp ~ week | id, foo, col = c(red, yellow, blue),
   panel = 

I personally don't see the point of using different colors though (that
would 
seem useful to me only if the different colors appeared within the same 
panel).

There's no restriction on the length of the elements of 
trellis.par.get(superpose.symbol). 7 (which is just as good a number as
any 
other) is the default choice, inspired by Trellis in S. Set it to whatever 
you want with trellis.par.set() or lset() (or just supply the colors to 
xyplot(), which is usually more convenient for specific tasks like this).

Names like navy blue are just a convenience, and I doubt that all 256^3 
colors in the RGB space have been named, so trying to get a name for 
#ff7f00 may not get you anywhere. R has a function col2rgb() that converts

colors to RGB, e.g.

 col2rgb(#ff7f00)
  [,1]
red255
green  127
blue 0
 col2rgb(navyblue)
  [,1]
red  0
green0
blue   128

If you are more comfortable with named colors, use them--- R accepts them 
everywhere. A list of names it recognizes is produced by 

 colors()

The help pages for colors and col2rgb have more information.

HTH,

Deepayan

On Friday 29 August 2003 11:14, Paul, David A wrote:
 Win2k, R1.7.1:

 I am currently working with some growth curve data from a 
 biotoxicology experiment.  Each of 12 subjects had their blood drawn 
 at 0, 2, 4, 6, 8, and 10 weeks.  For the purposes of the project, it 
 would be helpful if I were able to do the following:

   a.  Produce 12 panels, each displaying the *same* data, with
   the strip at the top of a particular panel showing
   exactly one of the subject id's
   b.  For a particular panel, plot the time course data for
   the subject whose id appears in the strip in some
   really obvious color (like yellow, red, or blue),
   with circles at each time point, and connecting the
   dots.  In the same panel, those subjects whose id's
   did NOT appear in the strip would ideally have their
   data plotted in black, possibly with no symbols at
   any of the time points, but still connecting the
   dots.

 I apologize if the description of what is needed is vague.
 It is possible to address (a) by duplicating the data set twelve times 
 and cbind()ing a factor variable so that each of the duplicated data 
 sets is associated with exactly one of the subject id's.  I have done 
 this, and the code

 subjects - foo$subject.id
 superpose.symbol - trellis.par.get(superpose.symbol)
 xyplot(log.response ~ week | factor.variable, data = foo,
   panel = panel.superpose,
   groups = subjects,
   key = list(space = top, columns = 6, transparent = TRUE,
   text = list(levels(subjects)),
   points = Rows(superpose.symbol,1:7))
)

 works, with factor.variable corresponding to the cbind()ed factor 
 variable.  Unfortunately, I have been unable to figure out how to do 
 (b).  I would also like to determine a more memory efficient way of 
 doing (a) -- even though my current data set is small (only 10 weeks 
 of data per subject), that will change.

 Also, an examination of superpose.symbol reveals the

 following:
  superpose.symbol - trellis.par.get(superpose.symbol)
  superpose.symbol

 $cex
 

[R] lattice question

2003-08-29 Thread Murad Nayal


Hello,

I am using lattice to plot histograms of one variable conditioned on
another continuous variable. for this I am using equal.count on the
conditioning variable to get the appropriate shingle. I would like to
have in my plot a representation of the shingle's intervals including
the min/max values and maybe tick marks. some sort of axis for the
conditioning variable. while the 'strips' of the lattice plot do
represent the single intervals as a darkly shaded region. I can't find a
way to also include in the plot the actual min/max numbers corresponding
to the shingle's intervals. is that possible?

regards

-- 
Murad Nayal M.D. Ph.D.
Department of Biochemistry and Molecular Biophysics
College of Physicians and Surgeons of Columbia University
630 West 168th Street. New York, NY 10032
Tel: 212-305-6884   Fax: 212-305-6926

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


Re: [R] lattice question

2003-08-29 Thread Deepayan Sarkar

The typical graphical representation for shingles is via plot.shingle, e.g.

a - equal.count(rnorm(100))
plot(a)

I'm not sure how you wish to represent this information inside the histogram 
plot itself, but everything you need should be available inside the strip 
function. For example, 

#
x - rnorm(100)
a - equal.count(rnorm(100))

histogram( ~ x | a, par.strip.text = list(lines = 2),
  strip = function(..., shingle.intervals, 
   which.given, which.panel, strip.names) {
  print(shingle.intervals[which.panel[which.given], ,drop = TRUE])

  strip.default(...,
shingle.intervals = shingle.intervals,
which.given = which.given,
which.panel = which.panel,
strip.names = FALSE)

  ltext(.5, .5, 
 paste(round(shingle.intervals[which.panel[which.given], ,
 drop = TRUE],
 digits = 4), collapse = ,   ))
  })


The width of the strip area is determined by the display, but you can control 
the height with par.strip.text. (Currently, whatever the strip function does 
is clipped to within the strip area, you can override that with a setting 
option in the lattice version that comes with r-devel)

Deepayan

On Friday 29 August 2003 14:37, Murad Nayal wrote:
 Hello,

 I am using lattice to plot histograms of one variable conditioned on
 another continuous variable. for this I am using equal.count on the
 conditioning variable to get the appropriate shingle. I would like to
 have in my plot a representation of the shingle's intervals including
 the min/max values and maybe tick marks. some sort of axis for the
 conditioning variable. while the 'strips' of the lattice plot do
 represent the single intervals as a darkly shaded region. I can't find a
 way to also include in the plot the actual min/max numbers corresponding
 to the shingle's intervals. is that possible?

 regards

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] case weight in mixed model

2003-08-29 Thread tzhou1
Hi,

I have a question about how to do case weight in mixed model using R. Can R do 
this? If so, could you give me some references and examples? I'm looking 
forward to hearing from you.


Thanks a lot!

Tianyue

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help


[R] Cigarettes $20.95 per carton S/H Tax Included

2003-08-29 Thread payless4smokes
NOW AVAILABLE TO THE PUBLIC!!!
http://www.payless4smokes.com
http://www.payless-4-smokes.com
and
http://www.yourcheapsmokes.com

We are happy to announce our new website is now available to the public.

featuring NAME-BRAND cigarettes for only $12.95 - $20.95 per carton.

Delivered right to your front door!!

NOTHING EVER OVER $20.95 TOTAL...Why! would you pay more???
free shipping, duty free, tax free, no membership fees and no hidden 
costs. Nothing to join, No one to sponser, No club fees, No 
affiliate, residual, multi-level CRAP!! 
Just $20.95 taxes and shipping included plain and simple.

over 50 top choices including (but certainly not limited to):  
marlboro  camel  winston  benson  hedges  dunhill  mild 7  rothmans  
salem  pall mall  parliament  silk cut  lm   ms  monte carlo  
phillip morris  winchester  and many many more

If you have any questions be sure to ask we are more than happy to 
answer them.

visit us today:
http://www.payless4smokes.com

http://www.payless-4-smokes.com

http://www.yourcheapsmokes.com

Be sure to tell all your friends how they can enjoy saving money buying 
our cigarettes forward this email to them. 
http://www.payless4smokes.com 
http://www.payless-4-smokes.com
http://www.yourcheapsmokes.com

__
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help