[R] Extract data from edit chart

2005-09-20 Thread Chun-Ying Lee
Dear R users:

I wonder if it is possible to use 
data.frame and edit to show the 
form like:

parameter   upper  lower
   A 
   B
   C
when I type the command edit(abc), assume
the data.frame named abc. And then I want to 
extract the number form it, like abc[1,2] 
which mean the upper level of A, to do something.

The following is my example and the warning messages:
 abc-data.frame(Parameter=c(a,b,c),Lower=c( )
,Upper=c( ))
 par-edit(abc)
then, I key in some number(1,2,3...) and close the console.
Warning messages:
1: added factor levels in 'Lower' in: edit.data.frame(abc) 
2: added factor levels in 'Upper' in: edit.data.frame(abc) 
 par[1,2]
[1] 1
Levels:   1 2 3
How can I fix the warning messages?
And can I just catch the number 1 without the value of Levels: 1 2 3 ?
Please give me some comments about this.
Thank you in advance!!

__
R-help@stat.math.ethz.ch 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] Extract data from edit chart

2005-09-20 Thread Gabor Grothendieck
By specifying space like that you are specifying
that the columns be factors.  If you want them
to be character columns use 

abc - data.frame(Parameter = 1:10, lo = I(), hi = I())

and if you want them to be numeric columns specify something
that is numeric like 0, NaN, Inf, -Inf or something like that, e.g.

abc - data.frame(Parameter = 1:10, lo = 0, hi = 0)

On 9/20/05, Chun-Ying Lee [EMAIL PROTECTED] wrote:
 Dear R users:
 
 I wonder if it is possible to use
 data.frame and edit to show the
 form like:
 
 parameter   upper  lower
   A
   B
   C
 when I type the command edit(abc), assume
 the data.frame named abc. And then I want to
 extract the number form it, like abc[1,2]
 which mean the upper level of A, to do something.
 
 The following is my example and the warning messages:
  abc-data.frame(Parameter=c(a,b,c),Lower=c( )
,Upper=c( ))
  par-edit(abc)
 then, I key in some number(1,2,3...) and close the console.
 Warning messages:
 1: added factor levels in 'Lower' in: edit.data.frame(abc)
 2: added factor levels in 'Upper' in: edit.data.frame(abc)
  par[1,2]
 [1] 1
 Levels:   1 2 3
 How can I fix the warning messages?
 And can I just catch the number 1 without the value of Levels: 1 2 3 ?
 Please give me some comments about this.
 Thank you in advance!!
 
 
 
 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] waveform filtering

2005-09-20 Thread Uwe Ligges
Huntsinger, Reid wrote:

 You should probably have a look at the sound packages for R, tuneR and
 sound, I believe, on http://cran.r-project.org. 
 
 Applying a filter can be done with filter(), but you need to come up with
 filter coefficients. High-pass and low-pass have simple descriptions in
 the Fourier transform space, so you might want to specify the frequency
 response of your filter directly there, then do an inverse Fourier transform
 (fft() in R) to get coefficients. 
 
 The ingredients are all there in R itself; but the packages tuneR and sound

Unfortunately, methods for filtering are neither in sound nor in tuneR 
(yet). Contributions are welcome, of course!

Uwe Ligges


 might have exactly what you want. A book on time series or signal processing
 might be helpful.
 
 Reid Huntsinger
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of tom wright
 Sent: Monday, September 19, 2005 10:36 AM
 To: R-help mailing list
 Subject: [R] waveform filtering
 
 
 I'm not an engineer so I hope I'm using the correct terminology here. I
 have a recorded waveform that I want to apply low and high pass filters
 too, are tehre already R functions existing to do this or am I going to
 have to program my own?
 thanks for any pointers
 tom
 
 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Problem installing packages on Windows

2005-09-20 Thread John Field
I've recently had a series of similar errors trying to install 
packages to R 2.1.1 running under Windows XP.

  utils:::menuInstallLocal()
package 'randomForest' successfully unpacked and MD5 sums checked
updating HTML package descriptions
Warning message:
unable to move temporary installation 'C:\Program 
Files\R\rw2011\library\file25214\randomForest' to 
'C:\PROGRA~1\R\rw2011\library\randomForest'
 

I get the same error if I try directly installing from CRAN or from a 
local zip file.

I've fixed it for some earlier package downloads by reinstalling R 
and packages, but I don't want to have to do that every time.

Any ideas about what the problem is?

Many thanks,
John Field

==
John Field Consulting Pty Ltd
10 High St, Burnside SA 5066
ph: (08) 8332 5294 or 0409 097 586
fax: (08) 8332 1229
email:  [EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] predicting residual expected survival times

2005-09-20 Thread Anne
DeaR-Helpers
Is there an implemented method to predict residual expected survival
times for parametric/Cox PH models ? (I have modelled my data using
the survival library)
I would like to predict for a given subject (with a given profile )
having survived up to time Ts the expected residual surviving time (or
the  residual survival time quantiles)

Thanks a lot
-- 
Anne

__
R-help@stat.math.ethz.ch 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] scale function within a for-loop?

2005-09-20 Thread Frank Schmid
I have a data matrix containing around 180 variables and more than 470
observations for each and no missing values. 
 
Within a for-loop, the first step of calculations is to standardize each
column, such that the mean of each column is zero and the sd is one. The
for-loop starts with a subset of the initial matrix and includes all columns
but only a third of the rows. The loop works itself through the whole
matrix and adds everytimes one row, so in the last loop, the whole data
matrix is used. The standardization within the loop is done using the
scale function. 
 
Now, my problem is that with all the 180 variables, either the for-loop or
the scale function does not work properly, as the resulting matrix after the
standardization does not have the same dimensions anymore as it had before.
The matrix is no longer a 180*470 matrix, but a 180*130 matrix. If, however,
I include only 130 variables instead of 180, the result is correct, the
dimensions are right and each column indeed has mean zero and sd one. 
 
Can anyone please tell me, why this problem appears? Would there be a way
that gives the same result without using a for-loop?
 
Thanks
 
 
 
 

[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Xgird, R, parallel computing

2005-09-20 Thread Christophe Pouzat
Hi,

Can start by checking out these two addresses:

http://adm.wustl.edu/rcluster.php
http://adm.wustl.edu/xgrid.php

Christophe.

Mahdi Osman wrote:

Hi, list,


Sorry if I am bothering you.

I am interested in using xgrid with R for distributed computing. I am using
MacOS X and my R 2.1. 1 is already installed and running. The client
computers are all of the same type and the same version of R has been
installed on them.

We have also set up xgrid on my system and client computers as well.

I am wondering if any one can give me some clues about how I can start using
xgrid with R? Do I need to get some packages? Are there documentations or
examples explainging how to use xgrid with R for parallel computing?


I would be very greatful for  your help and hints


Thanks in advance


Rgards


Mahdi

  



-- 
A Master Carpenter has many tools and is expert with most of them.If you
only know how to use a hammer, every problem starts to look like a nail.
Stay away from that trap.
Richard B Johnson.
--

Christophe Pouzat
Laboratoire de Physiologie Cerebrale
CNRS UMR 8118
UFR biomedicale de l'Universite Paris V
45, rue des Saints Peres
75006 PARIS
France

tel: +33 (0)1 42 86 38 28
fax: +33 (0)1 42 86 38 30
web: www.biomedicale.univ-paris5.fr/physcerv/C_Pouzat.html

__
R-help@stat.math.ethz.ch 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] scale function within a for-loop?

2005-09-20 Thread Petr Pikal
Hi

I maybe mistaken but

scale(your.matrix)

gives you matrix scaled in the way you want.

 apply(scale(as.matrix(kalcin[,3:7])), na.rm=T,2,sd)
vodofe  stroz  l  a  b 
 1  1  1  1  1 
 apply(scale(as.matrix(kalcin[,3:7])), na.rm=T,2,mean)
   vodofe stroz l a b 

 1.990322e-15 -5.025086e-14  8.581765e-14  3.588313e-15 -1.370877e-15 

HTH
Petr


On 20 Sep 2005 at 9:13, Frank Schmid wrote:

 I have a data matrix containing around 180 variables and more than 470
 observations for each and no missing values. 
 
 Within a for-loop, the first step of calculations is to standardize
 each column, such that the mean of each column is zero and the sd is
 one. The for-loop starts with a subset of the initial matrix and
 includes all columns but only a third of the rows. The loop works
 itself through the whole matrix and adds everytimes one row, so in
 the last loop, the whole data matrix is used. The standardization
 within the loop is done using the scale function. 
 
 Now, my problem is that with all the 180 variables, either the
 for-loop or the scale function does not work properly, as the
 resulting matrix after the standardization does not have the same
 dimensions anymore as it had before. The matrix is no longer a 180*470
 matrix, but a 180*130 matrix. If, however, I include only 130
 variables instead of 180, the result is correct, the dimensions are
 right and each column indeed has mean zero and sd one. 
 
 Can anyone please tell me, why this problem appears? Would there be a
 way that gives the same result without using a for-loop?
 
 Thanks
 
 
 
 
 
  [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html

Petr Pikal
[EMAIL PROTECTED]

__
R-help@stat.math.ethz.ch 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] Are least-squares means useful or appropriate?

