Re: [R] Reshape a sparse matrix

2007-05-16 Thread Martin Maechler
 Scott == Scott Hyde [EMAIL PROTECTED]
 on Tue, 15 May 2007 17:03:13 -1000 (HST) writes:

Scott Hi,

Scott I'd like to reshape a sparse matrix generated from the Matrix 
package.  I can't seem to do it with the command

Scott dim(A) - c(6,9)

Scott which works perfectly with the base package matrices, but with the 
sparse matrices it errors with

Scott Error in dim(A) = c(6, 9) : dim- : invalid first argument

This *does* work in the current version of Matrix (0.99875-1), actually
already in version 0.99875-0 .

In the next version of Matrix, it will not only work, but also
work sparsely internally via the new class sparseVector and
its daughter classes, on which I've been working during the last
10 days or so...
Interesting that you bring the topic up right now ...


Scott Manipulating the Dim attribute of the sparse Matrix does not produce 
the desired effect. [EMAIL PROTECTED] - c(as.integer(9),as.integer(6)) does 
not produce a column ordering result, which I am assuming is because the data 
is stored in a row (i) and column (j) format instead (class dgTMatrix)

You should not have manipulate slots of S4 classes in general.
Some  people say that you should not even access them directly.

Scott Does a function for this exist?

yes, as I said above  dim(.) - ..  works in the newest versions
of Matrix.

Regards,
Martin Maechler, ETH Zurich

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] urca package - summary method -

2007-05-16 Thread lmiceli
Hi

  I am using the package urca and I am interested about the KPSS test.
  That works fine except the method summary did not work in the script,
  only when it is typed direct in the console the results are shown( not a
  source file).

  Is there any problem with these method ?

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] [R-pkgs] new packages 'ICS' and 'ICSNP'

2007-05-16 Thread Klaus Nordhausen
Dear R useRs,

The new contributed packages 'ICS' and 'ICSNP' are available on CRAN.

Descriptions:

The 'ICS' package implements the 2 scatter matrix transformation to 
obtain an invariant coordinate system or independent components, 
depending on the underlying assumptions. The result of the 
transformation is an object of the S4 class ics which is provided by 
this package. Besides generic functions to create and work with ics 
objects the package contains also some scatter matrices and two tests 
for multinormality.


The 'ICSNP' package contains tools for nonparametric multivariate 
analysis, including the estimation of location and shape as well as some 
tests for location and independence. Shape matrices from this package 
can be used as one of the scatter matrices needed in the package ICS 
whereas the tests of this package can be used for testing in the 
framework of invariant coordinates or independent components obtained 
from the package ICS. The parametric Hotelling’s T test serves as a 
reference for the nonparametric location tests.

Suggestions, bug reports and other comments are very welcome.

Best wishes,

Klaus, Seija, Hannu and Dave

-- 
Klaus Nordhausen
Researcher
Tampere School of Public Health
FIN-33014 University of Tampere

phone:  +358 3 3551 7086
fax:+358 3 3551 6057
e-mail: [EMAIL PROTECTED]

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Reshape a sparse matrix

2007-05-16 Thread Scott Hyde

Thanks for the respons, Martin.  The program I wrote works as well for doing 
the reshaping, but it is nice to have it built in.

Is there a way to tell what version of Matrix is installed, and how do we know 
when new releases are issued?  I installed Matrix fairly recently, and thought 
I was up to date.

-Scott

 Original message 
Date: Wed, 16 May 2007 09:32:44 +0200
From: Martin Maechler [EMAIL PROTECTED]  
Subject: Re: [R] Reshape a sparse matrix  
To: Scott Hyde [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch

 Scott == Scott Hyde [EMAIL PROTECTED]
 on Tue, 15 May 2007 17:03:13 -1000 (HST) writes:

Scott Hi,

Scott I'd like to reshape a sparse matrix generated from the Matrix 
 package.  I can't seem to do it with the command

Scott dim(A) - c(6,9)

Scott which works perfectly with the base package matrices, but with the 
 sparse matrices it errors with

Scott Error in dim(A) = c(6, 9) : dim- : invalid first argument

This *does* work in the current version of Matrix (0.99875-1), actually
already in version 0.99875-0 .

In the next version of Matrix, it will not only work, but also
work sparsely internally via the new class sparseVector and
its daughter classes, on which I've been working during the last
10 days or so...
Interesting that you bring the topic up right now ...


Scott Manipulating the Dim attribute of the sparse Matrix does not 
 produce the desired effect. [EMAIL PROTECTED] - 
 c(as.integer(9),as.integer(6)) does not produce a column ordering result, 
 which I am assuming is because the data is stored in a row (i) and column (j) 
 format instead (class dgTMatrix)

You should not have manipulate slots of S4 classes in general.
Some  people say that you should not even access them directly.

Scott Does a function for this exist?

yes, as I said above  dim(.) - ..  works in the newest versions
of Matrix.

Regards,
Martin Maechler, ETH Zurich

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] how to reduce in a grid ?

2007-05-16 Thread Norbert
hi dear R users,
I'm a newbie with R and excuse me if my question is stupid ...  but i've read 
lot of documentation and I don't know how to do.

I have a dataset like

xyvar1var2
241050
3   32070
325068
45   3442
531023
782342
7   32334
[...]

And I need to produce grids like :
y\x]0-2]]2-4]]4-6]]6-8]
]0-3]   
]3-6]means of corresponding values for var1 (or var2)
]6-9]


but I don't find any example 


in advance, lot of thanks for your help

js



  
_

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] use mathematics formula

2007-05-16 Thread elyakhlifi mustapha
hello,
I wanna use some mathematics formula and to do this I tried several way in 
paricular using 
strsplit
textconnection
scan
setdiff
but I think that it's a lil hard
the data frame that I'm working on is as follow

 donCalcara2
   Id_Cara  
Form_C
1  743  if C325=. then 
C743=(C152/C103)*100| else C743=(C152/C325)*100
2  627 if C137=. Then C627=.| else do| if C109=. Then 
C627=(C138/S138)*(100-C137)| else C627=(C138/S138)*C109| end
3  638  
C638 = C103 / S103
4  740  if C325=. then 
C740=(C346/C103)*100| else C740=(C346/C325)*100
5  739 if C155=. then 
C739=(C570/C103)*100| else C739=C155/(C155+C103)*100
6  628  if C325=. then 
C628=(C455/C103)*100| else C628=(C455/C325)*100
7  747if C325=. then 
C747=(C27/C103)*100| else C747=(C27/C325)*100
8  629  if C325=. then 
C629=(C454/C103)*100| else C629=(C454/C325)*100
9  737  if C325=. then 
C737=(C457/C103)*100| else C737=(C457/C325)*100
10 750  if C325=. then 
C750=(C431/C103)*100| else C750=(C431/C325)*100
11 754   if C325=. then 
C754=(C894/C103)*100| else C754=(C894/(C325+C894))*100
12 760  
 C760= C627 / 0.89
13 761  
C761 = C177 * 0.89
14 586  
   if C325=. then C586=(C588/C103)*100
15 896  
   if C325=. then C896=(C895/C103)*100
16 751  if C325=. then 
C751=(C433/C103)*100| else C751=(C433/C325)*100
17 738  if C325=. then 
C738=(C151/C103)*100| else C738=(C151/C325)*100
18 744  
  C744=(C627*C177)/100
19 633  if C325=. then 
C633=(C130/C103)*100| else C633=(C130/C325)*100
20 732  if C325=. then 
C732=(C585/C103)*100| else C732=(C585/C325)*100
21 898  
   if C325=. then C898=(C897/C103)*100

Can you help me please?
I'm French so if you can speak French it's better for me because of my English 
level


  
_ 