2005-09-20 Thread Felipe
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi.
My question was just theoric. I was wondering if someone who were using
SAS and R could give me their opinion on the topic. I was trying to use
least-squares means for comparison in R, but then I found some
indications against them, and I wanted to know if they had good basis
(as I told earlier, they were not much detailed).
Greetings.

Felipe

Spencer Graves wrote:
| Estimado Felipe:
|
|   If you provide a very simple example (as suggested in the posting
| guide, www.R-project.org/posting-guide.html), it would allow those of
| use who rarely use SAS to respond.  Try to think of the simplest
| possible toy data set and analysis that shows the difference between the
| SAS answer and the answer you get from a certain R function.  If you
| post something simple of that nature that someone can copy from your
| email into R and try other things in a minute or two, it will likely
| increase the speed and utility of a reply.
|
|   Buena Suerte,
|   spencer graves
|
-BEGIN PGP SIGNATURE-

iEYEARECAAYFAkMvzDEACgkQWtdQtNzjBl6NbgCfTg0hPZaSio9tO1iWrKHZY3Os
wzEAn3jdHwqqaHxG0OT8KR6kBlSZDPLp
=KtTd
-END PGP SIGNATURE-

__
R-help@stat.math.ethz.ch 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] column-binary data

2005-09-20 Thread David Barron

Thanks for the replies.  That's not quite what I meant.  These data are 
multipunched to allow more than one variable to be coded in the same column.  
For example, the first 7 columns of the first card of the data I'm trying to 
read contain the following:

Column   Rows  Description
---
1-5Serial number
6  Card number
7 Y,X  Sex of respondent
7 0-3  Marital status
7 4-9  Occupational status

I happen to know that the actual punches for the first respondent are 
1,1,Y,1,4.

When I use
 ip - readBin(ff,what=raw,n=14,signed=FALSE) 
I get
 08 00 08 00 08 00 08 00 04 00 04 00 24 20
for these seven columns.

When I use raw2bin from package caTools I get:
 binip - raw2bin(ip,integer,size=2)
   888844 8228

Now I can see that the relationship between binary numbers and punches is this:
 
binary  punch  binary punch
-- 
13 2569
22 5128
41 1024   7
80 2048   6
16   X 4096   5
32   Y 8192   4
64 16384
12832768 

I can also see that the binary value for column 7 (8228) is equal to the sum of 
the values for each of the three punches in that column (Y=32 + 1=4 + 4=8192), 
but what I don't get is how I can get R to work out the punches either from the 
raw values or from the binary values.  If anyone can suggest anything I would 
be very, very grateful!

David

-Original Message-
From:   Ted Harding [mailto:[EMAIL PROTECTED]
Sent:   Fri 9/16/2005 14:31
To: E-Mail
Cc: David Barron
Subject:Re: [R] column-binary data
On 16-Sep-05 jim holtman wrote:
 Each card column had 12 rows, so as binary it comes in as 12 bits. The 
 question is does this come as a 16 bit integer, or a string of 12 bits
 that I have to extract from. Either case is not that difficult to do.

Indeed ... as an example of how one could proceed, I deconstruct
my example below (see at end).

 On 9/16/05, Ted Harding [EMAIL PROTECTED] wrote: 
 
 On 16-Sep-05 David Barron wrote:
  I have a number of datasets that are multipunch column-binary
  format.
  Does anyone have any advice on how to read this into R? Thanks.
 
  David
 
 Do you mean something like the old
 
 HOLLERITH PUNCHED CARD BINARY FORMAT?
 1011100110110
 0100011001001
 010100111001100010011
 0010100010101100100101001
 0001000110011100011101011
 01000100111010010101001110001
 01001011010100111010100101101
 
 (here 1 = hole in card, binary representation of 7-bit ASCII
 encoding, high-order bit on top).

#First, construct a vector ASCII consiting of the printable
#characters:

ASCII-c( ,!,\,#,$,%,,',(,),
 *,+,,,-,.,/,0,1,2,3,
 4,5,6,7,8,9,:,;,,=,
 ,?,@,A,B,C,D,E,F,G,
 H,I,J,K,L,M,N,O,P,Q,
 R,S,T,U,V,W,X,Y,Z,[,
 \\,],^,_,`,a,b,c,d,e,
 f,g,h,i,j,k,l,m,n,o,
 p,q,r,s,t,u,v,w,x,y,
 z,{,|,},~)


#Next, a vector of powers of 2:

rad-2^(6:0)


#Read in the data from stdin():

M-t(matrix(as.integer(unlist((strsplit(scan(stdin(),
 what=character),split=,ncol=7))

#(read 7 lines from stdin by copypaste:
#1: 1011100110110
#2: 0100011001001
#3: 010100111001100010011
#4: 0010100010101100100101001
#5: 0001000110011100011101011
#6: 01000100111010010101001110001
#7: 01001011010100111010100101101
#8: 
#Read 7 items

#and convert the columns to ASCII codes:

R-rad%*%M

#and see what you've got:

paste(ASCII[R-31],collapse=)

#[1] HOLLERITH PUNCHED CARD BINARY FORMAT?

The above can be adapted to whatever your binary data represent
and to how they are laid out in the input.

Others may find a slicker way of doing this.

The only fly in the above ointment is that I haven't located
in R a character-vector constant which consists of the printable
ASCII characters, or a function to convert numerical ASCII code
to characters, so I made my own.

Best wishes,
Ted.



E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 16-Sep-05   Time: 22:26:16
-- XFMail --

__
R-help@stat.math.ethz.ch 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] Extended Hypergeometric Distribution

2005-09-20 Thread Martin Maechler
 Narcyz == Narcyz Ghinea [EMAIL PROTECTED]
 on Mon, 19 Sep 2005 12:38:27 +1000 writes:

Narcyz Dear R Users,

Narcyz There exists a non-central hypergeometric
Narcyz distribution function in the (MCMCpack) package, and
Narcyz a hypergeometric distribution function in the
Narcyz (stats) package.

Narcyz Is there a function for sampling from an extended
Narcyz hypergeometric distribution?

what is extended ?
Do you mean extended to include non-central?

__
R-help@stat.math.ethz.ch 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] Teaching R - In front of the computer?

2005-09-20 Thread Christian Hennig
Dear Roland,

I wrote an eight-pages manuscript with basic commands and instructions
to use the help system and gave the students series of many small
exercises. For further concepts such as matrix computations, index
manipulations, coercion, I gave short presentations (15 minutes or so),
again followed by series of exercises including some where they had to
find out about non-introduced stuff. I was available for help (of course
this works with up to 25, but not necessarily with 90 students).
It worked quite well even though it's not exactly a fast way to introduce
a lot of commands...

Christian


On Mon, 19 Sep 2005, John Fox wrote:

 Dear Roland,

 I've taught the use of R to this kind of audience many times. Take a
 look at
 http://socserv.socsci.mcmaster.ca/jfox/Courses/UCLA/index.html for
 materials used in such a workshop, and at
 http://socserv.socsci.mcmaster.ca/jfox/Teaching-with-R.pdf for a
 paper on teaching social statistics with R.

 As others have suggested, using static slides is not a good idea, and
 having at least a live display for the presenter is essential. It also
 helps to have the students sitting at computers and able to try things
 out for themselves. If this is a workshop devoted to R, I'd strongly
 recommend this format.

 On the other hand, if you're teaching R in the context of a more
 general statistics course, you can cover the basics in a hands-on
 workshop and then use the LCD projector to introduce new commands,
 etc., during the course as they're needed. I find that once they've
 acquired the basics, students are able to work more independently.

 I hope this helps,
  John

 On Mon, 19 Sep 2005 15:25:14 +0200
  Rau, Roland [EMAIL PROTECTED] wrote:
  Dear R-Users,
 
  given you have been teaching R to students (grad level, mainly social
  science background, no previous programming experience, 80% know
  SPSS),
  what are your experiences concerning the style of teaching? Do you
  prefer to stand in front of the class like in normal lectures and
  you
  show them slides? Or do you you explain some concept (for example
  things
  like mydata[order(var1, var2),]) and show it directly on the computer
  via beamer/projector and also the students have to enter it on the
  computers in front of them.
 
  Any experiences you can share are highly appreciated.
 
  Thanks,
  Roland
 
  +
  This mail has been sent through the MPI for Demographic
  Rese...{{dropped}}
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html

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

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


*** --- ***
Christian Hennig
University College London, Department of Statistical Science
Gower St., London WC1E 6BT, phone +44 207 679 1698
[EMAIL PROTECTED], www.homepages.ucl.ac.uk/~ucakche

__
R-help@stat.math.ethz.ch 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] Possible bug in lmer nested analysis with factors

2005-09-20 Thread Yan Wong

On 18 Sep 2005, at 16:04, Douglas Bates wrote:

 You are correct that good documentation of the capabilities of lmer
 does not currently exist. lmer is still under active development and
 documentation is spread in several places.  The vignette in the mlmRev
 package explores some of the capabilities of lmer.  Also see the
 examples in that package.

Yes. Thanks for this, and indeed for the development of the package.
I'm currently trying to do GLMMs (binary response), so I thought that
I should learn mixed modelling using a library with these capabilities.


 You are correct that the denominator degrees of freedom associated
 with terms in the fixed effects is different between lme and lmer.
 ...
 Some arguments on
 degrees of freedom can be made for nested grouping factors but the
 question of testing fixed effects terms for models with partially
 crossed grouping factors is difficult.

Would it not be possible to recognise when the model is fully nested,
and make this a special case? I was imagining using lmer as a
replacement for lme, so finding that they differ in this way came
as some surprise. When learning to use a new, relatively undescribed
routine, I usually try to see if I can reproduce known results. This
is where I was coming unstuck when trying to reproduce lme results
using lmer.

I suspect that many people (I know of one other in my group) will use
lmer as a drop-in replacement for lme specifically for its GLMM
capabilities rather than for its partial nesting. I realise, however,
that this might not be your priority.


 This area could be a very fruitful research area for people with
 strong mathematical and implementation skills.

That's not me, I'm afraid. I am only just working through Chapter 1
of your (excellent) mixed effects models in S book.

 There are already some facilities for lmer models such as mcmcsamp and
 simulate which can be used for evaluating the posterior distribution
 of a single coefficient or for a parametric bootstrap of the reference
 distribution of a quantity like the likelihood ratio statistic for a
 hypothesis test.

This, again, is beyond me at the moment. But I do hope that someone
else can respond to the call, especially for textbook as well as
more complex examples of lmer usage.

Best wishes

Yan Wong

__
R-help@stat.math.ethz.ch 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] Possible bug in lmer nested analysis with factors

2005-09-20 Thread Yan Wong

On 18 Sep 2005, at 16:27, Douglas Bates wrote:

 I have a couple of other comments.  You can write the nested grouping
 factors as Sundar did without having to explicitly evaluate the
 interaction term and drop unused levels.  The lmer function, like most
 modeling functions in R, uses the optional argument drop.unused.levels
 = TRUE when creating the model frame.

In other words, the use of b:c in a model formula, where both b and c
are factors, results in an internal call to evalq(b:c)[,drop=T] (or
equivalent), which is treated as a factor in a temporary model data
frame? I know little of the internals to R - that is new to me,
but does make sense for factors.

Thus I could use |a:b and |a:b:c as random terms in lme or lmer, even
though 'a' is a fixed, unnested factor.

Notation like this in the model formula does indeed aid clarity. By the
way, I noticed that in your mlmRev vignette you recommended this as good
practice for lea:school (page 3), but then omitted to do it on page 4.

 John Maindonald has already suggested the use of

  (1|b/c) = (1|b:c) + (1|b)

 as syntactic sugar for the lmer formula and it is a reasonable
 request.

This is, indeed, the behaviour I was expecting.

 Unfortunately, implementing this is not high on my priority
 list at present. (We just made a massive change in the sparse matrix
 implementation in the Matrix package and shaking the bugs out of that
 will take a while.)

All your efforts in these areas are, I'm sure, much appreciated. I'm
certainly very interested in learning to use lmer, and welcome all the
improvements that are being made.

 In any case the general recommendation for nested grouping factors is
 first to ensure that they are stored as factors and then to create the
 sequence of interaction terms.

As a brief aside, I know that some people assume that lme treats random
effects as factors even if they are of a numeric type. It might be worth
doing a check in lmer (and even lme) that random effects are factors,
producing a warning if not. Again, this is a non-vital suggestion, and I
don't wish to take up any more of your time!

Thanks

Yan

__
R-help@stat.math.ethz.ch 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] Teaching R - In front of the computer?

2005-09-20 Thread Rau, Roland
Dear all,

thanks for telling me your experiences how you proceed teaching R. I am 
currently giving a five week course teaching R to 16 graduate-level students 
consisting of 12 sessions à 1.5 hours. Two weeks have passed during that course 
and I was just questioning myself whether my style of teaching in front of 
the students with a running R session (+editor) is the best way of teaching. [1]

But thanks to the replies I got here, I believe this is a better approach than 
teaching in front of the class like in a normal lecture without any live 
display of R.

I especially liked the idea on John Fox Homepage to give code and the students 
have to debug it. 

Thanks again for all your replies.

Best,
Roland



[1] What I usually do is to describe what we want to do. Occasionally I remind 
them of the statistical background on the blackboard. Then I show them how to 
translate it into R. They should enter it as well into R. Then, I am explaining 
to them all the details how the code works and what one has to keep in mind. I 
distribute a script with all the examples and explanations and additional 
exercises (which can be easily done thanks to Friedrich Leisch's 
Sweave/Stangle/... function).

+
This mail has been sent through the MPI for Demographic Rese...{{dropped}}

__
R-help@stat.math.ethz.ch 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] Running glm in batch and exporting results (AIC) to HTML

2005-09-20 Thread Jérôme Lemaître
Dear all,

I'm doing univariate Poisson regressions using the glm and glm.fit
functions. I have 5 independent datasets and each dataset, has one response
variable and more than 20 factors to test.
Currently, I run one regression at a time and manually take notes of the
results in excel to have a quick overview on what is going on in my data. My
poor method is very time-consuming and I was looking for a faster and more
reliable way to do all the regressions.
I'm quite sure that R could do all of this for me but I can't think of a way
to tell it...

What I want R to do is
1) running one regression at a time in a particular dataset.
2) saving results. Here, I'm interested in AIC, Beta coefficient of the
factor, the z value and the p value of the factor
3) formatting results in a table with column names as follow:
factor; beta coefficient; z value; p value; aic
4) exporting the table in a way that I could read it in excel. In that way,
I would repeat the operation for each of the 5 datasets rather than for the
100 regressions.

I hope you could help me with this.
Thanks a lot for your answers.

Jérôme Lemaître
Ph.D. student
Dpt biologie
Université Laval
Québec, Canada

__
R-help@stat.math.ethz.ch 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] Running glm in batch and exporting results (AIC) to HTML

2005-09-20 Thread vincent
see
?write.table
hih

__
R-help@stat.math.ethz.ch 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] waveform filtering

2005-09-20 Thread tom wright
On Mon, 2005-19-09 at 10:36 -0400, tom wright wrote:
 I'm not an engineer so I hope I'm using the correct terminology here. I
 have a recorded waveform that I want to apply low and high pass filters
 too, are tehre already R functions existing to do this or am I going to
 have to program my own?
 thanks for any pointers
 tom
 
Thanks for the answers to this, after a little reading I realised that
what sounded so simple wasnt quite. However chapters 15-18 of
http://www.dspguide.com has been very useful.

__
R-help@stat.math.ethz.ch 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] Change the mirror

2005-09-20 Thread Ronaldo Reis-Jr.
Hi,

Please, change the brazilian mirror http://www.termix.ufv.br/CRAN/ to 
http://www.insecta.ufv.br/CRAN/ in R homepage.

Thanks
ROnaldo
-- 

Se dois homens no mesmo trabalho concordam o tempo todo, um deles é demais. Se 
discordam sem parar, então os dois são dispensáveis

--Darryl F. Zanuck
--
|   // | \\   [***]
|   ( õ   õ )  [Ronaldo Reis Júnior]
|  V  [UFV/DBA-Entomologia]
|/ \   [36570-000 Viçosa - MG  ]
|  /(.''`.)\  [Fone: 31-3899-4007 ]
|  /(: :'  :)\ [EMAIL PROTECTED]]
|/ (`. `'` ) \[ICQ#: 5692561 | LinuxUser#: 205366 ]
|( `-  )   [***]
|  _/   \_Powered by GNU/Debian Woody/Sarge

__
R-help@stat.math.ethz.ch 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] Change the mirror

2005-09-20 Thread Duncan Murdoch
On 9/20/2005 9:24 AM, Ronaldo Reis-Jr. [EMAIL PROTECTED] wrote:
 Hi,
 
 Please, change the brazilian mirror http://www.termix.ufv.br/CRAN/ to 
 http://www.insecta.ufv.br/CRAN/ in R homepage.

Requests like this should go to CRAN (to whom I've cc'd this).  The 
admins there might not see it in R-Help.

Duncan Murdoch

__
R-help@stat.math.ethz.ch 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] Interpretation of csplit from rpart.object

2005-09-20 Thread jmoreira
Dear members of R-list,

I need to reproduce the rules of a decision tree. For that I need to use the
csplit information from the rpart.object. But I cannot uderstand the
information because from my example I get:
 rpart.tree$csplit
  [,1] [,2] [,3] [,4] [,5] [,6] [,7]
 [1,]1331333
 [2,]2331222
 [3,]1331333
 [4,]2331222
 [5,]2331222
 [6,]2132311
 [7,]2332331
 [8,]2331222
 [9,]2132311
[10,]2133222
[11,]2112113
[12,]2331222
[13,]2112311
[14,]2331222
[15,]2132111
[16,]2311222
[17,]2331222
[18,]2132131
[19,]2331222
[20,]2132133
[21,]2312222
[22,]2132111

I don't understand why I have 22 rows (my tree has 21 nodes including the root
node) and 7 columns (I have four explanatory variables: two numerics and two
factors; plus the numeric target variable)

?rpart.object it says:

  csplit: this will be present only if one of the split variables is a
  factor. There is one row for each such split, and column 'i =
  -1' if this level of the factor goes to the left, '+1' if it
  goes to the right, and 0 if that level is not present at this
  node of the tree. For an ordered categorical variable all
  levels are marked as 'R/L',  including levels that are not
  present.

The values I got are quite different.

Can some one give me information on how to deal with that?

Thanks in advance?

Joao Moreira

__
R-help@stat.math.ethz.ch 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] predicting residual expected survival times

2005-09-20 Thread Dieter Menne
Anne anne.piotet at gmail.com writes:

 Is there an implemented method to predict residual expected survival
 times for parametric/Cox PH models ? (I have modelled my data using
 the survival library)
 I would like to predict for a given subject (with a given profile )
 having survived up to time Ts the expected residual surviving time (or
 the  residual survival time quantiles)

What's wrong with documented resid?

 fit - coxph(Surv(start, stop, event) ~ (age + surgery)* transplant,
   data=heart)
 mresid - resid(fit, collapse=heart$id)

Dieter

__
R-help@stat.math.ethz.ch 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] Running glm in batch and exporting results (AIC) to HTML

2005-09-20 Thread Stefano Calza
see

?html

in Hmisc package

HIH
Ste

On Tue, Sep 20, 2005 at 02:56:17PM +0200, [EMAIL PROTECTED] wrote:
vincentsee
vincent?write.table
vincenthih
vincent
vincent__
vincentR-help@stat.math.ethz.ch mailing list
vincenthttps://stat.ethz.ch/mailman/listinfo/r-help
vincentPLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html

__
R-help@stat.math.ethz.ch 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] waveform filtering

2005-09-20 Thread jfontain
Quoting tom wright [EMAIL PROTECTED]:

 On Mon, 2005-19-09 at 10:36 -0400, tom wright wrote:
  I'm not an engineer so I hope I'm using the correct terminology here. I
  have a recorded waveform that I want to apply low and high pass filters
  too, are tehre already R functions existing to do this or am I going to
  have to program my own?
  thanks for any pointers
  tom
 
 Thanks for the answers to this, after a little reading I realised that
 what sounded so simple wasnt quite. However chapters 15-18 of
 http://www.dspguide.com has been very useful.

Maybe you need a more specialized tool, such as FFTW?
I found it by searching on fourier at www.freshmeat.net. Just an idea...


--
Jean-Luc

__
R-help@stat.math.ethz.ch 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] waveform filtering

2005-09-20 Thread Huntsinger, Reid
fftw is a library to do FFTs (fast Fourier transform). It's excellent, but
probably not necessary unless you have lots of long series and you use FFT's
repeatedly (say in an iterative fitting procedure). R's fft() is essentially
instantaneous for most one-shot applications.

Reid Huntsinger

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED]
Sent: Tuesday, September 20, 2005 10:32 AM
To: R-help mailing list
Subject: Re: [R] waveform filtering


Quoting tom wright [EMAIL PROTECTED]:

 On Mon, 2005-19-09 at 10:36 -0400, tom wright wrote:
  I'm not an engineer so I hope I'm using the correct terminology here. I
  have a recorded waveform that I want to apply low and high pass filters
  too, are tehre already R functions existing to do this or am I going to
  have to program my own?
  thanks for any pointers
  tom
 
 Thanks for the answers to this, after a little reading I realised that
 what sounded so simple wasnt quite. However chapters 15-18 of
 http://www.dspguide.com has been very useful.

Maybe you need a more specialized tool, such as FFTW?
I found it by searching on fourier at www.freshmeat.net. Just an idea...


--
Jean-Luc

__
R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Neat way of using R for pivoting?

2005-09-20 Thread BANNISTER, Keith

Hi,

I'd like to use R to do what excel pivot tables do, and plot results.

I've never used R before, and I've managed to do something, but it's quite a
lot of code to do something simple. I can't help but think I'm not Doing it
the R way.

I could be using R for the wrong thing, in which case, please tell me off.

I was hoping something like plot(by(t, factor(t$snr), summary)) would do
something, but it doesn't.

Say my data is (for example)
SNR timeError
4   1.3
4   2.1
4   1.2
6   2.1
6   2.2
6   2.1
8   3.2
8   3.7
8   3.1

I want to produce a plot of SNR vs mean(timeError) with error bars of
magnitude 3 sigma.

here's what I've got so far (without the error bars. I can't do that yet).

I'm sure it's the wrong way to go about this:

*** BEGIN SNIPPET ***

get_stats - function(t) {
cnfac - factor(t$cnset);
mu - as.list(by(t$snr, cnfac, mean));
tvar - as.list(by(t$snr, cnfac, var));
t - list(mu=mu, var=tvar);
}

vn - read.table('vn.csv', sep=',');
vn_stats - get_stats(vn);

vsn - read.table('vsn.csv', sep=',');
vsn_stats - get_stats(vsn);

snrs - as.numeric(names(vn_stats$mu))

matplot(snrs, cbind(vn_stats$mu, vsn_stats$mu));

windows();
matplot(snrs, cbind(vn_stats$var, vsn_stats$var));

*** END SNIPPET ***

Appreciate any helpful hints from the pros.

Cheers!

p.s. We've been having rather a good time around the office recently with
International Talk Like a Pirate Day (www.yarr.org.uk). R fits in very
well: I be usin' Arrrgg for my post processin'.


Keith Bannister

--
Electrical Engineer
Astrium Ltd


This email is for the intended addressee only.
If you have received it in error then you must not use, retain, disseminate or 
otherwise deal with it.
Please notify the sender by return email.
The views of the author may not necessarily constitute the views of EADS 
Astrium Limited.
Nothing in this email shall bind EADS Astrium Limited in any contract or 
obligation.

EADS Astrium Limited, Registered in England and Wales No. 2449259
Registered Office: Gunnels Wood Road, Stevenage, Hertfordshire, SG1 2AS, England

__
R-help@stat.math.ethz.ch 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] Estimate predictor contribution in GAM models

2005-09-20 Thread Yves Magliulo
hi,

i'm using gam() function from package mgcv. 

if G is my gam object, then 
SG=summary(G)
Formula:
y ~ +s(x0, k = 5) + s(x1) + s(x2, k = 3)

Parametric coefficients:
  Estimate  std. err.t ratioPr(|t|)
(Intercept)  3.462e+07  1.965e+05  176.2 2.22e-16

Approximate significance of smooth terms:
   edf chi.sq p-value
 s(x0)  2.858   70.629 1.3129e-07
 s(x1)  8.922   390.39 2.6545e-13
 s(x2)  1.571141.6 1.8150e-11

R-sq.(adj) =  0.955   Deviance explained =   97%
GCV score = 2.4081e+12   Scale est. = 1.5441e+12  n = 40
--

I know i can estimate the significance of smooth terms with chi.sq 
p.value. In this example, i now that s(x1) is the most significant
follow by s(x2) and s(x0). also, i know the 3 give a good contribution
in my model and i have a very good model (dev expl = 97%)

=
But how can i estimate numericaly the contribution of each smooth
against the others. In others words, is there a way to quantify this
significance like a percentage of how the model is improved by each of
my predictors? 

I hope it's ~ clear (i'm french!)

thanks.




[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Strange Result using weightedMedian

2005-09-20 Thread Oliver Duerr
Dear all,
I found a strange result using R's weightedMedian function.
Consider the following:

 x - c (0.2, 0.3, 0.5)
 w - c (1,1,2)
 weightedMedian(x,w)
 0.3666

In cases like above, when the weights are integers, one could argue that  
the weighted
median should be the same as the standard median with the elements  
repeated according to their weights. This is trivially true for the mean.
In the example above, we simply double the occurrence of the 0.5 entry

 x1 - c(0.2, 0.3, 0.5, 0.5)
 median(x1)  0.4

Does anyone know the answer to that inconsistency?
It must have to do with the interpolated version.
If you switch of the interpolation you get:
 weightedMedian(x,w,interpolate=FALSE)
 0.4

However, I prefer the interpolated version since it is continuous with  
respect to the weights. Is there a interpolated version of the  
weightedMedian which does not show this inconsistency?


All the best,
  Oliver

__
R-help@stat.math.ethz.ch 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] Course***R/Splus Programming *** 6 cities Nationwide / October 2005

2005-09-20 Thread elvis
XLSolutions Corporation (www.xlsolutions-corp.com) is proud to
announce  2-day R/S-plus Fundamentals and Programming
Techniques in 6 cities.
www.xlsolutions-corp.com/Rfund.htm


 Seattle -- October 24th-25th, 2005
 San Francisco ---  October 27th-28th, 2005

 New York City ---  October 20th-21st, 2005
 Boston -- October 20th-21st, 2005 

 Chicago - October 27th-28th, 2005
 Washington  October 27th-28th, 2005


Ask for our next class in your city.

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, build your own packages (librairies) and connect via
ODBC,etc.
We will perform some statistical modeling 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)
- Connecting; ODBC, Rweb, Orca via sockets and via Rjava

Interested in R/Splus Advanced course? email us.

Email us for group discounts.
Email Sue Turner: [EMAIL PROTECTED]
Phone: 206-686-1578
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]

__
R-help@stat.math.ethz.ch 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] Extended Hypergeometric Distribution

2005-09-20 Thread Albatineh, Ahmed
Do you mean the generalized Hypergeometric distribution ??


*

-Original Message-
From: Martin Maechler [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, September 20, 2005 5:31 AM
To: Narcyz Ghinea
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Extended Hypergeometric Distribution

 Narcyz == Narcyz Ghinea [EMAIL PROTECTED]
 on Mon, 19 Sep 2005 12:38:27 +1000 writes:

Narcyz Dear R Users,

Narcyz There exists a non-central hypergeometric
Narcyz distribution function in the (MCMCpack) package, and
Narcyz a hypergeometric distribution function in the
Narcyz (stats) package.

Narcyz Is there a function for sampling from an extended
Narcyz hypergeometric distribution?

what is extended ?
Do you mean extended to include non-central?

__
R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Neat way of using R for pivoting?

2005-09-20 Thread Greg Snow
 BANNISTER, Keith [EMAIL PROTECTED] 09/20/05
09:46AM 
 
 Hi,
 
 I'd like to use R to do what excel pivot tables do, and plot
results.

R does not have pivot tables and I hope that it never does.

My experiance with pivot tables is that they encourage poor initial
design followed
by non-easily-reproducable post-hoc twiddling.

R encourages proper initial design followed by fixing the core design
in cases
where things don't turn out the way you intended. 
 
In R I prefer to work with script files and save the file.  If the
table or graph
does not turn out the way I intended, then I just edit the script file
and rerun it.
While this may be a little more work than clicking on a pivot table at
first, in the 
long run I find it saves more time.

Consider the situation where you create a table/graph, then a month
later your
boss/client/coworker finds some typos in the original data and needs
the table
and/or graph recreated with the corrected data (or maybe a new dataset
that
needs a similar graph/table).  With the pivot table you need to try and
remember
everything that you clicked on and click on it again.  With the R
script file you 
just fix the data (or load in the new data) and rerun the script and
your done.

OK, enough of my ranting, on to helping with your problem.


 I've never used R before, and I've managed to do something, but it's
quite a
 lot of code to do something simple. I can't help but think I'm not
Doing it
 the R way.
 
 I could be using R for the wrong thing, in which case, please tell
me off.
[snip]

by is a bit of an overkill for this situation, tapply will probably
work better.

try this basic script as a starting place:

### start ###
my.df - data.frame( SNR=rep( c(4,6,8), each=3), 
timeError = c(1.3,2.1,1.2,2.1,2.2,2.1,3.2,3.7,3.1))

tmp.mean - tapply( my.df$timeError, my.df$SNR, mean)
tmp.sd   - tapply( my.df$timeError, my.df$SNR, sd)

tmp.x - unique(my.df$SNR)

plot( tmp.x, tmp.mean,
ylim=range(tmp.mean+3*tmp.sd,tmp.mean-3*tmp.sd),
xlab='SNR',ylab='timeError')

segments(tmp.x, tmp.mean-3*tmp.sd, tmp.x, tmp.mean+3*tmp.sd,
col='green')

### optional
points(tmp.x, tmp.mean+3*tmp.sd, pch='-',cex=3,col='green')
points(tmp.x, tmp.mean-3*tmp.sd, pch='-',cex=3,col='green')
points(tmp.x, tmp.mean)

### end script ###

This may be even simpler with a loaded package. a quick search shows
the following functions (package in parens) that may help:

plotCI(gplots)  Plot Error Bars and Confidence Intervals
errbar(Hmisc)   Plot Error Bars
xYplot(Hmisc)   xyplot and dotplot with Matrix Variables to
Plot Error Bars and Bands

plotCI(plotrix) Plot confidence intervals/error bars

errbar(sfsmisc) Scatter Plot with Error Bars
plotCI(sfsmisc) Plot Confidence Intervals / Error Bars




 Appreciate any helpful hints from the pros.
 

hope this helps,

 Cheers!
 
 p.s. We've been having rather a good time around the office recently
with
 International Talk Like a Pirate Day (www.yarr.org.uk). R fits in
very
 well: I be usin' Arrrgg for my post processin'.
 
 
 Keith Bannister


Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
[EMAIL PROTECTED]
(801) 408-8111

__
R-help@stat.math.ethz.ch 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] Transform variable number of rows per subject to column variables?

2005-09-20 Thread Kevin Bartz
Hey Bing,

Reshape's the ticker -- ?reshape.

For example, reshape(myFrame, idvar = ID, timevar = TEST.A) should
do most of the trick.

Kevin

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Bing Ho
Sent: Monday, September 19, 2005 10:04 PM
To: r-help@stat.math.ethz.ch
Subject: [R] Transform variable number of rows per subject to column
variables?

Hello,

I am very new to R, but I am having trouble with my dataset.

I have a data frame where a subject has a variable number of multiple 
observations for each row, which I wish the transform these 
observations to column variables.

An example of the data frame
ID  TEST.A  TEST.B
1   10  1
1   13  2
1   11  1
2   15  2
2   17  3

And I wish to transform it to the following:
ID  TEST.A1 TEST.A2 TEST.A3 TEST.B1 TEST.B2 TEST.B3
1   10  13  11  1
2   1
2   15  17  NA  2
3   NA

In other words, for the variable number of repeated follow up 
studies, a new column variable for each subject, but they are grouped 
by the original test.

Thank you for any help - I'm realizing that I am a terrible programmer!

Bing Ho

__
R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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 exclude a level from a factor

2005-09-20 Thread Qiong Yang

Hi,

I could not use 'exlcude=' option in factor()
to exclude a level from a existing factor.

x is a factor:

 x
[1] a b c
Levels: a b c

 factor(x,exclude=c)
[1] a b c
Levels: a b c
Warning message:
NAs introduced by coercion

However, c is not coded as NA.

The following does not work either:

 factor(x,exclude=factor(c,levels=c(a,b,c)))
[1] a b c
Levels: a b c


What's wrong with my codes?

Thanks for any help

Qiong Yang

__
R-help@stat.math.ethz.ch 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] Strange Result using weightedMedian

2005-09-20 Thread Dieter Menne
Oliver Duerr Oliver.Duerr at genedata.com writes:

 
 Dear all,
 I found a strange result using R's weightedMedian function


I could not find weightedMedian on CRAN; I know there is such a function in 
some Java lib, googling gave a reference to limma (Linear Models for Microarray 
Data by Gordon Smyth and others).

Best contact the authors about the subject.

Dieter

__
R-help@stat.math.ethz.ch 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] Neat way of using R for pivoting?

2005-09-20 Thread hadley wickham
Hi Keith,

You might want to check out my reshape package
(http://had.co.nz/reshape/) which is very much pivot table inspired. 
I doesn't produce graphics yet, but the output is very amenable to
being fed into existing R graphics function (especially lattice
graphics).

Hadley

__
R-help@stat.math.ethz.ch 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 exclude a level from a factor

2005-09-20 Thread Sundar Dorai-Raj


Qiong Yang wrote:
 Hi,
 
 I could not use 'exlcude=' option in factor()
 to exclude a level from a existing factor.
 
 x is a factor:
 
 
x
 
 [1] a b c
 Levels: a b c
 
 
factor(x,exclude=c)
 
 [1] a b c
 Levels: a b c
 Warning message:
 NAs introduced by coercion
 
 However, c is not coded as NA.
 
 The following does not work either:
 
 
factor(x,exclude=factor(c,levels=c(a,b,c)))
 
 [1] a b c
 Levels: a b c
 
 
 What's wrong with my codes?
 


I think you want:

x - factor(letters[1:3])
factor(as.character(x), exclude = c)

HTH,
--sundar

__
R-help@stat.math.ethz.ch 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] Neat way of using R for pivoting?

2005-09-20 Thread Gabor Grothendieck
On 9/20/05, Greg Snow [EMAIL PROTECTED] wrote:
  BANNISTER, Keith [EMAIL PROTECTED] 09/20/05
 09:46AM 
 
  Hi,
 
  I'd like to use R to do what excel pivot tables do, and plot
 results.
 
 R does not have pivot tables and I hope that it never does.
 
 My experiance with pivot tables is that they encourage poor initial
 design followed
 by non-easily-reproducable post-hoc twiddling.
 
 R encourages proper initial design followed by fixing the core design
 in cases
 where things don't turn out the way you intended.
 
 In R I prefer to work with script files and save the file.  If the
 table or graph
 does not turn out the way I intended, then I just edit the script file
 and rerun it.
 While this may be a little more work than clicking on a pivot table at
 first, in the
 long run I find it saves more time.
 
 Consider the situation where you create a table/graph, then a month
 later your
 boss/client/coworker finds some typos in the original data and needs
 the table
 and/or graph recreated with the corrected data (or maybe a new dataset
 that
 needs a similar graph/table).  With the pivot table you need to try and
 remember
 everything that you clicked on and click on it again.  With the R
 script file you
 just fix the data (or load in the new data) and rerun the script and
 your done.
 
 OK, enough of my ranting, on to helping with your problem.

Just one comment here lest we be arguing against a strawman.
While I agree that reproducibility can be a problem with pivot tables
if created interactively and this applies to just about anything you do
in Excel if done interactively, it should also be realized that Excel is 
completely programmable, like R, using VBA or any language (including R!)
via its COM object interface. 

The fact that Excel has both an interactive interface and a script-based
interface whereas R has only a script-based interface puts it ahead, not 
behind, R in at least some respects.

__
R-help@stat.math.ethz.ch 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 exclude a level from a factor

2005-09-20 Thread Uwe Ligges
Qiong Yang wrote:

 Hi,
 
 I could not use 'exlcude=' option in factor()
 to exclude a level from a existing factor.
 
 x is a factor:
 
 
x
 
 [1] a b c
 Levels: a b c
 
 
factor(x,exclude=c)
 
 [1] a b c
 Levels: a b c
 Warning message:
 NAs introduced by coercion
 
 However, c is not coded as NA.
 
 The following does not work either:
 
 
factor(x,exclude=factor(c,levels=c(a,b,c)))
 
 [1] a b c
 Levels: a b c
 
 
 What's wrong with my codes?


  factor(x, levels=letters[1:2])

Uwe Ligges

 Thanks for any help
 
 Qiong Yang
 
 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] Neat way of using R for pivoting?

2005-09-20 Thread Liaw, Andy
 From: Greg Snow
 
  BANNISTER, Keith [EMAIL PROTECTED] 09/20/05
 09:46AM 
  
  Hi,
  
  I'd like to use R to do what excel pivot tables do, and plot
 results.
 
 R does not have pivot tables and I hope that it never does.
 
 My experiance with pivot tables is that they encourage poor initial
 design followed
 by non-easily-reproducable post-hoc twiddling.
 
 R encourages proper initial design followed by fixing the core design
 in cases
 where things don't turn out the way you intended. 
  
 In R I prefer to work with script files and save the file.  If the
 table or graph
 does not turn out the way I intended, then I just edit the script file
 and rerun it.
 While this may be a little more work than clicking on a pivot table at
 first, in the 
 long run I find it saves more time.

Actually, it's even better to write functions for repetitive tasks.
This is one of the things Martin talked about at useR! 2004:
http://www.ci.tuwien.ac.at/Conferences/useR-2004/Keynotes/Maechler.pdf

For Keith's problem, here's one possibility (using plotCI() from gplots):

myErrorBarPlot - function(SNR, timeError, ...) {
stopifnot(require(gplots))
m - aggregate(timeError, list(SNR), mean)
d - aggregate(timeError, list(SNR), sd)
dat - cbind(m, d[, 2])
names(dat) - c(SNR, mean, sd)
dat$SNR - as.numeric(as.character(dat$SNR))
with(dat, plotCI(SNR, mean, uiw=3*sd, ...))
invisible(dat)
}

vn - read.table(clipboard, header=TRUE)

myErrorBarPlot(vn$SNR, vn$timeError)

Andy
 
 Consider the situation where you create a table/graph, then a month
 later your
 boss/client/coworker finds some typos in the original data and needs
 the table
 and/or graph recreated with the corrected data (or maybe a new dataset
 that
 needs a similar graph/table).  With the pivot table you need 
 to try and
 remember
 everything that you clicked on and click on it again.  With the R
 script file you 
 just fix the data (or load in the new data) and rerun the script and
 your done.
 
 OK, enough of my ranting, on to helping with your problem.
 
 
  I've never used R before, and I've managed to do 
 something, but it's
 quite a
  lot of code to do something simple. I can't help but think I'm not
 Doing it
  the R way.
  
  I could be using R for the wrong thing, in which case, please tell
 me off.
 [snip]
 
 by is a bit of an overkill for this situation, tapply will probably
 work better.
 
 try this basic script as a starting place:
 
 ### start ###
 my.df - data.frame( SNR=rep( c(4,6,8), each=3), 
   timeError = c(1.3,2.1,1.2,2.1,2.2,2.1,3.2,3.7,3.1))
 
 tmp.mean - tapply( my.df$timeError, my.df$SNR, mean)
 tmp.sd   - tapply( my.df$timeError, my.df$SNR, sd)
 
 tmp.x - unique(my.df$SNR)
 
 plot( tmp.x, tmp.mean,
 ylim=range(tmp.mean+3*tmp.sd,tmp.mean-3*tmp.sd),
   xlab='SNR',ylab='timeError')
 
 segments(tmp.x, tmp.mean-3*tmp.sd, tmp.x, tmp.mean+3*tmp.sd,
 col='green')
 
 ### optional
 points(tmp.x, tmp.mean+3*tmp.sd, pch='-',cex=3,col='green')
 points(tmp.x, tmp.mean-3*tmp.sd, pch='-',cex=3,col='green')
 points(tmp.x, tmp.mean)
 
 ### end script ###
 
 This may be even simpler with a loaded package. a quick search shows
 the following functions (package in parens) that may help:
 
 plotCI(gplots)  Plot Error Bars and Confidence Intervals
 errbar(Hmisc)   Plot Error Bars
 xYplot(Hmisc)   xyplot and dotplot with Matrix Variables to
 Plot Error Bars and Bands
 
 plotCI(plotrix) Plot confidence intervals/error bars
 
 errbar(sfsmisc) Scatter Plot with Error Bars
 plotCI(sfsmisc) Plot Confidence Intervals / Error Bars
 
 
 
 
  Appreciate any helpful hints from the pros.
  
 
 hope this helps,
 
  Cheers!
  
  p.s. We've been having rather a good time around the 
 office recently
 with
  International Talk Like a Pirate Day (www.yarr.org.uk). R fits in
 very
  well: I be usin' Arrrgg for my post processin'.
  
  
  Keith Bannister
 
 
 Greg Snow, Ph.D.
 Statistical Data Center, LDS Hospital
 Intermountain Health Care
 [EMAIL PROTECTED]
 (801) 408-8111
 
 __
 R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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 exclude a level from a factor

2005-09-20 Thread Qiong Yang

Problem solved. Thanks a lot for your replies!

 x
[1] a b c
Levels: a b c

 factor(as.character(x),exclude=c)
[1] abNA
Levels: a b

exclude= option may not work on factors.
One has to convert the factor to character first.

Qiong

On Tue, 20 Sep 2005, Sundar Dorai-Raj wrote:



 Qiong Yang wrote:
 Hi,
 
 I could not use 'exlcude=' option in factor()
 to exclude a level from a existing factor.
 
 x is a factor:
 
 
 x
 
 [1] a b c
 Levels: a b c
 
 
 factor(x,exclude=c)
 
 [1] a b c
 Levels: a b c
 Warning message:
 NAs introduced by coercion
 
 However, c is not coded as NA.
 
 The following does not work either:
 
 
 factor(x,exclude=factor(c,levels=c(a,b,c)))
 
 [1] a b c
 Levels: a b c
 
 
 What's wrong with my codes?
 


 I think you want:

 x - factor(letters[1:3])
 factor(as.character(x), exclude = c)

 HTH,
 --sundar


__
R-help@stat.math.ethz.ch 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] Strange Result using weightedMedian

2005-09-20 Thread Oliver Dürr
weightedMedian is in the R.basic packag.
To download see:
See http://www.maths.lth.se/help/R/R.classes/#1.%20Introduction

Best,
  Oliver

__
R-help@stat.math.ethz.ch 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] Strange Result using weightedMedian

2005-09-20 Thread Frank E Harrell Jr
Oliver Duerr wrote:
 Dear all,
 I found a strange result using R's weightedMedian function.
 Consider the following:
 
 
x - c (0.2, 0.3, 0.5)
w - c (1,1,2)
weightedMedian(x,w)
0.3666
 
 
 In cases like above, when the weights are integers, one could argue that  
 the weighted
 median should be the same as the standard median with the elements  
 repeated according to their weights. This is trivially true for the mean.
 In the example above, we simply double the occurrence of the 0.5 entry
 
 
x1 - c(0.2, 0.3, 0.5, 0.5)
median(x1)  0.4
 
 
 Does anyone know the answer to that inconsistency?
 It must have to do with the interpolated version.
 If you switch of the interpolation you get:
 
weightedMedian(x,w,interpolate=FALSE)
0.4
 
 
 However, I prefer the interpolated version since it is continuous with  
 respect to the weights. Is there a interpolated version of the  
 weightedMedian which does not show this inconsistency?
 
 
 All the best,
   Oliver

By the way:

  library(Hmisc)
  wtd.quantile(x,w)
0%   25%   50%   75%  100%
0.200 0.275 0.400 0.500 0.500

Also see the type argument to wtd.quantile

-- 
Frank E Harrell Jr   Professor and Chair   School of Medicine
  Department of Biostatistics   Vanderbilt University

__
R-help@stat.math.ethz.ch 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 estimating parameters with nls

2005-09-20 Thread Uri Iskin
Dear helpeRs,

I have a vector containing values of incomes and I would like to estimate
the three parameters of a Dagum distribution.
Dagum himself recommends to use nonlinear least-squares method.
I have read nls, optim (and the posting guide!) and still have not succeded.

sipcf is my sorted vector of incomes with 3065 obs.
fda is a vector of the empirical cumulative distribution probabilities:
 fda - vector(length=length(sipcf))
 for (I in 1:length(sipcf)){
 fda[i] - sum(sipcf = sipcf[i])/length(sipcf)
 }
fdae is the cdf:
 fdae - function(x){
 fda[sum(sipcf=x)]
}
dagfda is the cdf of Dagum:
 dagfda - function(x,a,b,p){
(1+(x^(-a)*b^a))^(-p)
}

start values I am using: a=1.9 b=0.34 p=1.3

I am trying to get the parameters estimates with nls and optim, but all I
get are errors.
Could you help me showing how to get them?
Thank you in advance!

Uri Iskin

__
R-help@stat.math.ethz.ch 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] Neat way of using R for pivoting?

2005-09-20 Thread Patrick Burns
Gabor Grothendieck wrote:
...

The fact that Excel has both an interactive interface and a script-based
interface whereas R has only a script-based interface puts it ahead, not 
behind, R in at least some respects.
  


Sorry, but I can't resist:  That very much depends on if
you are doing something that is appropriate to be done
in a spreadsheet.  The set of tasks appropriate for R is
very much larger than the set appropriate for Excel.

http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html

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

__
R-help@stat.math.ethz.ch 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] Neat way of using R for pivoting?

2005-09-20 Thread Gabor Grothendieck
On 9/20/05, Patrick Burns [EMAIL PROTECTED] wrote:
 Gabor Grothendieck wrote:
 ...
 
 The fact that Excel has both an interactive interface and a script-based
 interface whereas R has only a script-based interface puts it ahead, not
 behind, R in at least some respects.
 
 
 
 Sorry, but I can't resist:  That very much depends on if
 you are doing something that is appropriate to be done
 in a spreadsheet.  The set of tasks appropriate for R is
 very much larger than the set appropriate for Excel.
 
 http://www.burns-stat.com/pages/Tutor/spreadsheet_addiction.html
 

I certainly don't want to be an apologist for Excel but I would
not asses its domain of applicability to be a subset of that of
R.  I agree with most of the points made in the link you cited 
but its mainly concerned  with stretching the use of spreadsheets 
to situations where R would be better  

At the same time the domain where spreadsheets are appropriate 
and preferable is very large and probably exceeds the domain where R
is preferable to Excel due to the fact that financial, accounting
and budgetary work done by every organization is mostly in the domain
of applicabilty of Excel.  Also I think the link overstates the case,
at least in reference to Excel, since some of the criticisms can
be overcome using Excel's scripting capability.

__
R-help@stat.math.ethz.ch 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] Neat way of using R for pivoting?

2005-09-20 Thread Greg Snow

 Gabor Grothendieck [EMAIL PROTECTED] 09/20/05 11:31AM 
 Just one comment here lest we be arguing against a strawman.
 While I agree that reproducibility can be a problem with pivot
tables
 if created interactively and this applies to just about anything you
do
 in Excel if done interactively, it should also be realized that
Excel is 
 completely programmable, like R, using VBA or any language
(including R!)
 via its COM object interface. 
 
 The fact that Excel has both an interactive interface and a
script-based
 interface whereas R has only a script-based interface puts it ahead,
not 
 behind, R in at least some respects.

Just one comment here lest we be arguing against a strawman.  
R has both interactive and script-based interfaces available and has
for a long time (I remember working with an early port of S in the
1980's on VMS machines which if you used the old Tek10 graphics driver
(anyone else remember the days of printer()...show() and 
tektronics(sp?) dumb terminals?) allowed you to click on a point in 
your graph and have it labelled).

One of the big differences I see between R and Excel is that while
they both have script and gui based interfaces, the gui interfaces
for R (take Rcmdr for example) provide an aid to learning, while
still encouraging the use of command lines, scripts, and functions,
while Excel hides the script interface from all but experts and 
encourages non-reproducable clicking.

Just because a software package has a capability does not mean much if
the overall design promotes the use of a less desirable feature.  I
remember one job where before I came along they were using a
spreedsheet to compute a column of numbers, highlighting and printing
out those numbers, then hand entering these same numbers into a
different spreadsheet.  Dr. Burns has already posted the url that
contains another of my experiances with intelligent people getting
caught in one of Excel's traps (and yes Excel has a feature that would
have prevented the trap, but Excel convieniently hid the need to use
it).



Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
[EMAIL PROTECTED]
(801) 408-8111

__
R-help@stat.math.ethz.ch 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] Neat way of using R for pivoting?

2005-09-20 Thread Gabor Grothendieck
On 9/20/05, Greg Snow [EMAIL PROTECTED] wrote:
 
  Gabor Grothendieck [EMAIL PROTECTED] 09/20/05 11:31AM 
  Just one comment here lest we be arguing against a strawman.
  While I agree that reproducibility can be a problem with pivot
 tables
  if created interactively and this applies to just about anything you
 do
  in Excel if done interactively, it should also be realized that
 Excel is
  completely programmable, like R, using VBA or any language
 (including R!)
  via its COM object interface.
 
  The fact that Excel has both an interactive interface and a
 script-based
  interface whereas R has only a script-based interface puts it ahead,
 not
  behind, R in at least some respects.
 
 Just one comment here lest we be arguing against a strawman.
 R has both interactive and script-based interfaces available and has
 for a long time (I remember working with an early port of S in the
 1980's on VMS machines which if you used the old Tek10 graphics driver
 (anyone else remember the days of printer()...show() and
 tektronics(sp?) dumb terminals?) allowed you to click on a point in
 your graph and have it labelled).

This hardly qualifies to be in any way comparable to Excel's pervasive
all encompassing interactive GUI interface.

 
 One of the big differences I see between R and Excel is that while
 they both have script and gui based interfaces, the gui interfaces
 for R (take Rcmdr for example) provide an aid to learning, while
 still encouraging the use of command lines, scripts, and functions,
 while Excel hides the script interface from all but experts and
 encourages non-reproducable clicking.

Rcmdr is an excellent package but it is restricted to prewritten
sets of functionality.  On the other hand, Excel is completely
general and will allow you to automatically write scripts that
can be massaged based on virtually any interactive operation
using its macro recording facility. 

 
 Just because a software package has a capability does not mean much if
 the overall design promotes the use of a less desirable feature.  I

Maybe you are not really familiar with Excel.  The scripting capability
is very powerful and easier to learn than R.  

 remember one job where before I came along they were using a
 spreedsheet to compute a column of numbers, highlighting and printing
 out those numbers, then hand entering these same numbers into a
 different spreadsheet.  

Excel can produce output in many ways and one can copy and paste
from it too.  This is not a valid criticism of Excel.  Excel is excellent
at interacting with other applications and the operating system.  

 Dr. Burns has already posted the url that
 contains another of my experiances with intelligent people getting
 caught in one of Excel's traps (and yes Excel has a feature that would
 have prevented the trap, but Excel convieniently hid the need to use
 it).

One can get caught in many traps with R too and, in fact, just
about any piece of complex software will have some items that
require experience before you figure out the workarounds.

__
R-help@stat.math.ethz.ch 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] annotating an axis in bwplot (lattice)

2005-09-20 Thread Sebastian Luque
Hi,

I'd like to add, say, the sample size for every group in a bwplot as a
parenthetical annotation to the axis.  Here's a sketch:

--8---cut here---start-8---
require(Hmisc)
age - sample(1:100, 1000, replace = TRUE)
sex - gl(2, 8, 1000, c(Male, Female))
grp - gl(4, 6, 1000, letters[1:4])

bwplot(grp ~ age | sex, aspect = 0.5, box.ratio = 2,
   panel = function(x, y, ...) {
 panel.bpplot(x, y, nout = 0.01, probs = seq(0.05, 0.45, 0.05))
 nage - tapply(age, grp, length)
 panel.text(rep(0, length(x)), seq(along = x), labels = nage)
   })
--8---cut here---end---8---

I have two problems here: 1. place the sample size as a note in
parenthesis next to axis annotation label for the group (e.g. a (252), b
(252), c (250), d (246)), and 2. handle more complex subsetting in the
call to bwplot, i.e. when using the 'data' and 'subset' arguments, so that
'nage' in the code above is more flexible.  I have a feeling the
'subscripts' argument may be useful for the second issue, but I'm not
discovering how.  For the first point, I'll have to play some more with
'scales' argument and its 'at' and 'labels' components.

Any suggestions?

Thanks in advance,


-- 
Sebastian P. Luque

__
R-help@stat.math.ethz.ch 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] Problem with read.spss() and as.data.frame(), or: alternative to subset()?

2005-09-20 Thread Dirk Enzmann
Trying to select a subset of cases (rows of data) I encountered several 
problems:

Firstly, because I did not read the help to read.spss() thoroughly 
enough, I treated the data read as a data frame. For example,

dr2000 - read.spss('myfile.sav')
d - subset(dr2000,RBINZ99  0)

and thus received an error message (Object RBINZ99 not found), because 
dr2000 is not a data.frame but a list (shown by class(dr2000)).

d - subset(dr2000,dr2000$RBINZ99)

didn' help either, because now d is empty (dim = NULL).

Thus, I tried to use the option to.data.frame=T of read.spss():

dr2000 - read.spss('myfile.sav',to.data.frame=T)

However, now R crashes ('R for Windows GUI front-end has found an 
error and must be closed') (the error message is in German).

Finally, I tried again using read.spss() without the option 
'to.data.frame=T' (as before) and tried to convert dr2000 to a data 
frame by using

d - as.data.frame(dr2000)

However, R crashes again (with the same error message).

Of course, I could use SPSS first and save only the cases with RBINZ99  
0, but this is not always possible (all users of the data must have SPSS 
available and we have to use different selection criteria). Is there 
another possibility to solve the problem by using R? I want to select 
certain rows (cases) based on the values of one variable of dr2000, 
but keep all columns (variables) - although dr2000 is not a data frame?

And: R should not crash but rather give a warning.


R version 2.1.1 Patched (2005-07-15)
Package Foreign Version 0.8-10

Operating system: Windows XP Professional (5.1 (Build 2600))
CPU: Pentium Model 2 Stepping 9
RAM: 512 MB

*
Dr. Dirk Enzmann
Institute of Criminal Sciences
Dept. of Criminology
Edmund-Siemers-Allee 1
D-20146 Hamburg
Germany

phone: +49-040-42838.7498 (office)
+49-040-42838.4591 (Billon)
fax:   +49-040-42838.2344
email: [EMAIL PROTECTED]
www: 
http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Enzmann.html

__
R-help@stat.math.ethz.ch 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] Problem with read.spss() and as.data.frame(), or: alternative to subset()? (2)

2005-09-20 Thread Dirk Enzmann
In my previous mail there is a typo. Instead of

d - subset(dr2000,dr2000$RBINZ99)

I used

d - subset(dr2000,dr2000$RBINZ99  0)


*
Dr. Dirk Enzmann
Institute of Criminal Sciences
Dept. of Criminology
Edmund-Siemers-Allee 1
D-20146 Hamburg
Germany

phone: +49-040-42838.7498 (office)
+49-040-42838.4591 (Billon)
fax:   +49-040-42838.2344
email: [EMAIL PROTECTED]
www: 
http://www2.jura.uni-hamburg.de/instkrim/kriminologie/Mitarbeiter/Enzmann/Enzmann.html

__
R-help@stat.math.ethz.ch 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] why this postscript didn't work?

2005-09-20 Thread WWei
Hi, List,

I used the following codes to generate ps plots but foo.ps contains 
nothing. Would someone please point out what is wrong with my codes? 
Thanks a million!

postscript('foo.ps')
par(mfrow=c(2,1))
par(mfg=c(1,1))
hist(rnorm(100),col='blue')
par(mfrow=c(2,2))
par(mfg=c(2,1))
hist(rnorm(50),col='blue')
par(mfg=c(2,2))
hist(rnorm(60),col='blue')
dev.off()

Best,

Auston


Auston Wei
Statistical Analyst
Department of Biostatistics and Applied Mathematics
The University of Texas MD Anderson Cancer Center
Tel: 713-563-4281
Email: [EMAIL PROTECTED]
[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] why this postscript didn't work?

2005-09-20 Thread Marc Schwartz
On Tue, 2005-09-20 at 18:30 -0500, [EMAIL PROTECTED] wrote:
 Hi, List,
 
 I used the following codes to generate ps plots but foo.ps contains 
 nothing. Would someone please point out what is wrong with my codes? 
 Thanks a million!
 
 postscript('foo.ps')
 par(mfrow=c(2,1))
 par(mfg=c(1,1))
 hist(rnorm(100),col='blue')
 par(mfrow=c(2,2))
 par(mfg=c(2,1))
 hist(rnorm(50),col='blue')
 par(mfg=c(2,2))
 hist(rnorm(60),col='blue')
 dev.off()
 
 Best,
 
 Auston

It sort of works here using:

Version 2.1.1 Patched (2005-09-14) on FC4

in that the graphic is drawn, but the output device dimensions are not
appropriate for the plot and the plot is rotated relative to the page.
The page is landscape orientation and the plot is cuttoff on the bottom
(actually right axis) as a result of the rotation.

Your e-mail headers suggest that you are on Windows and you do not
specify which version of R you are running, so there may be some
differences in what you see on your system resulting in problematic
output.

Try this. I am using layout() here and note that your code above can be
replaced by:

postscript(foo.ps, width = 6, height = 6)
layout(matrix(c(1, 1, 2, 3), 2, 2, byrow = TRUE))
hist(rnorm(100),col='blue')
hist(rnorm(50),col='blue')
hist(rnorm(60),col='blue')
dev.off()


Note that I am specifying height and width dimensions for the postscript
output. See if that changes anything on your system. You can of course
modify the dimension arguments as you may require.

Also note that if you want to create an EPS output file, you would need
something like:

postscript(foo.ps, width = 6, height = 6, 
   horizontal = FALSE, onefile = FALSE, paper = special)

See the Details section of ?postscript and also ?layout.

HTH,

Marc Schwartz

__
R-help@stat.math.ethz.ch 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] Searchable mailing list archives -- not reachable FIXED

2005-09-20 Thread Robert King
http://tolstoy.newcastle.edu.au/~rking/R/
is now working again, following a power supply problem that kept it off 
the net.  Unfortunately, even when it is working it is firewalled away 
from pings.

Robert.

Martin Maechler wrote:
 AFAIK, the correct URL --- as also used from CRAN's search page ---
 is
 http://tolstoy.newcastle.edu.au/~rking/R/
 
 However you are both correct that it is not reachable anymore;
 It seems because it's been firewalled off the world :
 
  PING tolstoy.newcastle.edu.au (134.148.237.146) 56(84) bytes of data.
  From newcastle-atm.nswrno.net.au (203.15.123.42) icmp_seq=1 Packet filtered
  From newcastle-atm.nswrno.net.au (203.15.123.42) icmp_seq=14 Packet filtered
  From newcastle-atm.nswrno.net.au (203.15.123.42) icmp_seq=17 Packet filtered
 
 Martin
 
 
Murray == Murray Pung [EMAIL PROTECTED]
on Fri, 16 Sep 2005 15:43:13 +1000 writes:
 
 
 Murray Yes, I've had the same trouble.  Robert may be able
 Murray to sort this out.
 
 Murray -Original Message- From:
 Murray [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
 Murray Sent: Friday, 16 September 2005 3:34 PM To:
 Murray r-help@stat.math.ethz.ch Subject: [R] Searchable
 Murray archives
 
  I cannot access the searchable archives at
  www.tolstoy.newcastle.au/~rking/R.  Does anyone else
  have this problem?
 
  -- Fiona H. Evans
  http://www.cmis.csiro.au/Fiona.Evans

__
R-help@stat.math.ethz.ch 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 estimating parameters with nls

2005-09-20 Thread Francisco J. Zagmutt
RSiteSearch(Dagum)

Francisco


From: Uri Iskin [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject: [R] help with estimating parameters with nls
Date: Tue, 20 Sep 2005 15:44:07 -0300

Dear helpeRs,

I have a vector containing values of incomes and I would like to estimate
the three parameters of a Dagum distribution.
Dagum himself recommends to use nonlinear least-squares method.
I have read nls, optim (and the posting guide!) and still have not 
succeded.

sipcf is my sorted vector of incomes with 3065 obs.
fda is a vector of the empirical cumulative distribution probabilities:
  fda - vector(length=length(sipcf))
  for (I in 1:length(sipcf)){
  fda[i] - sum(sipcf = sipcf[i])/length(sipcf)
  }
fdae is the cdf:
  fdae - function(x){
  fda[sum(sipcf=x)]
}
dagfda is the cdf of Dagum:
  dagfda - function(x,a,b,p){
(1+(x^(-a)*b^a))^(-p)
}

start values I am using: a=1.9 b=0.34 p=1.3

I am trying to get the parameters estimates with nls and optim, but all I
get are errors.
Could you help me showing how to get them?
Thank you in advance!

Uri Iskin

__
R-help@stat.math.ethz.ch 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@stat.math.ethz.ch 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] why this postscript didn't work?

2005-09-20 Thread WWei
Marc,

Thank you very much for your help! Your codes worked perfectly fine here. 
I am using R 2.0.1 on Red Hat 9, sorry for not specifying it in my 
original post. I didn't know we could use layout to plot, it is much 
easier than par(mfg). Thanks a lot!

Best,

Auston







Marc Schwartz [EMAIL PROTECTED]
Sent by: [EMAIL PROTECTED]
09/20/2005 07:20 PM
Please respond to MSchwartz


 

To:
[EMAIL PROTECTED]
cc:
r-help@stat.math.ethz.ch




Subject:
Re: [R] why this postscript didn't work?



On Tue, 2005-09-20 at 18:30 -0500, [EMAIL PROTECTED] wrote:
 Hi, List,
 
 I used the following codes to generate ps plots but foo.ps contains 
 nothing. Would someone please point out what is wrong with my codes? 
 Thanks a million!
 
 postscript('foo.ps')
 par(mfrow=c(2,1))
 par(mfg=c(1,1))
 hist(rnorm(100),col='blue')
 par(mfrow=c(2,2))
 par(mfg=c(2,1))
 hist(rnorm(50),col='blue')
 par(mfg=c(2,2))
 hist(rnorm(60),col='blue')
 dev.off()
 
 Best,
 
 Auston

It sort of works here using:

Version 2.1.1 Patched (2005-09-14) on FC4

in that the graphic is drawn, but the output device dimensions are not
appropriate for the plot and the plot is rotated relative to the page.
The page is landscape orientation and the plot is cuttoff on the bottom
(actually right axis) as a result of the rotation.

Your e-mail headers suggest that you are on Windows and you do not
specify which version of R you are running, so there may be some
differences in what you see on your system resulting in problematic
output.

Try this. I am using layout() here and note that your code above can be
replaced by:

postscript(foo.ps, width = 6, height = 6)
layout(matrix(c(1, 1, 2, 3), 2, 2, byrow = TRUE))
hist(rnorm(100),col='blue')
hist(rnorm(50),col='blue')
hist(rnorm(60),col='blue')
dev.off()


Note that I am specifying height and width dimensions for the postscript
output. See if that changes anything on your system. You can of course
modify the dimension arguments as you may require.

Also note that if you want to create an EPS output file, you would need
something like:

postscript(foo.ps, width = 6, height = 6, 
   horizontal = FALSE, onefile = FALSE, paper = special)

See the Details section of ?postscript and also ?layout.

HTH,

Marc Schwartz

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



[[alternative HTML version deleted]]

__
R-help@stat.math.ethz.ch 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] Seu computador est? infectado com o virus [EMAIL PROTECTED]

2005-09-20 Thread security-check

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