[[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
and provide commented, minimal, self-contained, reproducible code.


[R] Filled step-function?

2007-05-16 Thread Beate Kowalczyk

Hello,

I'd like to generate a filled step-function in R as you can see in the 
attachement (image is generated by grapher, but I need a freely 
available alternative). The problem is, that I don't know, how to fill 
it up. My code right now looks like this:


pH - c(0,6.1,6.1,6.3,6.6,7.3,0)
Tiefe - c(0,0,10,40,80,120,10)
plot(pH,Tiefe,type=s,main=Tiefenfunktion pH,ylim=c(120,0),xlim=c(0,23))

Can someone give me an hint how to work on this?

Thanks, Beate

inline: pH.png__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Package versions (was Reshape a sparse matrix)

2007-05-16 Thread Prof Brian Ripley
On Tue, 15 May 2007, Scott Hyde wrote:


 Thanks for the respons, Martin.  The program I wrote works as well for 
 doing the reshaping, but it is nice to have it built in.

 Is there a way to tell what version of Matrix is installed, and how do 
 we know when new releases are issued?  I installed Matrix fairly 
 recently, and thought I was up to date.

library(help=Matrix)  shows you the version.

If you want it programmatically, one way is
packageDescription(Matrix , fields=Version)

update.packages() offers you updates.
(It is possible that the mirror you use has not got 0.99875-1 yet,
especially if this is a binary install, e.g, Windows or MacOS X.  E.g. the 
Windows binary was only built yesterday afternoon.)


 -Scott

  Original message 
 Date: Wed, 16 May 2007 09:32:44 +0200
 From: Martin Maechler [EMAIL PROTECTED]
 Subject: Re: [R] Reshape a sparse matrix
 To: Scott Hyde [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch

 Scott == Scott Hyde [EMAIL PROTECTED]
 on Tue, 15 May 2007 17:03:13 -1000 (HST) writes:

Scott Hi,

Scott I'd like to reshape a sparse matrix generated from the Matrix 
 package.  I can't seem to do it with the command

Scott dim(A) - c(6,9)

Scott which works perfectly with the base package matrices, but with the 
 sparse matrices it errors with

Scott Error in dim(A) = c(6, 9) : dim- : invalid first argument

 This *does* work in the current version of Matrix (0.99875-1), actually
 already in version 0.99875-0 .

 In the next version of Matrix, it will not only work, but also
 work sparsely internally via the new class sparseVector and
 its daughter classes, on which I've been working during the last
 10 days or so...
 Interesting that you bring the topic up right now ...


Scott Manipulating the Dim attribute of the sparse Matrix does not 
 produce the desired effect. [EMAIL PROTECTED] - 
 c(as.integer(9),as.integer(6)) does not produce a column ordering result, 
 which I am assuming is because the data is stored in a row (i) and column 
 (j) format instead (class dgTMatrix)

 You should not have manipulate slots of S4 classes in general.
 Some  people say that you should not even access them directly.

Scott Does a function for this exist?

 yes, as I said above  dim(.) - ..  works in the newest versions
 of Matrix.

 Regards,
 Martin Maechler, ETH Zurich

 __
 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
 and provide commented, minimal, self-contained, reproducible code.


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

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


[R] drop a letter

2007-05-16 Thread elyakhlifi mustapha
hello,
how can I do to drop C from this character  C325  ?


  
_ 

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Filled step-function?

2007-05-16 Thread Petr Klasterecky
Hi,

I am not sure what exactly you would like to fill up and how, but take a 
look at
?polygon
and the examples given there.

hth
Petr


Beate Kowalczyk napsal(a):
 Hello,
 
 I'd like to generate a filled step-function in R as you can see in the 
 attachement (image is generated by grapher, but I need a freely 
 available alternative). The problem is, that I don't know, how to fill 
 it up. My code right now looks like this:
 
 pH - c(0,6.1,6.1,6.3,6.6,7.3,0)
 Tiefe - c(0,0,10,40,80,120,10)
 plot(pH,Tiefe,type=s,main=Tiefenfunktion pH,ylim=c(120,0),xlim=c(0,23))
 
 Can someone give me an hint how to work on this?
 
 Thanks, Beate
 
 
 
 
 
 
 
 __
 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
 and provide commented, minimal, self-contained, reproducible code.

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] drop a letter

2007-05-16 Thread Chuck Cleland
elyakhlifi mustapha wrote:
 hello,
 how can I do to drop C from this character  C325  ?

 x - C325

 substring(x, first=2)
[1] 325

 gsub(C, , x)
[1] 325

 gsub([A-Z], , x)
[1] 325

?substring
?gsub

   
 _ 
 
   [[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
 and provide commented, minimal, self-contained, reproducible code. 

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] drop a letter

2007-05-16 Thread Vladimir Eremeev



elyakhlifi mustapha wrote:
 
 hello,
 how can I do to drop C from this character  C325  ?
 

1. if C is always single and always first:
 substring(C325,2)

2. more generic solution, drops all letters
 sp-unlist(strsplit(C325,split=[A-Z]))
 sp-sp[nchar(sp)0]
 sp
-- 
View this message in context: 
http://www.nabble.com/drop-a-letter-tf3763392.html#a10638376
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lmer function

2007-05-16 Thread Iasonas Lamprianou
Dear all, 
the question was if lmer can estimate the variance components correctly, 
although my design is very UNbalanced.
Also, how do I find the percentage of the variance from every component? Do I 
have to add all the varianc components and then divide each one by the total?

Thanks

P.S. lmer is excellent. It can estimate large datasets where SPSS gives me 
error messages and says it cannot estimate them. Keep on good work friends!
Jason
 
Dr. Iasonas Lamprianou
Department of Education
The University of Manchester
Oxford Road, Manchester M13 9PL, UK
Tel. 0044 161 275 3485
[EMAIL PROTECTED]



- Original Message 
From: Douglas Bates [EMAIL PROTECTED]
To: Steven McKinney [EMAIL PROTECTED]
Cc: Iasonas Lamprianou [EMAIL PROTECTED]; r-help@stat.math.ethz.ch
Sent: Tuesday, 15 May, 2007 2:17:34 AM
Subject: Re: [R] lmer function


On 5/14/07, Steven McKinney [EMAIL PROTECTED] wrote:

 Running lme4 0.9975-13
 I'm still getting the warning

  $ operator not defined for this S4 class, returning NULL in: x$symbolic.cor

It was my mistake.  I fixed the problem in the development sources
long ago but I haven't uploaded a new release since doing so.   I'll
upload a new release next week - this is finals week for us and they
seem to expect that we will do things like grade exams rather than
debugging code. :-)

 Is there a more recent version?
 Is there any known problem with this warning
 (incorrect results etc.) ?

Not really.  It is a benign cut-and-paste error.  If you want to fix
it now look for the function printMer in the source file lme4/R/lmer.R
and change the default for the symbolic.cor argument to FALSE.

  sessionInfo()
 R version 2.5.0 (2007-04-23)
 powerpc-apple-darwin8.9.1

 locale:
 C

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

 other attached packages:
lme4  Matrix lattice
 0.9975-13 0.9975-110.15-4
 

 Steven McKinney

 Statistician
 Molecular Oncology and Breast Cancer Program
 British Columbia Cancer Research Centre

 email: [EMAIL PROTECTED]

 tel: 604-675-8000 x7561

 BCCRC
 Molecular Oncology
 675 West 10th Ave, Floor 4
 Vancouver B.C.
 V5Z 1L3
 Canada




 -Original Message-
 From: [EMAIL PROTECTED] on behalf of Douglas Bates
 Sent: Mon 5/14/2007 12:43 PM
 To: Iasonas Lamprianou
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] lmer function

 On 5/14/07, Iasonas Lamprianou [EMAIL PROTECTED] wrote:
  Does anyone know if the lmer function of lme4 works fine for unbalanced 
  designs? I have the examination results of 1000 pupils on three subjects, 
  one score every term. So, I have three scores for English (one for every 
  term), three scores for maths etc. However, not everybody was examined in 
  maths, not everybody was examined in English etc, but everybody was in 
  effect examined on four subjects. I also have information abouit the 
  school. Would this model hive the right results for the variance components?
 
  mod_3_f  - lmer(SCORE ~ GENDER + (1 |ID ) + (1 | TERM) + (1 | SUBJECT)  , 
  Dataset)
 
  Linear mixed-effects model fit by REML
  Formula: SCORE ~ GENDER + (1 | ID) + (1 | TERM) + (1 | SUBJECT)
 Data: Dataset
  AICBIC  logLik MLdeviance REMLdeviance
   247882 247926 -123936 247871   247872
  Random effects:
   Groups   NameVariance Std.Dev.
   ID   (Intercept) 5.97288  2.44395
   TERM (Intercept) 5.10307  2.25900
   SUBJECT  (Intercept) 0.25943  0.50934
   Residual 4.41673  2.10160
  number of obs: 53978, groups: ID, 5695; TERM, 4; SUBJECT, 4
  Fixed effects:
 Estimate Std. Error t value
  (Intercept)14.303521.15870   12.34
  GENDER[T.Male] -1.017760.06885  -14.78
  Correlation of Fixed Effects:
  Warning in x$symbolic.cor : $ operator not defined for this S4 class, 
  returning NULL

 What version of the lme4 package are you using?  (Use sessionInfo() to
 check.)  I think the bug that causes that warning has been fixed in
 the most recent version.

  (Intr)
  GENDER[T.M] -0.023

  How do I interpert the results?

 Do you really want to treat SUBJECT as a random effect?  I think it
 would be more common to treat it as a fixed effect.  If I understand
 you correctly there are only two levels of SUBJECT and these are
 repeatable levels. If that is the case one could model SUBJECT as a
 fixed effect or consider its interaction within student with the term
 (SUBJECT|ID).

 It would make sense to regard the pair of responses in maths and
 English for each student in each term as a multivariate response but,
 at present, that model cannot be fit with lmer.

 I would also question whether you want the TERM to be modeled with a
 random effect.

 __
 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
 and provide commented, minimal, self-contained, 

Re: [R] use mathematics formula

2007-05-16 Thread hadley wickham
Perhaps you could step back and try and explain to the list what your
overall goal is.  From looking at your code, it looks like you are
trying to take some SAS code and turn it in to the equivalent R code
automatically.  Is that correct?  What is the problem you are trying
to solve?

Hadley

On 5/16/07, elyakhlifi mustapha [EMAIL PROTECTED] wrote:
 hello,
 I wanna use some mathematics formula and to do this I tried several way in 
 paricular using
 strsplit
 textconnection
 scan
 setdiff
 but I think that it's a lil hard
 the data frame that I'm working on is as follow

  donCalcara2
Id_Cara
   Form_C
 1  743  if C325=. then 
 C743=(C152/C103)*100| else C743=(C152/C325)*100
 2  627 if C137=. Then C627=.| else do| if C109=. Then 
 C627=(C138/S138)*(100-C137)| else C627=(C138/S138)*C109| end
 3  638
   C638 = C103 / S103
 4  740  if C325=. then 
 C740=(C346/C103)*100| else C740=(C346/C325)*100
 5  739 if C155=. then 
 C739=(C570/C103)*100| else C739=C155/(C155+C103)*100
 6  628  if C325=. then 
 C628=(C455/C103)*100| else C628=(C455/C325)*100
 7  747if C325=. then 
 C747=(C27/C103)*100| else C747=(C27/C325)*100
 8  629  if C325=. then 
 C629=(C454/C103)*100| else C629=(C454/C325)*100
 9  737  if C325=. then 
 C737=(C457/C103)*100| else C737=(C457/C325)*100
 10 750  if C325=. then 
 C750=(C431/C103)*100| else C750=(C431/C325)*100
 11 754   if C325=. then 
 C754=(C894/C103)*100| else C754=(C894/(C325+C894))*100
 12 760
C760= C627 / 0.89
 13 761
   C761 = C177 * 0.89
 14 586
  if C325=. then C586=(C588/C103)*100
 15 896
  if C325=. then C896=(C895/C103)*100
 16 751  if C325=. then 
 C751=(C433/C103)*100| else C751=(C433/C325)*100
 17 738  if C325=. then 
 C738=(C151/C103)*100| else C738=(C151/C325)*100
 18 744
 C744=(C627*C177)/100
 19 633  if C325=. then 
 C633=(C130/C103)*100| else C633=(C130/C325)*100
 20 732  if C325=. then 
 C732=(C585/C103)*100| else C732=(C585/C325)*100
 21 898
  if C325=. then C898=(C897/C103)*100

 Can you help me please?
 I'm French so if you can speak French it's better for me because of my 
 English level


   
 _

 [[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
 and provide commented, minimal, self-contained, reproducible code.


__
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
and provide commented, minimal, self-contained, reproducible code.


[R] creating different strata

2007-05-16 Thread raymond chiruka
hie 
  l would like to create about ten strata l have tried using
  sample(c(1,2),1,replace=TRUE) but all l get is a vector of 1 and 2 if i 
change it to sample(c(1,10),1,replace=TRUE) it gives me a vector of 1 and 10 
how do l go about it
  
  
   
-

[[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
and provide commented, minimal, self-contained, reproducible code.


[R] converting a data frame to ts objects

2007-05-16 Thread fatih ozgul
Dear R-ians 

I have a data frame like

Person_id  Date/timeCount
-  --  ---
123 20 May 1999  1
123 21 May 1999  3
222 1  Feb 2000  2
222 3  Feb 2000  4

I want to create ts objects for each person_id (i.e. 123 and 222). Time
series frequency can be in months and all starting from the same date (i.e.
May 1999).

Rather than manually creating sum of counts for each month and creating ts
objects manually for each persons,

Is there a function for creating ts objects automatically from such data?

Thanks,

Faith OZGUL

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Running R function as a Batch process

2007-05-16 Thread d. sarthi maheshwari
Hi,

I am struggling with using R CMD BATCH command. Kindly suggest solution to
the following problem.

I have a function named CinC with accept two input parameters. This can be
shown as:

CinC - function(start, end)

where start and end both are character strings.

Please suggest me how can I run this function using command R CMD BATCH.

Currently I am trying to do like this - R CMD BATCH c:/tt/CinC.r
c:/tt/h.Rout -20070416 08:41 -20070416 10:33

What is wrong/incorrect with it?

Your suggestions are important to me. Kindly reply.
Thanks in advance.

Regards
Divya Sarthi

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] creating different strata

2007-05-16 Thread raymond chiruka
sorry all l got the answer thanks
  

raymond chiruka [EMAIL PROTECTED] wrote:  hie 
  l would like to create about ten strata l have tried using
  sample(c(1,2),1,replace=TRUE) but all l get is a vector of 1 and 2 if i  
change it to sample(c(1,10),1,replace=TRUE) it gives me a vector of 1  and 10 
how do l go about it
  
  
   
-

 [[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
and provide commented, minimal, self-contained, reproducible code.


 
-


[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Filled step-function?

2007-05-16 Thread Beate Kowalczyk
Hi Petr,

polygon doesn't work very well, because I need a graphical display for
the laboratory results of my institute. So I have a lot of data in
.csv-format, and I don't really want to define a new polygon for each
dataset, because then I have to do a lot of extra-work. I need a
solution that works like the following, but with coloring the area under
the function (like the image in my first posting):

labdata - read.csv(labdata.csv, header=TRUE)
attach(labdata) #for using column-names as variables
plot(variable1,variable2,type=s,main=Title,ylim=c(120,0),xlim=c(0,10))

For each .csv-dataset I want to use this code with only slight
adjustments...

Tanks again, Beate

Petr Klasterecky schrieb:
 Hi,

 I am not sure what exactly you would like to fill up and how, but take a 
 look at
 ?polygon
 and the examples given there.

 hth
 Petr


 Beate Kowalczyk napsal(a):
   
 Hello,

 I'd like to generate a filled step-function in R as you can see in the 
 attachement (image is generated by grapher, but I need a freely 
 available alternative). The problem is, that I don't know, how to fill 
 it up. My code right now looks like this:

 pH - c(0,6.1,6.1,6.3,6.6,7.3,0)
 Tiefe - c(0,0,10,40,80,120,10)
 plot(pH,Tiefe,type=s,main=Tiefenfunktion pH,ylim=c(120,0),xlim=c(0,23))

 Can someone give me an hint how to work on this?

 Thanks, Beate


 


 

 __
 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
 and provide commented, minimal, self-contained, reproducible code.
 



__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] use mathematics formula

2007-05-16 Thread John Kane
Explicez ce que vous voulez faire et donnez nous une
petite example.

Lisez et suivez les instuctions ici

http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained,
reproducible code.
 
On peut ecrire en anglais et francais.

--- elyakhlifi mustapha [EMAIL PROTECTED]
wrote:

 hello,
 I wanna use some mathematics formula and to do this
 I tried several way in paricular using 
 strsplit
 textconnection
 scan
 setdiff
 but I think that it's a lil hard
 the data frame that I'm working on is as follow
 
  donCalcara2
Id_Cara  
 
   Form_C
 1  743  
if C325=. then C743=(C152/C103)*100| else
 C743=(C152/C325)*100
 2  627 if C137=. Then C627=.| else do| if C109=.
 Then C627=(C138/S138)*(100-C137)| else
 C627=(C138/S138)*C109| end
 3  638  
C638
 = C103 / S103
 4  740  
if C325=. then C740=(C346/C103)*100| else
 C740=(C346/C325)*100
 5  739
 if C155=. then C739=(C570/C103)*100| else
 C739=C155/(C155+C103)*100
 6  628  
if C325=. then C628=(C455/C103)*100| else
 C628=(C455/C325)*100
 7  747  
  if C325=. then C747=(C27/C103)*100| else
 C747=(C27/C325)*100
 8  629  
if C325=. then C629=(C454/C103)*100| else
 C629=(C454/C325)*100
 9  737  
if C325=. then C737=(C457/C103)*100| else
 C737=(C457/C325)*100
 10 750  
if C325=. then C750=(C431/C103)*100| else
 C750=(C431/C325)*100
 11 754   if
 C325=. then C754=(C894/C103)*100| else
 C754=(C894/(C325+C894))*100
 12 760  

 C760= C627 / 0.89
 13 761  
C761
 = C177 * 0.89
 14 586  
   if C325=. then
 C586=(C588/C103)*100
 15 896  
   if C325=. then
 C896=(C895/C103)*100
 16 751  
if C325=. then C751=(C433/C103)*100| else
 C751=(C433/C325)*100
 17 738  
if C325=. then C738=(C151/C103)*100| else
 C738=(C151/C325)*100
 18 744  
 
 C744=(C627*C177)/100
 19 633  
if C325=. then C633=(C130/C103)*100| else
 C633=(C130/C325)*100
 20 732  
if C325=. then C732=(C585/C103)*100| else
 C732=(C585/C325)*100
 21 898  
   if C325=. then
 C898=(C897/C103)*100
 
 Can you help me please?
 I'm French so if you can speak French it's better
 for me because of my English level
 
 
  

_
 
 
   [[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
 and provide commented, minimal, self-contained,
 reproducible code.


__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] creating different strata

2007-05-16 Thread Petr Klasterecky
Something like this?
sample((1:10),100,replace=TRUE)
?sample

hth
Petr

raymond chiruka napsal(a):
 hie 
   l would like to create about ten strata l have tried using
   sample(c(1,2),1,replace=TRUE) but all l get is a vector of 1 and 2 if i 
 change it to sample(c(1,10),1,replace=TRUE) it gives me a vector of 1 and 10 
 how do l go about it
   
   

 -
 
   [[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
 and provide commented, minimal, self-contained, reproducible code.
 

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Running R function as a Batch process

2007-05-16 Thread Vladimir Eremeev



d. sarthi maheshwari wrote:
 
 Hi,
 
 I am struggling with using R CMD BATCH command. Kindly suggest solution to
 the following problem.
 
 I have a function named CinC with accept two input parameters. This can be
 shown as:
 
 CinC - function(start, end)
 
 where start and end both are character strings.
 
 Please suggest me how can I run this function using command R CMD BATCH.
 
 Currently I am trying to do like this - R CMD BATCH c:/tt/CinC.r
 c:/tt/h.Rout -20070416 08:41 -20070416 10:33
 
 What is wrong/incorrect with it?
 

You should use the function commandArgs in your code to retrieve supplied
arguments from the command line.
Look  at
?commandArgs
?Startup

Your R invokation should look like this
C:\ R CMD BATCH c:/tt/CinC.r c:/tt/h.Rout --args 20070416 08:41 20070416
10:33

And you should add something like this in your R code
  command.args-commandArgs(trailingOnly=TRUE)
  CinC(command.args[1],command.args[2])

-- 
View this message in context: 
http://www.nabble.com/Running-R-function-as-a-Batch-process-tf3764048.html#a10640433
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread Andrew Yee
I have the following csv file:

name,x,y,z
category,delta,gamma,epsilon
a,1,2,3
b,4,5,6
c,7,8,9

I'd like to create a numeric matrix of just the numbers in this csv dataset.

I've tried the following program:

sample.data - read.csv(sample.csv)
numerical.data - as.matrix(sample.data[-1,-1])

However, print(numerical.data) returns what appears to be a matrix of
characters:

  x   y   z
2 1 2 3
3 4 5 6
4 7 8 9

How do I force it to be numbers rather than characters?

Thanks,
Andrew

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Filled step-function?

2007-05-16 Thread Petr Klasterecky
Hi,

please reply to the entire list (as a carbon copy) - I do not always 
read this list properly or may not know the solution.

I do not know your data, but there does not seem to be much more work. 
This works well for me with your pH and Tiefe variables:

plot(pH,Tiefe,type=s,main=Tiefenfunktion pH,ylim=c(120,0),xlim=c(0,23))
for (i in (1:(length(pH)-2))){
polygon(x=c(pH[i], pH[i+1], pH[i+1], pH[i]), y=c(Tiefe[i], Tiefe[i], 
max(Tiefe), max(Tiefe)), col=i)
}

or

plot(pH,Tiefe,type=s,main=Tiefenfunktion pH,ylim=c(120,0),xlim=c(0,23))
for (i in (1:(length(pH)-2))){
polygon(x=c(pH[i], pH[i+1], pH[i+1], pH[i]), y=c(Tiefe[i], Tiefe[i], 
Tiefe[i+1], Tiefe[i+1]), col=i)
}

You just need to arrange your coordinates properly.
If your variables are not always named pH and Tiefe, just access them 
directly from the labdata data.frame: you will have labdata[,1] for 
variable1 (here pH) and labdata[,2] for variable2 (Tiefe).

hth
Petr

Beate Kowalczyk napsal(a):
 Hi Peter,
 
 polygon doesn't work very well, because I need a graphical display for 
 the laboratory results of my institute. So I have a lot of data in 
 .csv-format, and I don't really want to define a new polygon for each 
 dataset, because then I have to do a lot of extra-work. I need a 
 solution that works like the following, but with coloring the area under 
 the function (like the image in my first posting):
 
 labdata - read.csv(labdata.csv, header=TRUE)
 attach(labdata) #for using column-names as variables
 plot(variable1,variable2,type=s,main=Title,ylim=c(120,0),xlim=c(0,10))
 
 For each .csv-dataset I want to use this code with only slight 
 adjustments...
 
 Tanks again, Beate
 
 Petr Klasterecky schrieb:
 Hi,

 I am not sure what exactly you would like to fill up and how, but take 
 a look at
 ?polygon
 and the examples given there.

 hth
 Petr


 Beate Kowalczyk napsal(a):
  
 Hello,

 I'd like to generate a filled step-function in R as you can see in 
 the attachement (image is generated by grapher, but I need a freely 
 available alternative). The problem is, that I don't know, how to 
 fill it up. My code right now looks like this:

 pH - c(0,6.1,6.1,6.3,6.6,7.3,0)
 Tiefe - c(0,0,10,40,80,120,10)
 plot(pH,Tiefe,type=s,main=Tiefenfunktion 
 pH,ylim=c(120,0),xlim=c(0,23))

 Can someone give me an hint how to work on this?

 Thanks, Beate


 


 

 __
 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
 and provide commented, minimal, self-contained, reproducible code.
 

   
 
 

-- 
Petr Klasterecky
Dept. of Probability and Statistics
Charles University in Prague
Czech Republic

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread ONKELINX, Thierry
?as.numeric



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

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

 

 -Oorspronkelijk bericht-
 Van: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] Namens Andrew Yee
 Verzonden: woensdag 16 mei 2007 14:11
 Aan: r-help@stat.math.ethz.ch
 Onderwerp: [R] more woes trying to convert a data.frame to a 
 numerical matrix
 
 I have the following csv file:
 
 name,x,y,z
 category,delta,gamma,epsilon
 a,1,2,3
 b,4,5,6
 c,7,8,9
 
 I'd like to create a numeric matrix of just the numbers in 
 this csv dataset.
 
 I've tried the following program:
 
 sample.data - read.csv(sample.csv)
 numerical.data - as.matrix(sample.data[-1,-1])
 
 However, print(numerical.data) returns what appears to be a matrix of
 characters:
 
   x   y   z
 2 1 2 3
 3 4 5 6
 4 7 8 9
 
 How do I force it to be numbers rather than characters?
 
 Thanks,
 Andrew
 
   [[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
 and provide commented, minimal, self-contained, reproducible code.


__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Filled step-function?

2007-05-16 Thread Jim Lemon
Beate Kowalczyk wrote:
 Hello,
 
 I'd like to generate a filled step-function in R as you can see in the 
 attachement (image is generated by grapher, but I need a freely 
 available alternative). The problem is, that I don't know, how to fill 
 it up. My code right now looks like this:
 
 pH - c(0,6.1,6.1,6.3,6.6,7.3,0)
 Tiefe - c(0,0,10,40,80,120,10)
 plot(pH,Tiefe,type=s,main=Tiefenfunktion pH,ylim=c(120,0),xlim=c(0,23))
 
Hi Beate,
If I understand this, you want the steps to be converted into a polygon 
and displayed instead of the plot step display. You also want the y 
axis reversed. This might do what you want:

stepfun.polygon-function(x,y,miny=min(y),col=NULL,...) {
  plot(x,y,ylim=c(max(y),min(y)),type=n,...)
  polyx-c(x[1],rep(x[2:length(x)],each=2),x[1])
  polyy-c(rep(y,each=2))
  polygon(polyx,polyy,col=col)
}

Note that you will probably only want the observed values of x and y, as 
the zeros on the end produce an unwanted spike in the polygon.

Jim

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread Marc Schwartz
On Wed, 2007-05-16 at 08:10 -0400, Andrew Yee wrote:
 I have the following csv file:
 
 name,x,y,z
 category,delta,gamma,epsilon
 a,1,2,3
 b,4,5,6
 c,7,8,9
 
 I'd like to create a numeric matrix of just the numbers in this csv dataset.
 
 I've tried the following program:
 
 sample.data - read.csv(sample.csv)
 numerical.data - as.matrix(sample.data[-1,-1])
 
 However, print(numerical.data) returns what appears to be a matrix of
 characters:
 
   x   y   z
 2 1 2 3
 3 4 5 6
 4 7 8 9
 
 How do I force it to be numbers rather than characters?
 
 Thanks,
 Andrew

The problem is that you have two rows which contain alpha entries. 

The first row is treated as the header, but the second row is treated as
actual data, thus overriding the numeric values in the subsequent rows.

You could use:

  as.numeric(as.matrix(sample.data[-1, -1]))

to coerce the matrix to numeric, or if you don't need the alpha entries,
you could modify the read.csv() call to something like:

  read.csv(sample.csv, header = FALSE, skip = 2, row.names = 1, 
   col.names = c(name, x, y, z)

This will skip the first two rows, set the first column to the row names
and give you a data frame with numeric columns, which in most cases can
be treated as a numeric matrix and/or you could explicitly coerce it to
one.

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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread Dimitris Rizopoulos
have a look at: ?as.numeric() and ?data.matrix().


I hope it helps.

Best,
Dimitris


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

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


- Original Message - 
From: Andrew Yee [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Wednesday, May 16, 2007 2:10 PM
Subject: [R] more woes trying to convert a data.frame to a numerical 
matrix


I have the following csv file:

 name,x,y,z
 category,delta,gamma,epsilon
 a,1,2,3
 b,4,5,6
 c,7,8,9

 I'd like to create a numeric matrix of just the numbers in this csv 
 dataset.

 I've tried the following program:

 sample.data - read.csv(sample.csv)
 numerical.data - as.matrix(sample.data[-1,-1])

 However, print(numerical.data) returns what appears to be a matrix 
 of
 characters:

  x   y   z
 2 1 2 3
 3 4 5 6
 4 7 8 9

 How do I force it to be numbers rather than characters?

 Thanks,
 Andrew

 [[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
 and provide commented, minimal, self-contained, reproducible code.
 


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

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread Andrew Yee
Thanks for the suggestion and the explanation for why I was running into
these troubles.

I've tried:

as.numeric(as.matrix(sample.data[-1, -1]))

However, this creates another vector rather than a matrix.  Is there a
straight forward way to convert this directly into a numeric matrix rather
than a vector?

Additionally, I've also considered:

data.matrix(sample.data[-1,-1]

but bizarrely, it returns:

  x y z
2 1 1 1
3 2 2 2
4 3 3 3

Thanks,
Andrew


On 5/16/07, Marc Schwartz [EMAIL PROTECTED] wrote:

 On Wed, 2007-05-16 at 08:10 -0400, Andrew Yee wrote:
  I have the following csv file:
 
  name,x,y,z
  category,delta,gamma,epsilon
  a,1,2,3
  b,4,5,6
  c,7,8,9
 
  I'd like to create a numeric matrix of just the numbers in this csv
 dataset.
 
  I've tried the following program:
 
  sample.data - read.csv(sample.csv)
  numerical.data - as.matrix(sample.data[-1,-1])
 
  However, print(numerical.data) returns what appears to be a matrix of
  characters:
 
x   y   z
  2 1 2 3
  3 4 5 6
  4 7 8 9
 
  How do I force it to be numbers rather than characters?
 
  Thanks,
  Andrew

 The problem is that you have two rows which contain alpha entries.

 The first row is treated as the header, but the second row is treated as
 actual data, thus overriding the numeric values in the subsequent rows.

 You could use:

   as.numeric(as.matrix(sample.data[-1, -1]))

 to coerce the matrix to numeric, or if you don't need the alpha entries,
 you could modify the read.csv() call to something like:

   read.csv(sample.csv, header = FALSE, skip = 2, row.names = 1,
col.names = c(name, x, y, z)

 This will skip the first two rows, set the first column to the row names
 and give you a data frame with numeric columns, which in most cases can
 be treated as a numeric matrix and/or you could explicitly coerce it to
 one.

 HTH,

 Marc Schwartz




[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Running R function as a Batch process

2007-05-16 Thread Hanke, Alex
Hi,
There are many clues in the help.
First I created the file c:\sumfunction.R

x-as.numeric(commandArgs()[-1:-4] )
print(x)
addtogether-function(x,y){SUM-x+y;print(SUM)}
addtogether(x[1],x[2])

Then at the command line in Windows I enter

R --vanilla --slave --args 7 10 c:\sumfunction.R c:\logout.txt

Regards
Alex

 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of d. sarthi
maheshwari
Sent: May 16, 2007 8:29 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Running R function as a Batch process

Hi,

I am struggling with using R CMD BATCH command. Kindly suggest solution
to the following problem.

I have a function named CinC with accept two input parameters. This can
be shown as:

CinC - function(start, end)

where start and end both are character strings.

Please suggest me how can I run this function using command R CMD BATCH.

Currently I am trying to do like this - R CMD BATCH c:/tt/CinC.r
c:/tt/h.Rout -20070416 08:41 -20070416 10:33

What is wrong/incorrect with it?

Your suggestions are important to me. Kindly reply.
Thanks in advance.

Regards
Divya Sarthi

[[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
and provide commented, minimal, self-contained, reproducible code.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread Marc Schwartz
On Wed, 2007-05-16 at 08:40 -0400, Andrew Yee wrote:
 Thanks for the suggestion and the explanation for why I was running
 into these troubles.
 
 I've tried:
 
 as.numeric(as.matrix(sample.data[-1, -1]))
 
 However, this creates another vector rather than a matrix. 

Right. That's because I'm an idiot and need more caffeine... :-)

  Is there a straight forward way to convert this directly into a
 numeric matrix rather than a vector? 

Yeah, Dimitris' approach below of using data.matrix().

You could also use:

mat - sapply(sample.data[-1, -1], as.numeric)
rownames(mat) - rownames(sample.data[-1, -1])

 mat
  x y z
2 1 1 1
3 2 2 2
4 3 3 3

Though, this is essentially what data.matrix() does internally.

 Additionally, I've also considered:
 
 data.matrix(sample.data[-1,-1]
 
 but bizarrely, it returns:
 
   x y z
 2 1 1 1
 3 2 2 2
 4 3 3 3

That is a numeric matrix:

 str(data.matrix(sample.data[-1, -1]))
 int [1:3, 1:3] 1 2 3 1 2 3 1 2 3
 - attr(*, dimnames)=List of 2
  ..$ : chr [1:3] 2 3 4
  ..$ : chr [1:3] x y z

HTH,

Marc

 
 Thanks,
 Andrew
 
 
 On 5/16/07, Marc Schwartz [EMAIL PROTECTED] wrote:
 On Wed, 2007-05-16 at 08:10 -0400, Andrew Yee wrote:
  I have the following csv file:
 
  name,x,y,z
  category,delta,gamma,epsilon
  a,1,2,3
  b,4,5,6
  c,7,8,9
 
  I'd like to create a numeric matrix of just the numbers in
 this csv dataset. 
 
  I've tried the following program:
 
  sample.data - read.csv(sample.csv)
  numerical.data - as.matrix(sample.data[-1,-1])
 
  However, print(numerical.data ) returns what appears to be a
 matrix of
  characters:
 
x   y   z
  2 1 2 3
  3 4 5 6
  4 7 8 9 
 
  How do I force it to be numbers rather than characters?
 
  Thanks,
  Andrew
 
 The problem is that you have two rows which contain alpha
 entries.
 
 The first row is treated as the header, but the second row is
 treated as 
 actual data, thus overriding the numeric values in the
 subsequent rows.
 
 You could use:
 
   as.numeric(as.matrix(sample.data[-1, -1]))
 
 to coerce the matrix to numeric, or if you don't need the
 alpha entries, 
 you could modify the read.csv() call to something like:
 
   read.csv(sample.csv, header = FALSE, skip = 2, row.names =
 1,
col.names = c(name, x, y, z) 
 
 This will skip the first two rows, set the first column to the
 row names
 and give you a data frame with numeric columns, which in most
 cases can
 be treated as a numeric matrix and/or you could explicitly
 coerce it to 
 one.
 
 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
and provide commented, minimal, self-contained, reproducible code.


[R] Is it possible to pass a Tcl/Tk component as argument to a function

2007-05-16 Thread Hao Liu
hi! All:

I wonder if someone has done this before...

I am writing several functions that conduct statistical analysis using a 
GUI interface by Tcl/Tk, they share many identical GUI components. What 
I am trying to do now is to simplify the code by writing a GUI 
repository for all the components they use, thus save effort for code 
maintenance.

Since they all use:

mainFrame - tkcanvas(top)

--

I wonder if I can write functions that take mainFrame as an argument, 
and call those functions from other place with initialized tkcanvas 
object. I did not see example like this and from my *limited* experience 
with tcltk, I found it always need something to be initialized before 
put to use, that makes me wonder if this idea will work... if it does 
not, any work arounds? like using Macro?

Thanks
Hao

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] converting a data frame to ts objects

2007-05-16 Thread Gabor Grothendieck
On 5/16/07, fatih ozgul [EMAIL PROTECTED] wrote:
 Dear R-ians

 I have a data frame like

 Person_id  Date/timeCount
 -  --  ---
 123 20 May 1999  1
 123 21 May 1999  3
 222 1  Feb 2000  2
 222 3  Feb 2000  4

 I want to create ts objects for each person_id (i.e. 123 and 222). Time
 series frequency can be in months and all starting from the same date (i.e.
 May 1999).

 Rather than manually creating sum of counts for each month and creating ts
 objects manually for each persons,

 Is there a function for creating ts objects automatically from such data?


Try this:

# read in as data frame and fix up date
Lines.raw - Person_id Date/time Count
123 20 May 1999 1
123 21 May 1999 3
222 1 Feb 2000 2
222 3 Feb 2000 4

library(zoo)
DF - read.table(textConnection(Lines.raw), skip = 1,
  col.names = c(Person_id, d, b, Y, Count))
DF$Date.time - as.Date(paste(DF$d, DF$b, DF$Y), %d %b %Y)

# aggregate counts over months, series and convert to ts
f - function(DF) aggregate(zoo(DF$Count), as.yearmon(DF$Date.time), sum)
z - do.call(merge.zoo, lapply(split(DF, DF$Person_id), f))
frequency(z) - 12
as.ts(z)

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread Andrew Yee
Thanks for the suggestion.

However, I've tried sapply and data.matrix.

The problem is that it while it returns a numeric matrix, it gives back:

1 1 1
2 2 2
3 3 3

instead of

1 2 3
4 5 6
7 8 9

The latter matrix is the desired result

Thanks,
Andrew

On 5/16/07, Marc Schwartz [EMAIL PROTECTED] wrote:

 On Wed, 2007-05-16 at 08:40 -0400, Andrew Yee wrote:
  Thanks for the suggestion and the explanation for why I was running
  into these troubles.
 
  I've tried:
 
  as.numeric(as.matrix(sample.data[-1, -1]))
 
  However, this creates another vector rather than a matrix.

 Right. That's because I'm an idiot and need more caffeine... :-)

   Is there a straight forward way to convert this directly into a
  numeric matrix rather than a vector?

 Yeah, Dimitris' approach below of using data.matrix().

 You could also use:

 mat - sapply(sample.data[-1, -1], as.numeric)
 rownames(mat) - rownames(sample.data[-1, -1])

  mat
   x y z
 2 1 1 1
 3 2 2 2
 4 3 3 3

 Though, this is essentially what data.matrix() does internally.

  Additionally, I've also considered:
 
  data.matrix(sample.data[-1,-1]
 
  but bizarrely, it returns:
 
x y z
  2 1 1 1
  3 2 2 2
  4 3 3 3

 That is a numeric matrix:

  str(data.matrix(sample.data[-1, -1]))
 int [1:3, 1:3] 1 2 3 1 2 3 1 2 3
 - attr(*, dimnames)=List of 2
   ..$ : chr [1:3] 2 3 4
   ..$ : chr [1:3] x y z

 HTH,

 Marc

 
  Thanks,
  Andrew
 
 
  On 5/16/07, Marc Schwartz [EMAIL PROTECTED] wrote:
  On Wed, 2007-05-16 at 08:10 -0400, Andrew Yee wrote:
   I have the following csv file:
  
   name,x,y,z
   category,delta,gamma,epsilon
   a,1,2,3
   b,4,5,6
   c,7,8,9
  
   I'd like to create a numeric matrix of just the numbers in
  this csv dataset.
  
   I've tried the following program:
  
   sample.data - read.csv(sample.csv)
   numerical.data - as.matrix(sample.data[-1,-1])
  
   However, print(numerical.data ) returns what appears to be a
  matrix of
   characters:
  
 x   y   z
   2 1 2 3
   3 4 5 6
   4 7 8 9
  
   How do I force it to be numbers rather than characters?
  
   Thanks,
   Andrew
 
  The problem is that you have two rows which contain alpha
  entries.
 
  The first row is treated as the header, but the second row is
  treated as
  actual data, thus overriding the numeric values in the
  subsequent rows.
 
  You could use:
 
as.numeric(as.matrix(sample.data[-1, -1]))
 
  to coerce the matrix to numeric, or if you don't need the
  alpha entries,
  you could modify the read.csv() call to something like:
 
read.csv(sample.csv, header = FALSE, skip = 2, row.names =
  1,
 col.names = c(name, x, y, z)
 
  This will skip the first two rows, set the first column to the
  row names
  and give you a data frame with numeric columns, which in most
  cases can
  be treated as a numeric matrix and/or you could explicitly
  coerce it to
  one.
 
  HTH,
 
  Marc Schwartz
 
 
 



[[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
and provide commented, minimal, self-contained, reproducible code.


[R] effective df in local polinomial regression

2007-05-16 Thread Simone Vantini
Hallo R-users,
I would like to know if there is a way to get the effective degrees 
of freedom in
local polinomial regression. At the moment, to carry out the local 
polinomial regression, I am using the function
locpoly() in library KernSmooth (I need to estimate both the regression 
function and its derivatives, up to the 3rd one).

Thanks,
Simone


-- 
Simone Vantini
MOX - Modeling and Scientific Computing
Dipartimento di Matematica F. Brioschi
Politecnico di Milano
Piazza Leonardo da Vinci, 32
I-20133 Milano (Italy)
tel: +39 02 2399 4604
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Is it possible to pass a Tcl/Tk component as argument to afunction

2007-05-16 Thread John Fox
Dear Hao,

You might take a look at how the Rcmdr package is implemented with many
reusable elements. There is, for example, an initializeDialog function.

I hope this helps,
 John


John Fox, Professor
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Hao Liu
 Sent: Wednesday, May 16, 2007 8:58 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Is it possible to pass a Tcl/Tk component as 
 argument to afunction
 
 hi! All:
 
 I wonder if someone has done this before...
 
 I am writing several functions that conduct statistical 
 analysis using a GUI interface by Tcl/Tk, they share many 
 identical GUI components. What I am trying to do now is to 
 simplify the code by writing a GUI repository for all the 
 components they use, thus save effort for code maintenance.
 
 Since they all use:
 
 mainFrame - tkcanvas(top)
 
 --
 
 I wonder if I can write functions that take mainFrame as an 
 argument, and call those functions from other place with 
 initialized tkcanvas object. I did not see example like this 
 and from my *limited* experience with tcltk, I found it 
 always need something to be initialized before put to use, 
 that makes me wonder if this idea will work... if it does 
 not, any work arounds? like using Macro?
 
 Thanks
 Hao
 
   [[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
 and provide commented, minimal, self-contained, reproducible code.


__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] log rank test p value

2007-05-16 Thread Terry Therneau
The best place to start is
  help(survdiff)
 
That's right -- read the documentation!   
This tells you what is contained in the output to survdiff, namely objects
n, obs, exp, chisq, and var, including descriptions of each.

  The number of degrees of freedom for the chisquare test is (#groups -1);
both the obs and exp objects have one element per group.

Terry Therneau

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread Andrew Yee
Thanks again to everyone for all your help.

I think I've figured out the solution to my dilemma.  Instead of using
data.matrix or sapply, this works for me:

sample.data-read.csv(sample.csv)
sample.matrix.raw-as.matrix(sample.data[-1,-1])
sample.matrix - matrix(as.numeric(sample.matrix.raw),
nrow=attributes(sample.matrix.raw)$dim[1], ncol=attributes(
sample.matrix.raw)$dim[2])

With the above code, I get the desired matrix of:

1 2 3
4 5 6
7 8 9

(I'd like to be able to import the whole csv and then subset the relevant
header and data sections (rather than creating a separate csv for the header
and csv for the data)

Of course, the above code seems kind of clunky, and welcome any suggestions
for improvement.

Thanks,
Andrew


On 5/16/07, Andrew Yee [EMAIL PROTECTED] wrote:

 Thanks for the suggestion.

 However, I've tried sapply and data.matrix.

 The problem is that it while it returns a numeric matrix, it gives back:

 1 1 1
 2 2 2
 3 3 3

 instead of

 1 2 3
 4 5 6
 7 8 9

 The latter matrix is the desired result

 Thanks,
 Andrew

 On 5/16/07, Marc Schwartz  [EMAIL PROTECTED] wrote:
 
  On Wed, 2007-05-16 at 08:40 -0400, Andrew Yee wrote:
   Thanks for the suggestion and the explanation for why I was running
   into these troubles.
  
   I've tried:
  
   as.numeric(as.matrix(sample.data[-1, -1]))
  
   However, this creates another vector rather than a matrix.
 
  Right. That's because I'm an idiot and need more caffeine... :-)
 
Is there a straight forward way to convert this directly into a
   numeric matrix rather than a vector?
 
  Yeah, Dimitris' approach below of using data.matrix().
 
  You could also use:
 
  mat - sapply(sample.data[-1, -1], as.numeric)
  rownames(mat) - rownames(sample.data[-1, -1])
 
   mat
x y z
  2 1 1 1
  3 2 2 2
  4 3 3 3
 
  Though, this is essentially what data.matrix() does internally.
 
   Additionally, I've also considered:
  
   data.matrix(sample.data[-1,-1]
  
   but bizarrely, it returns:
  
 x y z
   2 1 1 1
   3 2 2 2
   4 3 3 3
 
  That is a numeric matrix:
 
   str(data.matrix(sample.data[-1, -1]))
  int [1:3, 1:3] 1 2 3 1 2 3 1 2 3
  - attr(*, dimnames)=List of 2
..$ : chr [1:3] 2 3 4
..$ : chr [1:3] x y z
 
  HTH,
 
  Marc
 
  
   Thanks,
   Andrew
  
  
   On 5/16/07, Marc Schwartz  [EMAIL PROTECTED] wrote:
   On Wed, 2007-05-16 at 08:10 -0400, Andrew Yee wrote:
I have the following csv file:
   
name,x,y,z
category,delta,gamma,epsilon
a,1,2,3
b,4,5,6
c,7,8,9
   
I'd like to create a numeric matrix of just the numbers in
   this csv dataset.
   
I've tried the following program:
   
sample.data - read.csv(sample.csv)
numerical.data - as.matrix (sample.data[-1,-1])
   
However, print(numerical.data ) returns what appears to be a
   matrix of
characters:
   
  x   y   z
2 1 2 3
3 4 5 6
4 7 8 9
   
How do I force it to be numbers rather than characters?
   
Thanks,
Andrew
  
   The problem is that you have two rows which contain alpha
   entries.
  
   The first row is treated as the header, but the second row is
   treated as
   actual data, thus overriding the numeric values in the
   subsequent rows.
  
   You could use:
  
 as.numeric(as.matrix(sample.data [-1, -1]))
  
   to coerce the matrix to numeric, or if you don't need the
   alpha entries,
   you could modify the read.csv() call to something like:
  
 read.csv(sample.csv, header = FALSE, skip = 2, row.names =
   1,
  col.names = c(name, x, y, z)
  
   This will skip the first two rows, set the first column to the
 
   row names
   and give you a data frame with numeric columns, which in most
   cases can
   be treated as a numeric matrix and/or you could explicitly
   coerce it to
   one.
  
   HTH,
  
   Marc Schwartz
  
  
  
 
 


[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Is it possible to pass a Tcl/Tk component as argument to a function

2007-05-16 Thread Duncan Murdoch
On 5/16/2007 8:58 AM, Hao Liu wrote:
 hi! All:
 
 I wonder if someone has done this before...
 
 I am writing several functions that conduct statistical analysis using a 
 GUI interface by Tcl/Tk, they share many identical GUI components. What 
 I am trying to do now is to simplify the code by writing a GUI 
 repository for all the components they use, thus save effort for code 
 maintenance.
 
 Since they all use:
 
 mainFrame - tkcanvas(top)
 
 --
 
 I wonder if I can write functions that take mainFrame as an argument, 
 and call those functions from other place with initialized tkcanvas 
 object. I did not see example like this and from my *limited* experience 
 with tcltk, I found it always need something to be initialized before 
 put to use, that makes me wonder if this idea will work... if it does 
 not, any work arounds? like using Macro?

I think your question is too vague.  Yes, you can pass your mainFrame 
object to a function.  Will it work?  Well, that depends on what you do 
with it.

Could you put together a small example showing the sort of thing you 
want to do?  If it works, then you probably don't need to post a 
question; if it doesn't, someone can probably point out what changes are 
necessary.

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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread Marc Schwartz
On Wed, 2007-05-16 at 09:05 -0400, Andrew Yee wrote:
 Thanks for the suggestion.
 
 However, I've tried sapply and data.matrix.
 
 The problem is that it while it returns a numeric matrix, it gives
 back:
 
 1 1 1
 2 2 2
 3 3 3
 
 instead of
 
 1 2 3 
 4 5 6
 7 8 9
 
 The latter matrix is the desired result
 
 Thanks,
 Andrew

OK.  One more time with gusto...

We need to coerce the values to character first, since they are read in
as factors and the results that we are seeing are the numeric values of
the factor levels and not the numeric values themselves.

Oy...

mat - sapply(sample.data[-1, -1], 
  function(x) as.numeric(as.character(x)))

rownames(mat) - rownames(sample.data[-1, -1])

 mat
  x y z
2 1 2 3
3 4 5 6
4 7 8 9

 str(mat)
 num [1:3, 1:3] 1 4 7 2 5 8 3 6 9
 - attr(*, dimnames)=List of 2
  ..$ : chr [1:3] 2 3 4
  ..$ : chr [1:3] x y z


It looks like data.matrix() does not do the character coercion
internally, so the above approach would seem to be better.

Sorry about that.

Another alternative would be to use the modifications to the read.csv()
function call that I referenced initially and then use the result for
your subsequent manipulations.

Marc

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] partial least regression

2007-05-16 Thread 赵玉忠

hello r-helpers:
there is a .txt file:
x1  x2  x3  x4  x5  x6  x7  x8  x9  x10 
x11 y1
17  5   77  18  19  24  7   24  24  72  
52  100
2   6   72  18  17  15  4   12  18  35  
42  97.2
17  2   58  10  5   3   4   3   3   40  
28  98
17  2   69  14  13  12  4   6   6   50  
37  93
2   3   75  20  38  18  6   12  18  73  
67  99
14  4   59  16  18  9   4   3   15  47  
40  99.95
17  4   87  18  17  12  4   15  12  69  
46  100
14  3   74  15  9   12  1   15  12  44  
35  98
17  6   76  15  33  21  15  9   18  46  
41  100
17  5   76  17  22  18  1   15  9   54  
38  100
20  16  98  23  43  27  27  24  27  87  
67  99.9
20  6   110 25  36  18  7   18  12  99  
88  90
20  6   100 20  19  18  4   15  21  84  
60  99.2
17  6   72  13  31  18  5   21  12  52  
43  95.6
20  15  104 25  53  30  31  30  30  100 
90  99.93
17  13  68  21  42  24  14  18  12  75  
69  99.1
17  8   63  14  18  9   10  15  25  39  
38  95
20  7   88  19  28  18  7   15  24  61  
49  100
20  14  61  18  48  15  11  21  18  48  
48  99.91
20  9   94  22  38  21  13  31  12  84  
80  99.43
17  7   70  16  28  12  18  12  12  52  
38  100
17	6	80	17	46	18	18	24	18	70	69	99.2 


and i write this program:
library(pls)
quality.data-read.table(d:\\work\\12.txt,col.names=c(x1,x2,x3,x4,
x5,x6,x7,x8,x9,x10,x11,y1))
attach(quality.data)
quality.data  #
pairs(cbind(x4,x5,y1))
X-data.frame(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,y1)
Y-data.frame(y1)
quality.simpls-mvr(X,Y,1:11,method=simpls,validation=CV)  #error
happens in this row ,and the error information is about: error in
:eval(expr, envir, enclos) :the length of number'envir' is not 1. 


i don't know how to solve this problem.
who can help me make this program correct,please. thank you very much!

 kenneth

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] partial least regression

2007-05-16 Thread Gabor Grothendieck

Your call to mvr does not correspond to the documentation. See ?mvr
and try this:

Lines - x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 y1
17 5 77 18 19 24 7 24 24 72 52 100
2 6 72 18 17 15 4 12 18 35 42 97.2
17 2 58 10 5 3 4 3 3 40 28 98
17 2 69 14 13 12 4 6 6 50 37 93
2 3 75 20 38 18 6 12 18 73 67 99
14 4 59 16 18 9 4 3 15 47 40 99.95
17 4 87 18 17 12 4 15 12 69 46 100
14 3 74 15 9 12 1 15 12 44 35 98
17 6 76 15 33 21 15 9 18 46 41 100
17 5 76 17 22 18 1 15 9 54 38 100
20 16 98 23 43 27 27 24 27 87 67 99.9
20 6 110 25 36 18 7 18 12 99 88 90
20 6 100 20 19 18 4 15 21 84 60 99.2
17 6 72 13 31 18 5 21 12 52 43 95.6
20 15 104 25 53 30 31 30 30 100 90 99.93
17 13 68 21 42 24 14 18 12 75 69 99.1
17 8 63 14 18 9 10 15 25 39 38 95
20 7 88 19 28 18 7 15 24 61 49 100
20 14 61 18 48 15 11 21 18 48 48 99.91
20 9 94 22 38 21 13 31 12 84 80 99.43
17 7 70 16 28 12 18 12 12 52 38 100
17 6 80 17 46 18 18 24 18 70 69 99.2

library(pls)
quality.data - read.table(textConnection(Lines), header = TRUE)
pairs(quality.data[c(x4, x5, y1)])
quality.simpls - mvr(y1 ~., ncomp = 6, quality.data, method = simpls,
 validation = CV) # replace 6 with whatever you want



On 5/16/07, 赵玉忠 [EMAIL PROTECTED] wrote:

hello r-helpers:
there is a .txt file:
x1  x2  x3  x4  x5  x6  x7  x8  x9  x10 
x11 y1
17  5   77  18  19  24  7   24  24  72  
52  100
2   6   72  18  17  15  4   12  18  35  
42  97.2
17  2   58  10  5   3   4   3   3   40  
28  98
17  2   69  14  13  12  4   6   6   50  
37  93
2   3   75  20  38  18  6   12  18  73  
67  99
14  4   59  16  18  9   4   3   15  47  
40  99.95
17  4   87  18  17  12  4   15  12  69  
46  100
14  3   74  15  9   12  1   15  12  44  
35  98
17  6   76  15  33  21  15  9   18  46  
41  100
17  5   76  17  22  18  1   15  9   54  
38  100
20  16  98  23  43  27  27  24  27  87  
67  99.9
20  6   110 25  36  18  7   18  12  99  
88  90
20  6   100 20  19  18  4   15  21  84  
60  99.2
17  6   72  13  31  18  5   21  12  52  
43  95.6
20  15  104 25  53  30  31  30  30  100 
90  99.93
17  13  68  21  42  24  14  18  12  75  
69  99.1
17  8   63  14  18  9   10  15  25  39  
38  95
20  7   88  19  28  18  7   15  24  61  
49  100
20  14  61  18  48  15  11  21  18  48  
48  99.91
20  9   94  22  38  21  13  31  12  84  
80  99.43
17  7   70  16  28  12  18  12  12  52  
38  100
17  6   80  17  46  18  18  24  18  70  
69  99.2

and i write this program:
library(pls)
quality.data-read.table(d:\\work\\12.txt,col.names=c(x1,x2,x3,x4,
x5,x6,x7,x8,x9,x10,x11,y1))
attach(quality.data)
quality.data  #
pairs(cbind(x4,x5,y1))
X-data.frame(x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,y1)
Y-data.frame(y1)
quality.simpls-mvr(X,Y,1:11,method=simpls,validation=CV)  #error
happens in this row ,and the error information is about: error in
:eval(expr, envir, enclos) :the length of number'envir' is not 1.

i don't know how to solve this problem.
who can help me make this program correct,please. thank you very much!

 kenneth


__
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
and provide commented, minimal, self-contained, reproducible code.




__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Installing SJava - problem

2007-05-16 Thread mister_bluesman

Hi there.

I am trying to install SJava on my windows xp machine.

I downloaded the windows source file SJava_0.69-0.tar.gz from the web site
http://www.omegahat.org/RSJava/

I have folloed the XP command line instructions as directed in the table
underneath the download link:

cd $RHOME/src/library
unzip SJava_0.69-0.zip
cd SJava
./configure.win $RHOME 
cd $RHOME/src/gnuwin32
make pkg-SJava

I reconfigured the configure.win file so that the correct java sdk was
referred to. Not a problem.

However, when I try to type in   make pkg-SJava   i get the following error:

C:\Program Files\R\R-2.5.0\src\gnuwin32make pkg-SJava
'make' is not recognized as an internal or external command,
operable program or batch file.

What do I need to do to rectify this?

Thanks
-- 
View this message in context: 
http://www.nabble.com/Installing-SJava---problem-tf3764923.html#a10642944
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Installing SJava - problem

2007-05-16 Thread Prof Brian Ripley
On Wed, 16 May 2007, mister_bluesman wrote:


 Hi there.

 I am trying to install SJava on my windows xp machine.

 I downloaded the windows source file SJava_0.69-0.tar.gz from the web site
 http://www.omegahat.org/RSJava/

 I have folloed the XP command line instructions as directed in the table
 underneath the download link:

 cd $RHOME/src/library
 unzip SJava_0.69-0.zip
 cd SJava
 ./configure.win $RHOME
 cd $RHOME/src/gnuwin32
 make pkg-SJava

 I reconfigured the configure.win file so that the correct java sdk was
 referred to. Not a problem.

 However, when I try to type in   make pkg-SJava   i get the following error:

 C:\Program Files\R\R-2.5.0\src\gnuwin32make pkg-SJava
 'make' is not recognized as an internal or external command,
 operable program or batch file.

 What do I need to do to rectify this?

Follow the instructions in 'R Installation and Administration' for
building source packages on Windows.

I don't know if SJava is currently buildable on Windows, not least because 
it requires an out-of-date Java (it objects to Java 6 aka 1.6.0), at least 
on Linux (and on x86_64 Linux no earlier Java is viable).

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

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread Liaw, Andy
I think this might be a bit more straight forward:

R mat - do.call(cbind, scan(clipboard, what=list(NULL, 0, 0, 0),
sep=,, skip=2))
Read 3 records
R mat
 [,1] [,2] [,3]
[1,]123
[2,]456
[3,]789

Andy


From: Andrew Yee
 
 Thanks again to everyone for all your help.
 
 I think I've figured out the solution to my dilemma.  Instead of using
 data.matrix or sapply, this works for me:
 
 sample.data-read.csv(sample.csv)
 sample.matrix.raw-as.matrix(sample.data[-1,-1])
 sample.matrix - matrix(as.numeric(sample.matrix.raw),
 nrow=attributes(sample.matrix.raw)$dim[1], ncol=attributes(
 sample.matrix.raw)$dim[2])
 
 With the above code, I get the desired matrix of:
 
 1 2 3
 4 5 6
 7 8 9
 
 (I'd like to be able to import the whole csv and then subset 
 the relevant
 header and data sections (rather than creating a separate csv 
 for the header
 and csv for the data)
 
 Of course, the above code seems kind of clunky, and welcome 
 any suggestions
 for improvement.
 
 Thanks,
 Andrew
 
 
 On 5/16/07, Andrew Yee [EMAIL PROTECTED] wrote:
 
  Thanks for the suggestion.
 
  However, I've tried sapply and data.matrix.
 
  The problem is that it while it returns a numeric matrix, 
 it gives back:
 
  1 1 1
  2 2 2
  3 3 3
 
  instead of
 
  1 2 3
  4 5 6
  7 8 9
 
  The latter matrix is the desired result
 
  Thanks,
  Andrew
 
  On 5/16/07, Marc Schwartz  [EMAIL PROTECTED] wrote:
  
   On Wed, 2007-05-16 at 08:40 -0400, Andrew Yee wrote:
Thanks for the suggestion and the explanation for why I 
 was running
into these troubles.
   
I've tried:
   
as.numeric(as.matrix(sample.data[-1, -1]))
   
However, this creates another vector rather than a matrix.
  
   Right. That's because I'm an idiot and need more caffeine... :-)
  
 Is there a straight forward way to convert this directly into a
numeric matrix rather than a vector?
  
   Yeah, Dimitris' approach below of using data.matrix().
  
   You could also use:
  
   mat - sapply(sample.data[-1, -1], as.numeric)
   rownames(mat) - rownames(sample.data[-1, -1])
  
mat
 x y z
   2 1 1 1
   3 2 2 2
   4 3 3 3
  
   Though, this is essentially what data.matrix() does internally.
  
Additionally, I've also considered:
   
data.matrix(sample.data[-1,-1]
   
but bizarrely, it returns:
   
  x y z
2 1 1 1
3 2 2 2
4 3 3 3
  
   That is a numeric matrix:
  
str(data.matrix(sample.data[-1, -1]))
   int [1:3, 1:3] 1 2 3 1 2 3 1 2 3
   - attr(*, dimnames)=List of 2
 ..$ : chr [1:3] 2 3 4
 ..$ : chr [1:3] x y z
  
   HTH,
  
   Marc
  
   
Thanks,
Andrew
   
   
On 5/16/07, Marc Schwartz  [EMAIL PROTECTED] wrote:
On Wed, 2007-05-16 at 08:10 -0400, Andrew Yee wrote:
 I have the following csv file:

 name,x,y,z
 category,delta,gamma,epsilon
 a,1,2,3
 b,4,5,6
 c,7,8,9

 I'd like to create a numeric matrix of just 
 the numbers in
this csv dataset.

 I've tried the following program:

 sample.data - read.csv(sample.csv)
 numerical.data - as.matrix (sample.data[-1,-1])

 However, print(numerical.data ) returns what 
 appears to be a
matrix of
 characters:

   x   y   z
 2 1 2 3
 3 4 5 6
 4 7 8 9

 How do I force it to be numbers rather than 
 characters?

 Thanks,
 Andrew
   
The problem is that you have two rows which 
 contain alpha
entries.
   
The first row is treated as the header, but the 
 second row is
treated as
actual data, thus overriding the numeric values in the
subsequent rows.
   
You could use:
   
  as.numeric(as.matrix(sample.data [-1, -1]))
   
to coerce the matrix to numeric, or if you 
 don't need the
alpha entries,
you could modify the read.csv() call to something like:
   
  read.csv(sample.csv, header = FALSE, skip = 
 2, row.names =
1,
   col.names = c(name, x, y, z)
   
This will skip the first two rows, set the 
 first column to the
  
row names
and give you a data frame with numeric columns, 
 which in most
cases can
be treated as a numeric matrix and/or you could 
 explicitly
coerce it to
one.
   
HTH,
   
Marc Schwartz
   
   
   
  
  
 
 
   [[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
 and 

Re: [R] Installing SJava - problem

2007-05-16 Thread mister_bluesman

Thank you for your help. Does that mean I am unable to create a java program
that runs on windows and evaluates R expressions within java code?



Prof Brian Ripley wrote:
 
 On Wed, 16 May 2007, mister_bluesman wrote:
 

 Hi there.

 I am trying to install SJava on my windows xp machine.

 I downloaded the windows source file SJava_0.69-0.tar.gz from the web
 site
 http://www.omegahat.org/RSJava/

 I have folloed the XP command line instructions as directed in the table
 underneath the download link:

 cd $RHOME/src/library
 unzip SJava_0.69-0.zip
 cd SJava
 ./configure.win $RHOME
 cd $RHOME/src/gnuwin32
 make pkg-SJava

 I reconfigured the configure.win file so that the correct java sdk was
 referred to. Not a problem.

 However, when I try to type in   make pkg-SJava   i get the following
 error:

 C:\Program Files\R\R-2.5.0\src\gnuwin32make pkg-SJava
 'make' is not recognized as an internal or external command,
 operable program or batch file.

 What do I need to do to rectify this?
 
 Follow the instructions in 'R Installation and Administration' for
 building source packages on Windows.
 
 I don't know if SJava is currently buildable on Windows, not least because 
 it requires an out-of-date Java (it objects to Java 6 aka 1.6.0), at least 
 on Linux (and on x86_64 Linux no earlier Java is viable).
 
 -- 
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595
 
 __
 R-help@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
 and provide commented, minimal, self-contained, reproducible code.
 
 

-- 
View this message in context: 
http://www.nabble.com/Installing-SJava---problem-tf3764923.html#a10644239
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] more woes trying to convert a data.frame to a numerical matrix

2007-05-16 Thread Marc Schwartz
On Wed, 2007-05-16 at 11:29 -0400, Liaw, Andy wrote:
 I think this might be a bit more straight forward:
 
 R mat - do.call(cbind, scan(clipboard, what=list(NULL, 0, 0, 0),
 sep=,, skip=2))
 Read 3 records
 R mat
  [,1] [,2] [,3]
 [1,]123
 [2,]456
 [3,]789
 
 Andy

snip

Good approach Andy and with a large source file should also be faster I
would think.

Regards,

Marc

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] urca package - summary method -

2007-05-16 Thread Pfaff, Bernhard Dr.

Hi

  I am using the package urca and I am interested about the KPSS test.
  That works fine except the method summary did not work in 
the script,
  only when it is typed direct in the console the results are 
shown( not a
  source file).

Hello,

which version of urca are using? The problem you mentioned has been
fixed in November  last last year (see R-Help, there is an extensive
thread about the explicit loading of methods as well as the Changelog of
urca:

2006-11-04  Dr. Bernhard Pfaff  [EMAIL PROTECTED]

* NAMESPACE: import(methods) inserted
).

I have checked again with:

file kpsstest.R
library(urca)
data(nporg)
gnp - na.omit(nporg[, gnp.r])
gnp.l - log(gnp)
kpss.gnp - ur.kpss(gnp.l, type=tau, lags=short)
summary(kpss.gnp)
summary(ur.kpss(gnp.l, type=tau, lags=short))
end file

and

R CMD BATCH --no-restore kpsstest.R

which runs flawlessly. Hence, a simple update of 'urca' should solve
your problem.

Best,
Bernhard


  Is there any problem with these method ?

__
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
and provide commented, minimal, self-contained, reproducible code.

*
Confidentiality Note: The information contained in this mess...{{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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] how to reduce in a grid ?

2007-05-16 Thread Norma Leyva
Try this:

## Dataset
mydata - data.frame(x=sample(1:8,10,replace=T),y=sample(1:9,10,replace=T),
var1=rnorm(10),var2=rnorm(10))
## Put x and y in bins
xcut - cut(mydata$x,seq(0,8,2))
ycut - cut(mydata$y,seq(0,9,3))
## Create table
tapply(mydata$var1,list(ycut,xcut),mean)

- Norma


On 5/16/07, Norbert [EMAIL PROTECTED] wrote:

 hi dear R users,
 I'm a newbie with R and excuse me if my question is stupid ...  but i've
 read lot of documentation and I don't know how to do.

 I have a dataset like

 xyvar1var2
 241050
 3   32070
 325068
 45   3442
 531023
 782342
 7   32334
 [...]

 And I need to produce grids like :
 y\x]0-2]]2-4]]4-6]]6-8]
 ]0-3]
 ]3-6]means of corresponding values for var1 (or var2)
 ]6-9]


 but I don't find any example 


 in advance, lot of thanks for your help

 js




 _

 __
 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
 and provide commented, minimal, self-contained, reproducible code.


[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Installing SJava - problem

2007-05-16 Thread Prof Brian Ripley
On Wed, 16 May 2007, mister_bluesman wrote:


 Thank you for your help. Does that mean I am unable to create a java program
 that runs on windows and evaluates R expressions within java code?

No, because

a) I said 'I don't know': it might work but I thought you ought to be
aware of the issue before doing a lot of work.

b) there are other interfaces, e.g. rJava and friends.




 Prof Brian Ripley wrote:

 On Wed, 16 May 2007, mister_bluesman wrote:


 Hi there.

 I am trying to install SJava on my windows xp machine.

 I downloaded the windows source file SJava_0.69-0.tar.gz from the web
 site
 http://www.omegahat.org/RSJava/

 I have folloed the XP command line instructions as directed in the table
 underneath the download link:

 cd $RHOME/src/library
 unzip SJava_0.69-0.zip
 cd SJava
 ./configure.win $RHOME
 cd $RHOME/src/gnuwin32
 make pkg-SJava

 I reconfigured the configure.win file so that the correct java sdk was
 referred to. Not a problem.

 However, when I try to type in   make pkg-SJava   i get the following
 error:

 C:\Program Files\R\R-2.5.0\src\gnuwin32make pkg-SJava
 'make' is not recognized as an internal or external command,
 operable program or batch file.

 What do I need to do to rectify this?

 Follow the instructions in 'R Installation and Administration' for
 building source packages on Windows.

 I don't know if SJava is currently buildable on Windows, not least because
 it requires an out-of-date Java (it objects to Java 6 aka 1.6.0), at least
 on Linux (and on x86_64 Linux no earlier Java is viable).

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

 __
 R-help@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
 and provide commented, minimal, self-contained, reproducible code.





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

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Installing SJava - problem

2007-05-16 Thread mister_bluesman

Thank you for your help. Does that mean I am unable to create a java program
that runs on windows and evaluates R expressions within java code? 


mister_bluesman wrote:
 
 Hi there.
 
 I am trying to install SJava on my windows xp machine.
 
 I downloaded the windows source file SJava_0.69-0.tar.gz from the web site
 http://www.omegahat.org/RSJava/
 
 I have folloed the XP command line instructions as directed in the table
 underneath the download link:
 
 cd $RHOME/src/library
 unzip SJava_0.69-0.zip
 cd SJava
 ./configure.win $RHOME 
 cd $RHOME/src/gnuwin32
 make pkg-SJava
 
 I reconfigured the configure.win file so that the correct java sdk was
 referred to. Not a problem.
 
 However, when I try to type in   make pkg-SJava   i get the following
 error:
 
 C:\Program Files\R\R-2.5.0\src\gnuwin32make pkg-SJava
 'make' is not recognized as an internal or external command,
 operable program or batch file.
 
 What do I need to do to rectify this?
 
 Thanks
 

-- 
View this message in context: 
http://www.nabble.com/Installing-SJava---problem-tf3764923.html#a10644264
Sent from the R help mailing list archive at Nabble.com.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] substitute x for pattern in a list, while preservign list structure. lapply, gsub, list...?

2007-05-16 Thread new ruser
I am experimenting with some of the common r functions.
I had a question re:using gsub (or some similar functions) on the contents of 
a list.

I want to design a function that looks at everything contained din a list, 
and anytime it finds the text string pattern replace it with x.  I also 
wish to preserve the structure of the original list.  What is a good way to 
accomplish this?

I tried :

a = matrix(data=c(23,45,'red',78),nrow=2)
b = c('red','green',1,2,3)
d = data.frame( test1=c(223,445,'red',78,56) , test2= c('red',NA,NA,NA,NA) )
e= list(a,b,d)
list1 = list(a,b,d,e)

list2 = lapply(list1,function(list)(gsub(red,green,list)))

str(list1)
str(list2)

but the structue fo the list changed.

   
-
Give spam the boot. Take control with tough spam protection

[[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
and provide commented, minimal, self-contained, reproducible code.


[R] Unable to compile Matrix package

2007-05-16 Thread Vittorio De Martino
After upgrading to 2.5.0 under freebsd 6.2 I updated all the add-on packages 
in an R session via update.packages(...). R was unable to install 
the Matrix package because it couldn't find the package.
Therefore I downloaded the *.tar.gz from the CRAN site and issued

R CMD INSTALL Matrix_0.99875-1.tar.gz 
 
but the comilation ended in an error (see the complete attached 
r_log.tar.gz)

cc -std=gnu99 -I/usr/local/lib/R/include -I/usr/local/lib/R/include  
-I/usr/local/include  -D__NO_MATH_INLINES -I../UFc
cc -std=gnu99 -I/usr/local/lib/R/include -I/usr/local/lib/R/include  
-I/usr/local/include  -D__NO_MATH_INLINES -I../UFc
ar -rucs ../COLAMD.a colamd.o colamd_global.oM
( cd Source ; make lib )M
Error expanding embedded variable.M
*** Error code 2M
M
Stop in /tmp/R.INSTALL.IuAhvE/Matrix/src/AMD.M
*** Error code 1M
M
Stop in /tmp/R.INSTALL.IuAhvE/Matrix/src.M
ERROR: compilation failed for package 'Matrix'M
** Removing '/usr/local/lib/R/library/Matrix'M
NbBSD# exitMM
exitM

What shall I do?

Ciao
Vittorio
__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] substitute x for pattern in a list, while preservign list structure. lapply, gsub, list...?

2007-05-16 Thread Marc Schwartz
On Wed, 2007-05-16 at 09:25 -0700, new ruser wrote:
 I am experimenting with some of the common r functions.
 I had a question re:using gsub (or some similar functions) on the
 contents of a list.
 
 I want to design a function that looks at everything contained din a
 list, and anytime it finds the text string pattern replace it with
 x.  I also wish to preserve the structure of the original list.
 What is a good way to accomplish this?
 
 I tried :
 
 a = matrix(data=c(23,45,'red',78),nrow=2)
 b = c('red','green',1,2,3)
 d = data.frame( test1=c(223,445,'red',78,56) , test2=
 c('red',NA,NA,NA,NA) )
 e= list(a,b,d)
 list1 = list(a,b,d,e)
 
 list2 = lapply(list1,function(list)(gsub(red,green,list)))
 
 str(list1)
 str(list2)
 
 but the structue fo the list changed.

I suspect that you will need to use rapply(), which is a recursive
version of lapply().

For example:

 str(list1)
List of 4
 $ : chr [1:2, 1:2] 23 45 red 78
 $ : chr [1:5] red green 1 2 ...
 $ :'data.frame':   5 obs. of  2 variables:
  ..$ test1: Factor w/ 5 levels 223,445,56,..: 1 2 5 4 3
  ..$ test2: Factor w/ 1 level red: 1 NA NA NA NA
 $ :List of 3
  ..$ : chr [1:2, 1:2] 23 45 red 78
  ..$ : chr [1:5] red green 1 2 ...
  ..$ :'data.frame':5 obs. of  2 variables:
  .. ..$ test1: Factor w/ 5 levels 223,445,56,..: 1 2 5 4 3
  .. ..$ test2: Factor w/ 1 level red: 1 NA NA NA NA



list3 - rapply(list1, function(x) gsub(red, green, x), 
how = replace)

 str(list3)
List of 4
 $ : chr [1:2, 1:2] 23 45 green 78
 $ : chr [1:5] green green 1 2 ...
 $ :List of 2
  ..$ test1: chr [1:5] 223 445 green 78 ...
  ..$ test2: chr [1:5] green NA NA NA ...
 $ :List of 3
  ..$ : chr [1:2, 1:2] 23 45 green 78
  ..$ : chr [1:5] green green 1 2 ...
  ..$ :List of 2
  .. ..$ test1: chr [1:5] 223 445 green 78 ...
  .. ..$ test2: chr [1:5] green NA NA NA ...


Note however, the impact of using gsub(), which is that factors are
coerced to characters. So consider what you want the end game to be.

See ?rapply for more information.

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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Unable to compile Matrix package

2007-05-16 Thread Douglas Bates
On 5/16/07, Vittorio De Martino [EMAIL PROTECTED] wrote:
 After upgrading to 2.5.0 under freebsd 6.2 I updated all the add-on packages
 in an R session via update.packages(...). R was unable to install
 the Matrix package because it couldn't find the package.
 Therefore I downloaded the *.tar.gz from the CRAN site and issued

 R CMD INSTALL Matrix_0.99875-1.tar.gz

 but the comilation ended in an error (see the complete attached
 r_log.tar.gz)

 cc -std=gnu99 -I/usr/local/lib/R/include -I/usr/local/lib/R/include  
 -I/usr/local/include  -D__NO_MATH_INLINES -I../UFc
 cc -std=gnu99 -I/usr/local/lib/R/include -I/usr/local/lib/R/include  
 -I/usr/local/include  -D__NO_MATH_INLINES -I../UFc
 ar -rucs ../COLAMD.a colamd.o colamd_global.oM
 ( cd Source ; make lib )M
 Error expanding embedded variable.M
 *** Error code 2M
 M
 Stop in /tmp/R.INSTALL.IuAhvE/Matrix/src/AMD.M
 *** Error code 1M
 M
 Stop in /tmp/R.INSTALL.IuAhvE/Matrix/src.M
 ERROR: compilation failed for package 'Matrix'M
 ** Removing '/usr/local/lib/R/library/Matrix'M
 NbBSD# exitMM
 exitM

 What shall I do?

As Duncan Murdoch once said, in extreme cases you could read the
documentation.  :-)

The Matrix package requires that you use a version of `make' that is
compatible with GNU make.  Often this is called 'gmake' on BSD
systems.  If that is the case for you then setting the environment
variable

setenv MAKE gmake

should work.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] read.table opening a website incl Password

2007-05-16 Thread Roland Rau
Dear all,

in the past I have been able to access websites with data directly. For 
example the following code works nicely

mydata - 
read.table(http://www.lifetable.de/data/MPIDR/POL_2004.txt;,   header=TRUE)

But what happens if I need a username and password (a different site)? 
How do I do that? Or is it not possible to this in R?
I tried something like this

mydata.frame - read.table(myusr:[EMAIL PROTECTED]/adir/afile.txt)

but it did not work.
I'd appreciate any hints.
My platform is Win32 (and I am actually running R 2.3.1, but I guess 
(hope!) this is not the reason. At least I checked the NEWS file whether 
any changes appeared since 2.3.1 which could affect this behavior).

Thanks,
Roland

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] lmer error confusion

2007-05-16 Thread Rick DeShon
Hi All.

I'm trying to run a simple model from Baayan, Davidson,  Bates and getting
a confusing error message.  Any ideas what I'm doing wrong here?

# Here's the data.
Subj- factor(rep(1:3,each=6))
Item- factor(rep(1:3,6))
SOA - factor(rep(0:1,3,each=3))
RT  -
c(466,520,502,475,494,490,516,566,577,491,544,526,484,529,539,470,511,528)
priming - data.frame(cbind(Subj,Item,SOA,RT))

str(priming)
'data.frame':   18 obs. of  4 variables:
 $ Subj: num  1 1 1 1 1 1 2 2 2 2 ...
 $ Item: num  1 2 3 1 2 3 1 2 3 1 ...
 $ SOA : num  1 1 1 2 2 2 1 1 1 2 ...
 $ RT  : num  466 520 502 475 494 490 516 566 577 491 ...

#Here's the call taken directly from the paper
priming.lmer1 - lmer(RT ~ SOA + (1 | Item) + (1 | Subj), data = priming)

#Here's the error
Error in rbind(Item = S4 object of class dgCMatrix, Subj = S4 object of
class dgCMatrix) :
cannot coerce type S4 to list vector

Any idea what I'm doing wrong?


sessionInfo()
R version 2.5.0 (2007-04-23)
i386-pc-mingw32
other attached packages:
   lme4  Matrix latticenlme
0.9975-13 0.99875-10.15-43.1-80

Rick DeShon

[[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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lmer function

2007-05-16 Thread Douglas Bates

On 5/16/07, Iasonas Lamprianou [EMAIL PROTECTED] wrote:

Dear all,



the question was if lmer can estimate the variance components correctly,
although my design is very UNbalanced.


Yes, lmer can handle unbalanced data and large data sets.


Also, how do I find the percentage of the variance from every component? Do
I have to add all the variance components and then divide each one by the
total?


Yes, that should do it.

I enclose a short function to automate the process by extracting the
information from the value of VarCorr.


P.S. lmer is excellent. It can estimate large datasets where SPSS gives me
error messages and says it cannot estimate them. Keep on good work
friends!


Thank you. It's wonderful to hear that it is helpful.  The main
objective in developing lmer was to be able to handle large data sets
with crossed or partially crossed random effects.


- Original Message 
From: Douglas Bates [EMAIL PROTECTED]
To: Steven McKinney [EMAIL PROTECTED]
Cc: Iasonas Lamprianou [EMAIL PROTECTED]; r-help@stat.math.ethz.ch
Sent: Tuesday, 15 May, 2007 2:17:34 AM
Subject: Re: [R] lmer function


On 5/14/07, Steven McKinney [EMAIL PROTECTED] wrote:

 Running lme4 0.9975-13
 I'm still getting the warning

  $ operator not defined for this S4 class, returning NULL in:
x$symbolic.cor

It was my mistake.  I fixed the problem in the development sources
long ago but I haven't uploaded a new release since doing so.   I'll
upload a new release next week - this is finals week for us and they
seem to expect that we will do things like grade exams rather than
debugging code. :-)

 Is there a more recent version?
 Is there any known problem with this warning
 (incorrect results etc.) ?

Not really.  It is a benign cut-and-paste error.  If you want to fix
it now look for the function printMer in the source file lme4/R/lmer.R
and change the default for the symbolic.cor argument to FALSE.

  sessionInfo()
 R version 2.5.0 (2007-04-23)
 powerpc-apple-darwin8.9.1

 locale:
 C

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

 other attached packages:
lme4  Matrix lattice
 0.9975-13 0.9975-110.15-4
 

 Steven McKinney

 Statistician
 Molecular Oncology and Breast Cancer Program
 British Columbia Cancer Research Centre

 email: [EMAIL PROTECTED]

 tel: 604-675-8000 x7561

 BCCRC
 Molecular Oncology
 675 West 10th Ave, Floor 4
 Vancouver B.C.
 V5Z 1L3
 Canada




 -Original Message-
 From: [EMAIL PROTECTED] on behalf of
Douglas Bates
 Sent: Mon 5/14/2007 12:43 PM
 To: Iasonas Lamprianou
 Cc: r-help@stat.math.ethz.ch
 Subject: Re: [R] lmer function

 On 5/14/07, Iasonas Lamprianou [EMAIL PROTECTED] wrote:
  Does anyone know if the lmer function of lme4 works fine for unbalanced
designs? I have the examination results of 1000 pupils on three subjects,
one score every term. So, I have three scores for English (one for every
term), three scores for maths etc. However, not everybody was examined in
maths, not everybody was examined in English etc, but everybody was in
effect examined on four subjects. I also have information abouit the school.
Would this model hive the right results for the variance components?
 
  mod_3_f  - lmer(SCORE ~ GENDER + (1 |ID ) + (1 | TERM) + (1 | SUBJECT)
, Dataset)
 
  Linear mixed-effects model fit by REML
  Formula: SCORE ~ GENDER + (1 | ID) + (1 | TERM) + (1 | SUBJECT)
 Data: Dataset
  AICBIC  logLik MLdeviance REMLdeviance
   247882 247926 -123936 247871   247872
  Random effects:
   Groups   NameVariance Std.Dev.
   ID   (Intercept) 5.97288  2.44395
   TERM (Intercept) 5.10307  2.25900
   SUBJECT  (Intercept) 0.25943  0.50934
   Residual 4.41673  2.10160
  number of obs: 53978, groups: ID, 5695; TERM, 4; SUBJECT, 4
  Fixed effects:
 Estimate Std. Error t value
  (Intercept)14.303521.15870   12.34
  GENDER[T.Male] -1.017760.06885  -14.78
  Correlation of Fixed Effects:
  Warning in x$symbolic.cor : $ operator not defined for this S4 class,
returning NULL

 What version of the lme4 package are you using?  (Use sessionInfo() to
 check.)  I think the bug that causes that warning has been fixed in
 the most recent version.

  (Intr)
  GENDER[T.M] -0.023

  How do I interpert the results?

 Do you really want to treat SUBJECT as a random effect?  I think it
 would be more common to treat it as a fixed effect.  If I understand
 you correctly there are only two levels of SUBJECT and these are
 repeatable levels. If that is the case one could model SUBJECT as a
 fixed effect or consider its interaction within student with the term
 (SUBJECT|ID).

 It would make sense to regard the pair of responses in maths and
 English for each student in each term as a multivariate response but,
 at present, that model cannot be fit with lmer.

 I would also question whether you want the TERM to be modeled with a
 random effect.

 

Re: [R] read.table opening a website incl Password

2007-05-16 Thread Chuck Cleland
Roland Rau wrote:
 Dear all,
 
 in the past I have been able to access websites with data directly. For 
 example the following code works nicely
 
 mydata - 
 read.table(http://www.lifetable.de/data/MPIDR/POL_2004.txt;, 
 header=TRUE)
 
 But what happens if I need a username and password (a different site)? 
 How do I do that? Or is it not possible to this in R?
 I tried something like this
 
 mydata.frame - read.table(myusr:[EMAIL PROTECTED]/adir/afile.txt)
 
 but it did not work.
 I'd appreciate any hints.
 My platform is Win32 (and I am actually running R 2.3.1, but I guess 
 (hope!) this is not the reason. At least I checked the NEWS file whether 
 any changes appeared since 2.3.1 which could affect this behavior).

  In what way did it not work?  The following seems to work for me:

read.table(ftp://myusr:[EMAIL PROTECTED]/mydir/test.dat)

 Thanks,
 Roland
 
 __
 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
 and provide commented, minimal, self-contained, reproducible code.

-- 
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] lmer error confusion

2007-05-16 Thread Douglas Bates
On 5/16/07, Rick DeShon [EMAIL PROTECTED] wrote:
 Hi All.

 I'm trying to run a simple model from Baayan, Davidson,  Bates and getting
 a confusing error message.  Any ideas what I'm doing wrong here?

 # Here's the data.
 Subj- factor(rep(1:3,each=6))
 Item- factor(rep(1:3,6))
 SOA - factor(rep(0:1,3,each=3))
 RT  -
 c(466,520,502,475,494,490,516,566,577,491,544,526,484,529,539,470,511,528)
 priming - data.frame(cbind(Subj,Item,SOA,RT))

 str(priming)
 'data.frame':   18 obs. of  4 variables:
  $ Subj: num  1 1 1 1 1 1 2 2 2 2 ...
  $ Item: num  1 2 3 1 2 3 1 2 3 1 ...
  $ SOA : num  1 1 1 2 2 2 1 1 1 2 ...
  $ RT  : num  466 520 502 475 494 490 516 566 577 491 ...

 #Here's the call taken directly from the paper
 priming.lmer1 - lmer(RT ~ SOA + (1 | Item) + (1 | Subj), data = priming)

 #Here's the error
 Error in rbind(Item = S4 object of class dgCMatrix, Subj = S4 object of
 class dgCMatrix) :
 cannot coerce type S4 to list vector

 Any idea what I'm doing wrong?


 sessionInfo()
 R version 2.5.0 (2007-04-23)
 i386-pc-mingw32
 other attached packages:
lme4  Matrix latticenlme
 0.9975-13 0.99875-10.15-43.1-80

It's a version skew problem (and thanks for including the
sessionInfo() output that makes it possible to detect this).  Changes
were made in version 0.99875-0 and later of the Matrix package that
require a new version of the lme4 package.  Please install version
0.99875-0 or later of lme4.

However, while we are discussing this example, notice that using the
cbind inside the call to data.frame causes the factors to become
numeric variables.  That is undesirable.  In this case it is benign
but it could be harmful.

A better approach is simply to give the variables and their names in
the call data.frame.  Also, the sequence factor(rep(...)) can be
written better as a call to the underutilized function gl.

 priming - data.frame(Subj = gl(3,6), Item = gl(3,1,18), SOA = 
 gl(2,3,18,labels = 0:1),
+   RT = 
c(466,520,502,475,494,490,516,566,577,491,544,526,484,529,539,470,511,528))
 str(priming)
'data.frame':   18 obs. of  4 variables:
 $ Subj: Factor w/ 3 levels 1,2,3: 1 1 1 1 1 1 2 2 2 2 ...
 $ Item: Factor w/ 3 levels 1,2,3: 1 2 3 1 2 3 1 2 3 1 ...
 $ SOA : Factor w/ 2 levels 0,1: 1 1 1 2 2 2 1 1 1 2 ...
 $ RT  : num  466 520 502 475 494 490 516 566 577 491 ...
 lmer2(RT ~ SOA + (1|Subj) + (1|Item), priming)
Linear mixed-effects model fit by REML
Formula: RT ~ SOA + (1 | Subj) + (1 | Item)
   Data: priming
   AIC BIC logLik MLdeviance REMLdeviance
 149.4 153 -70.72  154.4141.4
Random effects:
 Groups   NameVariance Std.Dev.
 Subj (Intercept) 499.37   22.347
 Item (Intercept) 607.80   24.654
 Residual 137.35   11.719
Number of obs: 18, groups: Subj, 3; Item, 3

Fixed effects:
Estimate Std. Error t value
(Intercept)  522.111 19.604  26.633
SOA1 -18.889  5.525  -3.419

Correlation of Fixed Effects:
 (Intr)
SOA1 -0.141

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] substitute x for pattern in a list, while preservign list structure. lapply, gsub, list...?

2007-05-16 Thread Gabor Grothendieck
On 5/16/07, Marc Schwartz [EMAIL PROTECTED] wrote:
 On Wed, 2007-05-16 at 09:25 -0700, new ruser wrote:
  I am experimenting with some of the common r functions.
  I had a question re:using gsub (or some similar functions) on the
  contents of a list.
 
  I want to design a function that looks at everything contained din a
  list, and anytime it finds the text string pattern replace it with
  x.  I also wish to preserve the structure of the original list.
  What is a good way to accomplish this?
 
  I tried :
 
  a = matrix(data=c(23,45,'red',78),nrow=2)
  b = c('red','green',1,2,3)
  d = data.frame( test1=c(223,445,'red',78,56) , test2=
  c('red',NA,NA,NA,NA) )
  e= list(a,b,d)
  list1 = list(a,b,d,e)
 
  list2 = lapply(list1,function(list)(gsub(red,green,list)))
 
  str(list1)
  str(list2)
 
  but the structue fo the list changed.

 I suspect that you will need to use rapply(), which is a recursive
 version of lapply().

 For example:

  str(list1)
 List of 4
  $ : chr [1:2, 1:2] 23 45 red 78
  $ : chr [1:5] red green 1 2 ...
  $ :'data.frame':   5 obs. of  2 variables:
  ..$ test1: Factor w/ 5 levels 223,445,56,..: 1 2 5 4 3
  ..$ test2: Factor w/ 1 level red: 1 NA NA NA NA
  $ :List of 3
  ..$ : chr [1:2, 1:2] 23 45 red 78
  ..$ : chr [1:5] red green 1 2 ...
  ..$ :'data.frame':5 obs. of  2 variables:
  .. ..$ test1: Factor w/ 5 levels 223,445,56,..: 1 2 5 4 3
  .. ..$ test2: Factor w/ 1 level red: 1 NA NA NA NA



 list3 - rapply(list1, function(x) gsub(red, green, x),
how = replace)

  str(list3)
 List of 4
  $ : chr [1:2, 1:2] 23 45 green 78
  $ : chr [1:5] green green 1 2 ...
  $ :List of 2
  ..$ test1: chr [1:5] 223 445 green 78 ...
  ..$ test2: chr [1:5] green NA NA NA ...
  $ :List of 3
  ..$ : chr [1:2, 1:2] 23 45 green 78
  ..$ : chr [1:5] green green 1 2 ...
  ..$ :List of 2
  .. ..$ test1: chr [1:5] 223 445 green 78 ...
  .. ..$ test2: chr [1:5] green NA NA NA ...


 Note however, the impact of using gsub(), which is that factors are
 coerced to characters. So consider what you want the end game to be.

 See ?rapply for more information.


Also note that from your str's above it appears that data.frames do not
survive rapply but rather are changed to plain lists.  I don't know whether
that is intentional on the part of the developers or not.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read.table opening a website incl Password

2007-05-16 Thread Prof Brian Ripley
On Wed, 16 May 2007, Roland Rau wrote:

 Dear all,

 in the past I have been able to access websites with data directly. For
 example the following code works nicely

 mydata -
 read.table(http://www.lifetable.de/data/MPIDR/POL_2004.txt;, 
 header=TRUE)

 But what happens if I need a username and password (a different site)?
 How do I do that? Or is it not possible to this in R?
 I tried something like this

 mydata.frame - read.table(myusr:[EMAIL PROTECTED]/adir/afile.txt)

 but it did not work.

Well, it could not.  You need ftp:// or http:// for this to be a URL. This 
ought to work for ftp:, but AFAIK not for http:.  You could always try 
--internet2: if it works in IE, it will probably also work in R.

 I'd appreciate any hints.
 My platform is Win32 (and I am actually running R 2.3.1, but I guess
 (hope!) this is not the reason. At least I checked the NEWS file whether
 any changes appeared since 2.3.1 which could affect this behavior).

 Thanks,
 Roland

 __
 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
 and provide commented, minimal, self-contained, reproducible code.


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

__
R-help@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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read.table opening a website incl Password

2007-05-16 Thread Bos, Roger
Chuck, Roland is trying to read from a web site instead of a ftp site.

I have also gotten this to work:
read.table(ftp://myusr:[EMAIL PROTECTED]/mydir/test.dat)
But when I try to do the same thing from the SEC's ftp site I get an
error, so beyond R, there may be some internet settings that need to be
fiddled with.  Maybe I can tag onto Roland's question and ask for hints
on what configuration options are available?

Thanks,

Roger


 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Chuck Cleland
Sent: Wednesday, May 16, 2007 1:08 PM
To: Roland Rau
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] read.table opening a website incl Password

Roland Rau wrote:
 Dear all,
 
 in the past I have been able to access websites with data directly. 
 For example the following code works nicely
 
 mydata - 
 read.table(http://www.lifetable.de/data/MPIDR/POL_2004.txt;,
header=TRUE)
 
 But what happens if I need a username and password (a different site)?

 How do I do that? Or is it not possible to this in R?
 I tried something like this
 
 mydata.frame - 
 read.table(myusr:[EMAIL PROTECTED]/adir/afile.txt)
 
 but it did not work.
 I'd appreciate any hints.
 My platform is Win32 (and I am actually running R 2.3.1, but I guess
 (hope!) this is not the reason. At least I checked the NEWS file 
 whether any changes appeared since 2.3.1 which could affect this
behavior).

  In what way did it not work?  The following seems to work for me:

read.table(ftp://myusr:[EMAIL PROTECTED]/mydir/test.dat)

 Thanks,
 Roland
 
 __
 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
 and provide commented, minimal, self-contained, reproducible code.

--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894

__
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
and provide commented, minimal, self-contained, reproducible code.

** * 
This message is for the named person's use only. It may 
contain confidential, proprietary or legally privileged 
information. No right to confidential or privileged treatment 
of this message is waived or lost by any error in 
transmission. If you have received this message in error, 
please immediately notify the sender by e-mail, 
delete the message and all copies from your system and destroy 
any hard copies. You must not, directly or indirectly, use, 
disclose, distribute, print or copy any part of this message 
if you are not the intended recipient.

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] substitute x for pattern in a list, while preservign list structure. lapply, gsub, list...?

2007-05-16 Thread Marc Schwartz
On Wed, 2007-05-16 at 13:18 -0400, Gabor Grothendieck wrote:
 On 5/16/07, Marc Schwartz [EMAIL PROTECTED] wrote:
  On Wed, 2007-05-16 at 09:25 -0700, new ruser wrote:
   I am experimenting with some of the common r functions.
   I had a question re:using gsub (or some similar functions) on the
   contents of a list.
  
   I want to design a function that looks at everything contained din a
   list, and anytime it finds the text string pattern replace it with
   x.  I also wish to preserve the structure of the original list.
   What is a good way to accomplish this?
  
   I tried :
  
   a = matrix(data=c(23,45,'red',78),nrow=2)
   b = c('red','green',1,2,3)
   d = data.frame( test1=c(223,445,'red',78,56) , test2=
   c('red',NA,NA,NA,NA) )
   e= list(a,b,d)
   list1 = list(a,b,d,e)
  
   list2 = lapply(list1,function(list)(gsub(red,green,list)))
  
   str(list1)
   str(list2)
  
   but the structue fo the list changed.
 
  I suspect that you will need to use rapply(), which is a recursive
  version of lapply().
 
  For example:
 
   str(list1)
  List of 4
   $ : chr [1:2, 1:2] 23 45 red 78
   $ : chr [1:5] red green 1 2 ...
   $ :'data.frame':   5 obs. of  2 variables:
   ..$ test1: Factor w/ 5 levels 223,445,56,..: 1 2 5 4 3
   ..$ test2: Factor w/ 1 level red: 1 NA NA NA NA
   $ :List of 3
   ..$ : chr [1:2, 1:2] 23 45 red 78
   ..$ : chr [1:5] red green 1 2 ...
   ..$ :'data.frame':5 obs. of  2 variables:
   .. ..$ test1: Factor w/ 5 levels 223,445,56,..: 1 2 5 4 3
   .. ..$ test2: Factor w/ 1 level red: 1 NA NA NA NA
 
 
 
  list3 - rapply(list1, function(x) gsub(red, green, x),
 how = replace)
 
   str(list3)
  List of 4
   $ : chr [1:2, 1:2] 23 45 green 78
   $ : chr [1:5] green green 1 2 ...
   $ :List of 2
   ..$ test1: chr [1:5] 223 445 green 78 ...
   ..$ test2: chr [1:5] green NA NA NA ...
   $ :List of 3
   ..$ : chr [1:2, 1:2] 23 45 green 78
   ..$ : chr [1:5] green green 1 2 ...
   ..$ :List of 2
   .. ..$ test1: chr [1:5] 223 445 green 78 ...
   .. ..$ test2: chr [1:5] green NA NA NA ...
 
 
  Note however, the impact of using gsub(), which is that factors are
  coerced to characters. So consider what you want the end game to be.
 
  See ?rapply for more information.
 
 
 Also note that from your str's above it appears that data.frames do not
 survive rapply but rather are changed to plain lists.  I don't know whether
 that is intentional on the part of the developers or not.

Right, which I noted and would be consistent with the behavior of
lapply() on data frames, which also simplifies the result to a normal
list.

Since rapply() is documented to be recursive version of lapply(), the
result above would be expected, at least implicitly.

Thanks for raising the point Gabor.

Regards,

Marc

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] read.table opening a website incl Password

2007-05-16 Thread Roland Rau
Dear all,

so far I tried various things but I did not really succeed:
- starting R with --internet2
- using url()
- using read.table(http://myusr:[EMAIL PROTECTED]/adir/afile.txt)

I just have an idea what the problem could be for me:
The username is actually an email address. So the '@'-character has some 
ambiguous meaning in my setting. Sorry that I did not think of that 
beforehand.

Thank you very much for your help,
Roland




Prof Brian Ripley wrote:
 On Wed, 16 May 2007, Roland Rau wrote:
 
 Dear all,

 in the past I have been able to access websites with data directly. For
 example the following code works nicely

 mydata -
 read.table(http://www.lifetable.de/data/MPIDR/POL_2004.txt;, 
 header=TRUE)

 But what happens if I need a username and password (a different site)?
 How do I do that? Or is it not possible to this in R?
 I tried something like this

 mydata.frame - read.table(myusr:[EMAIL PROTECTED]/adir/afile.txt)

 but it did not work.
 
 Well, it could not.  You need ftp:// or http:// for this to be a URL. 
 This ought to work for ftp:, but AFAIK not for http:.  You could always 
 try --internet2: if it works in IE, it will probably also work in R.
 
 I'd appreciate any hints.
 My platform is Win32 (and I am actually running R 2.3.1, but I guess
 (hope!) this is not the reason. At least I checked the NEWS file whether
 any changes appeared since 2.3.1 which could affect this behavior).

 Thanks,
 Roland

 __
 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
 and provide commented, minimal, self-contained, reproducible code.



__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] substitute x for pattern in a list, while preservign list structure. lapply, gsub, list...?

2007-05-16 Thread Gabor Grothendieck
Here is a recursive function you could try.  Here f has been defined only to
convert character variables.  Modify to suit.

recurse - function(x, f) {
   if (length(x) == 0) return(x)
   if (is.list(x)) for(i in seq_along(x)) x[[i]] - recurse(x[[i]], f)
   else x - f(x)
   x
}
f - function(x) if (mode(x) == character) gsub(red, green, x) else x
list4 - recurse(list1, f)


On 5/16/07, new ruser [EMAIL PROTECTED] wrote:
 I am experimenting with some of the common r functions.
 I had a question re:using gsub (or some similar functions) on the contents 
 of a list.

 I want to design a function that looks at everything contained din a list, 
 and anytime it finds the text string pattern replace it with x.  I also 
 wish to preserve the structure of the original list.  What is a good way to 
 accomplish this?

 I tried :

 a = matrix(data=c(23,45,'red',78),nrow=2)
 b = c('red','green',1,2,3)
 d = data.frame( test1=c(223,445,'red',78,56) , test2= c('red',NA,NA,NA,NA) )
 e= list(a,b,d)
 list1 = list(a,b,d,e)

 list2 = lapply(list1,function(list)(gsub(red,green,list)))

 str(list1)
 str(list2)

 but the structue fo the list changed.


 -
 Give spam the boot. Take control with tough spam protection

[[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
 and provide commented, minimal, self-contained, reproducible code.


__
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
and provide commented, minimal, self-contained, reproducible code.


[R] questions on package of KEGG

2007-05-16 Thread Li, Hua
Dear list members:
   Once I know a KEGG pathway identifier, how can I check all its direct 
children identifiers? you know, I could use GOMFCHILDREN or GOCCCHILDREN to 
check the children terms for a specific GO term, but I don't know how to do it 
in the same way for KEGG in R?
   Many Thanks!!
Hua

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Abline in dotplot

2007-05-16 Thread Thompson, Valeria V
Hello,

I have trouble adding an abline to a dotplot() from lattice package.
For example, I would like to draw a line at x=3:

 library(lattice)
 x-1:5
 names(x) - c(a, b, c, d, e)
 dotplot(sample(x))
 panel.abline(v=3)

Produces a line on the left hand side of the origin. What would be a
correct way to do this? 

Thank you,

Valeria V. Thompson
Applied Statistics Group
Mathematics  Computing Technology
The Boeing Company
(425) 373-2740

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Abline in dotplot

2007-05-16 Thread Sundar Dorai-Raj


Thompson, Valeria V said the following on 5/16/2007 12:04 PM:
 Hello,
 
 I have trouble adding an abline to a dotplot() from lattice package.
 For example, I would like to draw a line at x=3:
 
 library(lattice)
 x-1:5
 names(x) - c(a, b, c, d, e)
 dotplot(sample(x))
 panel.abline(v=3)
 
 Produces a line on the left hand side of the origin. What would be a
 correct way to do this? 
 
 Thank you,
 
 Valeria V. Thompson
 Applied Statistics Group
 Mathematics  Computing Technology
 The Boeing Company
 (425) 373-2740
 
 __
 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
 and provide commented, minimal, self-contained, reproducible code.

Try this instead:

library(lattice)
x-1:5
names(x) - c(a, b, c, d, e)
dotplot(sample(x),
 panel = function(...) {
   panel.dotplot(...)
   panel.abline(v=3)
 })


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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Abline in dotplot

2007-05-16 Thread Deepayan Sarkar
On 5/16/07, Thompson, Valeria V [EMAIL PROTECTED] wrote:
 Hello,

 I have trouble adding an abline to a dotplot() from lattice package.
 For example, I would like to draw a line at x=3:

  library(lattice)
  x-1:5
  names(x) - c(a, b, c, d, e)
  dotplot(sample(x))
  panel.abline(v=3)

 Produces a line on the left hand side of the origin. What would be a
 correct way to do this?

This would be one:

dotplot(sample(x),
panel = function(...) {
panel.abline(v=3)
panel.dotplot(...)
})

Your approach wouldn't generalize to the case where you have more than
one panel.

-Deepayan

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] questions on package of KEGG

2007-05-16 Thread Seth Falcon
Li, Hua  [EMAIL PROTECTED] writes:

 Dear list members: Once I know a KEGG pathway identifier, how can I
 check all its direct children identifiers? you know, I could use
 GOMFCHILDREN or GOCCCHILDREN to check the children terms for a
 specific GO term, but I don't know how to do it in the same way for
 KEGG in R?  Many Thanks!!  Hua

I think you should ask this question on the bioconductor list.

http://www.bioconductor.org/docs/postingGuide.html

+ seth

-- 
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Best way to utilize R graphing capabilities from other program

2007-05-16 Thread Abran Steele-Feldman
I am working on an open source program to be used for
model selection and evalution.  I would like to
utilize the graphical capabilities of R to generate
plots that I would then display in my software
program.  What is the best way to go about this?  I
have looked at Rserve and also looked at re-compiling
R as a shared library.  

I am looking for something that can be distributed
internally with my program (so that the user does not
need to install R separately) if possible, and also
something relatively small.

Any suggestions on how to proceed?  Good tutorials on
this subject?  Thanks for any advice


   
Take
 the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, 
photos  more.

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Re-sizing R graphics for Sweave

2007-05-16 Thread Thomas Adams
I am generating a single graphic containing about 31 Boxplots; the issue 
I am having is that not all the labels (3 characters each) are shown. 
Interactively, within a R session, I can simply re-size the graphics 
window and all the labels appear. But, what can I do non-interactively 
to have all the labels displayed when using Sweave? Can the labels be 
rotated 90-degrees; would this help? I guess one possibility would be to 
number the boxplots, but this may not help either. My thought would be 
to force the graphic to be a certain width, but I can't find how to do this.

I have searched and can not find a way to do this automatically — I 
could not find anything in the R Graphics book by Paul Murrell that 
pointed me in the right direction either.

Thank you,
Tom

-- 
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:  [EMAIL PROTECTED]

VOICE:  937-383-0528
FAX:937-383-0033

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] suppress plot w/ ewma function from qcc pkg

2007-05-16 Thread Francis, Brian
Hi,

I've been searching for a solution to this but have come up empty.

I would like to suppress the plot creation when using the ewma function
in the qcc package.  Normally it's just plot = FALSE, but the ewma
function doesn't have this option.  Anything I'm missing or a work
around?

Many thanks,

Brian Francis
Statistician II
Charles River Laboratories

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re-sizing R graphics for Sweave

2007-05-16 Thread Marc Schwartz
On Wed, 2007-05-16 at 16:34 -0400, Thomas Adams wrote:
 I am generating a single graphic containing about 31 Boxplots; the issue 
 I am having is that not all the labels (3 characters each) are shown. 
 Interactively, within a R session, I can simply re-size the graphics 
 window and all the labels appear. But, what can I do non-interactively 
 to have all the labels displayed when using Sweave? Can the labels be 
 rotated 90-degrees; would this help? I guess one possibility would be to 
 number the boxplots, but this may not help either. My thought would be 
 to force the graphic to be a certain width, but I can't find how to do this.
 
 I have searched and can not find a way to do this automatically — I 
 could not find anything in the R Graphics book by Paul Murrell that 
 pointed me in the right direction either.
 
 Thank you,
 Tom

Presuming that you are using a 'figure' chunk in your .Rnw file, you can
use:

  fig=TRUE,height=8,width=6.5=

 Your R code here...

  @


which will define the dimensions of your plot output file as 8 x 6.5.
Adjust these as you require.

See ?RweaveLatex

You may also need to adjust the size of the titles, etc. in the plots,
which you can do with the various 'cex' family of parameters. See ?par
for more information there.

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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Re-sizing R graphics for Sweave

2007-05-16 Thread Thomas Adams
Marc,

That did it! Thank you so much for your help…

Regards,
Tom


Marc Schwartz wrote:
 On Wed, 2007-05-16 at 16:34 -0400, Thomas Adams wrote:
   
 I am generating a single graphic containing about 31 Boxplots; the issue 
 I am having is that not all the labels (3 characters each) are shown. 
 Interactively, within a R session, I can simply re-size the graphics 
 window and all the labels appear. But, what can I do non-interactively 
 to have all the labels displayed when using Sweave? Can the labels be 
 rotated 90-degrees; would this help? I guess one possibility would be to 
 number the boxplots, but this may not help either. My thought would be 
 to force the graphic to be a certain width, but I can't find how to do this.

 I have searched and can not find a way to do this automatically — I 
 could not find anything in the R Graphics book by Paul Murrell that 
 pointed me in the right direction either.

 Thank you,
 Tom
 

 Presuming that you are using a 'figure' chunk in your .Rnw file, you can
 use:

   fig=TRUE,height=8,width=6.5=

  Your R code here...

   @


 which will define the dimensions of your plot output file as 8 x 6.5.
 Adjust these as you require.

 See ?RweaveLatex

 You may also need to adjust the size of the titles, etc. in the plots,
 which you can do with the various 'cex' family of parameters. See ?par
 for more information there.

 HTH,

 Marc Schwartz


   


-- 
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:  [EMAIL PROTECTED]

VOICE:  937-383-0528
FAX:937-383-0033

__
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] converting a data frame to ts objects

2007-05-16 Thread Gabor Grothendieck
On 5/16/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 On 5/16/07, fatih ozgul [EMAIL PROTECTED] wrote:
  Dear R-ians
 
  I have a data frame like
 
  Person_id  Date/timeCount
  -  --  ---
  123 20 May 1999  1
  123 21 May 1999  3
  222 1  Feb 2000  2
  222 3  Feb 2000  4
 
  I want to create ts objects for each person_id (i.e. 123 and 222). Time
  series frequency can be in months and all starting from the same date (i.e.
  May 1999).
 
  Rather than manually creating sum of counts for each month and creating ts
  objects manually for each persons,
 
  Is there a function for creating ts objects automatically from such data?
 

 Try this:

 # read in as data frame and fix up date
 Lines.raw - Person_id Date/time Count
 123 20 May 1999 1
 123 21 May 1999 3
 222 1 Feb 2000 2
 222 3 Feb 2000 4
 
 library(zoo)
 DF - read.table(textConnection(Lines.raw), skip = 1,
  col.names = c(Person_id, d, b, Y, Count))
 DF$Date.time - as.Date(paste(DF$d, DF$b, DF$Y), %d %b %Y)

 # aggregate counts over months, series and convert to ts
 f - function(DF) aggregate(zoo(DF$Count), as.yearmon(DF$Date.time), sum)
 z - do.call(merge.zoo, lapply(split(DF, DF$Person_id), f))
 frequency(z) - 12
 as.ts(z)


A slight simplification based on zoo 1.3-1 (which just appeared on CRAN)
is the following.  It converts the month and year columns directly into
class yearmon eliminating the intermediate step of going via Date class.
Its the same number of lines but a couple of the lines are now simpler.

# read in as data frame and fix up date
Lines.raw - Person_id Date/time Count

123 20 May 1999 1
123 21 May 1999 3
222 1 Feb 2000 2
222 3 Feb 2000 4


library(zoo)
DF - read.table(textConnection(Lines.raw), skip = 1,
 col.names = c(Person_id, d, b, Y, Count))
DF$yearmon - as.yearmon(paste(DF$b, DF$Y), %b %Y)

# aggregate counts over months, merge series and convert to ts
ag - function(DF) aggregate(zoo(DF$Count), DF$yearmon, sum)
z - do.call(merge.zoo, lapply(split(DF, DF$Person_id), ag))
frequency(z) - 12
as.ts(z)

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] [R-pkgs] New version 0.9-7 of lars package

2007-05-16 Thread Trevor Hastie
I uploaded a new version of the lars package to CRAN,
which incorporates some nontrivial changes.

1) lars now has normalize and intercept options, both defaulted to TRUE,
which means the variables are scaled to have unit euclidean norm, and
an intercept is included in the model. Either or both can be set to FALSE.

2) lars has an additional type = stepwise option;
now the list is type=c(lasso, lar, forward.stagewise,stepwise)
This was included because it is trivial to implement, and useful for 
comparisons.
Stepwise is a version of forward stepwise regression, where the 
variable to
enter is the one most correlated with the residuals. This is not 
necessarily the
same as the forward stepwise implemented as part of step() in R, where the
variable entered is the one that, when included, reduces the RSS the most.

3) a method for summary() has been included, which gives an anova-type 
summary
of the sequence of steps.

4) The plot method for lars defaults to plotting coefficients against 
the relative
L1 norm of the coefficients. This was not done correctly in general for 
type lar
and forward.stagewise, since the L1 norm does not change smoothly if
coefficients pass through zero. This has been fixed.

5) A smalll number of of other changes have been made, some in response 
to email
messages from users.
 
Thanks to Yann-Ael Le Borgne for pointing out the problem in (4) and 
proposing
a solution, and to Lukas Meier for reporting some bugs. Please let me 
know of any
new problems, or old ones not yet repaired.

Trevor Hastie


  Trevor Hastie  [EMAIL PROTECTED]
  Professor  Chair, Department of Statistics, Stanford University
  Phone: (650) 725-2231 (Statistics) Fax: (650) 725-8977
 (650) 498-5233 (Biostatistics)  Fax: (650) 725-6951
  URL: http://www-stat.stanford.edu/~hastie
  address: room 104, Department of Statistics, Sequoia Hall
  390 Serra Mall, Stanford University, CA 94305-4065

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
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
and provide commented, minimal, self-contained, reproducible code.


[R] Design matrix question

2007-05-16 Thread Steven McKinney

Hi useRs,

Perhaps I am having a senior moment?

I have a nested variable situation to model,

toy example:


 df - data.frame(A = factor(c(a, a, x, x), levels = c(x, a)),
+  B = factor(c(b, x, x, x), levels = c(x, b)))
 
 df
  A B
1 a b
2 a x
3 x x
4 x x

So of course the full design matrix is singular

 model.matrix(~ A * B, df)
  (Intercept) Aa Bb Aa:Bb
1   1  1  1 1
2   1  1  0 0
3   1  0  0 0
4   1  0  0 0
attr(,assign)
[1] 0 1 2 3
attr(,contrasts)
attr(,contrasts)$A
[1] contr.treatment

attr(,contrasts)$B
[1] contr.treatment


I'd like not to have the B term main effect in the model

 model.matrix(~ A * B - B, df)
  (Intercept) Aa Ax:Bb Aa:Bb
1   1  1 0 1
2   1  1 0 0
3   1  0 0 0
4   1  0 0 0
attr(,assign)
[1] 0 1 2 2
attr(,contrasts)
attr(,contrasts)$A
[1] contr.treatment

attr(,contrasts)$B
[1] contr.treatment

 

How do I get model.matrix to not add that
column of zeroes?

Why does model.matrix add that column of zeroes?

Is this a bug, or a senior moment?





Steven McKinney

Statistician
Molecular Oncology and Breast Cancer Program
British Columbia Cancer Research Centre

email: [EMAIL PROTECTED]

tel: 604-675-8000 x7561

BCCRC
Molecular Oncology
675 West 10th Ave, Floor 4
Vancouver B.C. 
V5Z 1L3
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
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Design matrix question

2007-05-16 Thread Richard M. Heiberger
 with(df, interaction(A, B))
[1] a.b a.x x.x x.x
Levels: x.x a.x x.b a.b
 A.B - factor(with(df, interaction(A, B)))
 A.B
[1] a.b a.x x.x x.x
Levels: x.x a.x a.b
 model.matrix(~ A.B, df)
  (Intercept) A.B[T.a.x] A.B[T.a.b]
1   1  0  1
2   1  1  0
3   1  0  0
4   1  0  0
attr(,assign)
[1] 0 1 1
attr(,contrasts)
attr(,contrasts)$A.B
[1] contr.Treatment



__
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
and provide commented, minimal, self-contained, reproducible code.


[R] MICE for Cox model

2007-05-16 Thread Inman, Brant A. M.D.

R-helpers:

I have a dataset that has 168 subjects and 12 variables.  Some of the
variables have missing data and I want to use the multiple imputation
capabilities of the mice package to address the missing data. Given
that mice only supports linear models and generalized linear models (via
the lm.mids and glm.mids functions) and that I need to fit Cox models, I
followed the previous suggestion of John Fox and have created my own
function cox.mids to use coxph to fit models to the imputed datasets.

(http://tolstoy.newcastle.edu.au/R/help/06/03/22295.html)

The function I created is:



cox.mids - function (formula, data, ...)
{
call - match.call()
if (!is.mids(data)) 
stop(The data must have class mids)
analyses - as.list(1:data$m)
for (i in 1:data$m) {
data.i - complete(data, i)
analyses[[i]] - coxph(formula, data = data.i, ...)
}
object - list(call = call, call1 = data$call, nmis = data$nmis, 
analyses = analyses)
oldClass(object) - c(mira, coxph)
return(object)
}



The problem that I encounter occurs when I try to use the pool
function to pool the fitted models into one general model. Here is some
code that reproduces the error using the pbc dataset.



d - pbc[,c('time','status','age','sex','hepmeg','platelet', 'trt',
'trig')]
d[d==-9] - NA 
d[,c(4,5,7)] - lapply(d[,c(4,5,7)], FUN=as.factor)
str(d)

imp - mice(d, m=10, maxit=10, diagnostics=T, seed=500, 
defaultImputationMethod=c('norm', 'logreg', 'polyreg'))

fit - cox.mids(Surv(time,status) ~ age + sex + hepmeg + platelet + trt
+   trig, imp)

pool(fit)



I have looked at the pool function but cannot figure out what I have
done wrong.  Would really appreciate any help with this.

Thanks,

Brant Inman
Mayo Clinic

__
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
and provide commented, minimal, self-contained, reproducible code.