Re: [R] Calling LAPACK functions directly from R

2007-04-12 Thread Prof Brian Ripley
This was much more appropriate for R-devel, so please move any followup 
there.

On Wed, 11 Apr 2007, William Constantine wrote:

 I am interested in tapping into LAPACK functionality directly from R.
 Using R-2.4.1 for Windows, I was able to do so ala:

 dyn.load(bin/Rlapack.dll)
 is.loaded(dstebz) # returns TRUE

 N - 100
 NW - 4
 n.tapers - 5
 tpW - (2 * pi * NW)/N
 otNmo - 1:N
 D - as.double(cos(tpW) * ((N - 1 - 2 * (0:(N - 1)))/2)^2)
 E - as.double((otNmo * (N - otNmo))/2)

 z - .Fortran(dstebz,
  I, B, as.integer(N), double(1), double(1),
  as.integer(N - n.tapers + 1), as.integer(N), double(1),
  D, E, integer(1), integer(1), double(N), integer(N), integer(N),
  double(4 * N), integer(3 * N), integer(1))[13:15]

 I then extended this approach in developing an R package
 where I added the following to the appropriate .First.lib():

  lapack.path - file.path(R.home(), ifelse(.Platform$OS.type == windows,
file.path(bin, Rlapack), file.path(lib, libRlapack)))
  dyn.load(paste(lapack.path,.Platform$dynlib.ext, sep=))

 which loads the LAPACK shared objects in lib/libRlapack.so for LINUX/UNIX
 and bin/Rlapack.dll for Windows.

 Q1: Is there a better or more robust way of loading LAPACK symbols
 into R, (e.g., one that is not platform dependent)?

Why do you want to do that?  All uses of LAPACK in R itself are via small 
C wrappers that make life a lot easier.

 -

 My R package does not currently contain any C or FORTRAN code. However,
 it has been suggested to me that creating a src/Makevars file containing
 the line:

  PKG_LIBS=$(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

 is a better means of loading LAPACK symbols as it
 would eliminate the need to use dyn.load() as shown in my .First.lib().
 In Windows, however, this suggestion fails and results (for example)
 in the above code returning a missing dstebz symbol error. My understanding
 is that one need only create such a src/Makevar if they are interested in
 tapping into LAPACK functionality from their src/ C or FORTRAN code
 and so am doubtful of this suggestion.

 Q2: Given that I have no C/FORTRAN code in my package, am I
 correct to assume that creating a Makevars files in such a way
 does not eliminate the need to use dyn.load() as in the above?

 Q3: For future releases of R, should I expect the path of the LAPACK
 library to remain as they are noted above in my .First.lib() example?

It may not work even now.  Buiilds of R do not necessarily contain 
LAPACK code (you can link to an external library) even on Windows.

The portable way to link to LAPACK is to use a C wrapper as described in 
'Writing R Extensions'.


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

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


Re: [R] Looping through series of names

2007-04-12 Thread Petr PIKAL
Hallo

[EMAIL PROTECTED] napsal dne 11.04.2007 22:45:19:

 Hi
 I am very new to R and have not able to find the answer to my question
 in the manual or any other post.  I have a dataset that has various
 different sites names with data relating to each site.  The data is in
 one dataset.  I want to loop through the different site names and
 perform my test on each site.  The sites are named not numbers for
 example YYC.  How do I do this.  I hope I was clear enough.
 Thanks for the help 

Instead of looping try to look at aggregate, tapply or by. And give a 
quick look to posting guide where you can find some general rules and 
hints what to do before posting and how to formulate your question to get 
helpful answer.

Regards
Petr

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

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


[R] taskPR

2007-04-12 Thread Benno Willemsen
Hello

I tried to load the taskPR-package in R, but it doesn't work at all. 
Everytime I try /library(taskPR)/, I get the error-message:

Error in dyn.load(x, as.logical(local), as.logical(now)) :
   unable to load shared library 
'/home/bw135690/R-2.4.1/library/taskPR/libs/taskPR.so':
 /home/bw135690/R-2.4.1/library/taskPR/libs/taskPR.so: cannot open 
shared object file: No such file or directory
Error in library(taskPR) : .First.lib failed for 'taskPR'
Error in library.dynam.unload(taskPR, libpath) :
   shared library 'taskPR' was not loaded

But the problem is, that the file 
/home/bw135690/R-2.4.1/library/taskPR/libs/taskPR.so exists.
Furthermore the /library()/-Method shows, that the package is fully 
installed.
Can anyone tell me, what is wrong in the dyn.load-function and how to 
correct my installation

thanks
Benno Willemsen

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


[R] FFT output and phase

2007-04-12 Thread #HU GUANGAN#
I'm doing the time-series data analysis using FFT. After fft(), I used 
spectrum() to calculate the power spectrum, which is used to define the main 
frequency. Now I want to get the phase information according to this frequency. 
For example, input 12 time-point data,
 
d-c(1.2950487,0.8547907,0.5636902,0.3928039,0.4564737,0.2296953,-0.1319331,-0.3122781,-0.3773676,-0.5930794,-0.9185491,-1.3633293)
fft(d)
[1] 0.09596575+0.000i 0.84111080-4.3717147i 1.20570677-2.0131148i
[4] 1.86094684-1.7742100i 1.39627707-0.8900564i 1.57888778-0.3601454i
[7] 1.67875966+0.000i 1.57888778+0.3601454i 1.39627707+0.8900564i
[10] 1.86094684+1.7742100i 1.20570677+2.0131148i 0.84111080+4.3717147i
spectrum(fft(d))$freq
[1] 0.0833 0.1667 0.2500 0. 0.4167 0.5000
 spectrum(fft(d))$spec
[1] 0.9772920 1.6402597 0.8764470 0.6785063 0.9855313 0.7042088

here, if i used the g-test to define the main component is the second 
frequency. I want to calculate the phase of it (Max Phase). Then which complex 
value in fft output is used for the atan function ? The first and seventh 
values are real, seems they are DC and Nyquist frequency.
Your help should do me a big favor.
 
Thanks,
Guang'an Hu


[[alternative HTML version deleted]]

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


[R] Assignment from list

2007-04-12 Thread Eric Blanc
I have a list of groups of xy positions I want to set to 0 in an  
array full of 1s. When the assignments are done directly from the  
list, they are incorrect, while if I use a temporary array derived  
from the list the assignments are correct. The following example will  
hopefully make my problem clearer.

The matrices z and zz are initialised with 1. The z and zz values at  
coordinates in list x are then set to 0 using two different methods.  
Although either method should lead to the same results, z and zz are  
different. z is incorrect, because some values in its first row have  
been incorrectly set to 0.

x  - list( matrix( c( 9, 9, 74, 75 ), nrow=2 ),
 matrix( c( 11, 11, 34, 35 ), nrow=2 ),
 matrix( c( 14, 15, 58, 58 ), nrow=2 ),
 c( 16, 142 ),
 matrix( c( 19, 19, 94, 95 ), nrow=2 ),
 matrix( c( 19, 20, 127, 127 ), nrow=2 ),
 matrix( c( 22, 22, 112, 113 ), nrow=2 ),
 c( 23, 13 ),
 matrix( c( 26, 27, 81, 81 ), nrow=2 ),
 matrix( c( 31, 32, 153, 153 ), nrow=2 ) )
xx - do.call( rbind, x )

z - matrix( 1, ncol=249, nrow=240 )
zz - matrix( 1, ncol=249, nrow=240 )

for( k in x ) z[k] - 0
zz[xx] - 0

sum( z != zz )
c( sum( z[,1] != 1 ), sum( zz[,1] != 1 ) )

Somewhere, I must be doing something wrong, or assuming something  
incorrect. I would be very grateful if anybody could point me in the  
right direction.

platform   i386-apple-darwin8.8.1
arch   i386
os darwin8.8.1
system i386, darwin8.8.1
status
major  2
minor  4.1
year   2006
month  12
day18
svn rev40228
language   R
version.string R version 2.4.1 (2006-12-18)

(same results with platform i386-pc-mingw32, R version 2.4.1 and  
platform x86_64-unknown-linux-gnu, R version 2.3.1)

--
Dr Eric Blanc
Lecturer in Bioinformatics
MRC Centre for Developmental Neurobiology
King's College London
New Hunt's House Room 4.10B
Guy's Hospital Campus
London SE1 1UL

E-mail: [EMAIL PROTECTED]
Tel: +44 (0)20 7848 6532
Fax: +44 (0)20 7848 6550




[[alternative HTML version deleted]]

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


Re: [R] taskPR

2007-04-12 Thread Prof Brian Ripley
It would have been helpful to have given the details the R posting guide 
asks for, such as your OS.

That message probably does not mean that 
/home/bw135690/R-2.4.1/library/taskPR/libs/taskPR.so does not exist.
It says 'cannot open shared object file', and this can have many causes. 
One is that there are dependent shared objects which are missing, so start 
from

R CMD ldd /home/bw135690/R-2.4.1/library/taskPR/libs/taskPR.so

and see if all are resolved.

As far as I am aware package taskPR is based on private entry points in a 
version of R from long ago (it includes a copy of the private header file 
Defn.h from 2005) and is not really tested on CRAN (it uses 
--install=fake).


On Thu, 12 Apr 2007, Benno Willemsen wrote:

 Hello

 I tried to load the taskPR-package in R, but it doesn't work at all.
 Everytime I try /library(taskPR)/, I get the error-message:

 Error in dyn.load(x, as.logical(local), as.logical(now)) :
   unable to load shared library
 '/home/bw135690/R-2.4.1/library/taskPR/libs/taskPR.so':
 /home/bw135690/R-2.4.1/library/taskPR/libs/taskPR.so: cannot open
 shared object file: No such file or directory
 Error in library(taskPR) : .First.lib failed for 'taskPR'
 Error in library.dynam.unload(taskPR, libpath) :
   shared library 'taskPR' was not loaded

 But the problem is, that the file
 /home/bw135690/R-2.4.1/library/taskPR/libs/taskPR.so exists.
 Furthermore the /library()/-Method shows, that the package is fully
 installed.
 Can anyone tell me, what is wrong in the dyn.load-function and how to
 correct my installation

 thanks
 Benno Willemsen

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

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


[R] Tweaking my plot of matrix as image

2007-04-12 Thread Wee-Jin Goh
Greetings list,

I have a rectangular 20 x 20 matrix with values in the range of [0 ,  
1]. I'd like to plot it as an image. To that end, I have used the  
image() function that seems to do what I want. Now, I just want to  
tweak it to look perfect. So here is my question:

At the moment, the values of the axis range from [0, 1]. I want it to  
show the row and column of the matrix. How do I do that?

  Thanks in advance.

Wee-Jin

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


Re: [R] Assignment from list

2007-04-12 Thread Dimitris Rizopoulos
try the following:

z - matrix(1, ncol = 249, nrow = 240)
zz - matrix(1, ncol = 249, nrow = 240)
for (k in seq_along(x)) {
z[rbind(x[[k]])] - 0
}
zz[xx] - 0

all.equal(z, zz)


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: Eric Blanc [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Thursday, April 12, 2007 10:36 AM
Subject: [R] Assignment from list


I have a list of groups of xy positions I want to set to 0 in an
 array full of 1s. When the assignments are done directly from the
 list, they are incorrect, while if I use a temporary array derived
 from the list the assignments are correct. The following example 
 will
 hopefully make my problem clearer.

 The matrices z and zz are initialised with 1. The z and zz values at
 coordinates in list x are then set to 0 using two different methods.
 Although either method should lead to the same results, z and zz are
 different. z is incorrect, because some values in its first row have
 been incorrectly set to 0.

 x  - list( matrix( c( 9, 9, 74, 75 ), nrow=2 ),
 matrix( c( 11, 11, 34, 35 ), nrow=2 ),
 matrix( c( 14, 15, 58, 58 ), nrow=2 ),
 c( 16, 142 ),
 matrix( c( 19, 19, 94, 95 ), nrow=2 ),
 matrix( c( 19, 20, 127, 127 ), nrow=2 ),
 matrix( c( 22, 22, 112, 113 ), nrow=2 ),
 c( 23, 13 ),
 matrix( c( 26, 27, 81, 81 ), nrow=2 ),
 matrix( c( 31, 32, 153, 153 ), nrow=2 ) )
 xx - do.call( rbind, x )

 z - matrix( 1, ncol=249, nrow=240 )
 zz - matrix( 1, ncol=249, nrow=240 )

 for( k in x ) z[k] - 0
 zz[xx] - 0

 sum( z != zz )
 c( sum( z[,1] != 1 ), sum( zz[,1] != 1 ) )

 Somewhere, I must be doing something wrong, or assuming something
 incorrect. I would be very grateful if anybody could point me in the
 right direction.

 platform   i386-apple-darwin8.8.1
 arch   i386
 os darwin8.8.1
 system i386, darwin8.8.1
 status
 major  2
 minor  4.1
 year   2006
 month  12
 day18
 svn rev40228
 language   R
 version.string R version 2.4.1 (2006-12-18)

 (same results with platform i386-pc-mingw32, R version 2.4.1 and
 platform x86_64-unknown-linux-gnu, R version 2.3.1)

 --
 Dr Eric Blanc
 Lecturer in Bioinformatics
 MRC Centre for Developmental Neurobiology
 King's College London
 New Hunt's House Room 4.10B
 Guy's Hospital Campus
 London SE1 1UL

 E-mail: [EMAIL PROTECTED]
 Tel: +44 (0)20 7848 6532
 Fax: +44 (0)20 7848 6550




 [[alternative HTML version deleted]]

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


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

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


[R] LME: incompatible formulas for groups

2007-04-12 Thread Jan Thiele
Dear R-Users,

I am currently working with LME to analyse repeated measures data. I encounter 
a problem when including both a random effect and a correlation structure with 
different grouping levels into the LME model. The error message is:

Error in lme.formula(diameter ~ flowers*timef + competition*timef + 
population*timef,  : 
Incompatible formulas for groups in random and correlation.

The syntax for the model I want to calculate is as follows:

model- lme(diameter ~ flowers*timef + competition*timef + population*timef, 
data= Timeseries, 
  random= ~flowers|genotype, 
  weights= varIdent(form= ~1|timef), 
  correlation= corAR1(form= ~time|plantind)  )

The model works when I specify random effects and correlation at the same level 
of grouping (either genotype or plantind). But this does not make too much 
sense in this analysis.

The data structure (a subset of the whole data set is listed below):

“timef” is a factor with three levels (time points 1, 2, 3; repeated measures 
of the same individuals);
time is the same variable but in numerical format;
“genotype” is a factor with ca. 300 levels in the whole data set;
“plantind” is a factor with ca. 1200 levels in the whole data set;
“plantind” is nested in “genotype”;
flowers and competition are numerical variables and population is another 
factor (6 levels).

I have read Pinheiro and Bates (2000) and searched the web and R-help archive. 
The above mentioned error message appears to occur occasionally, but I could 
not find an answer how to avoid it.

Has anyone got an idea what the source of error might be in this case? I would 
be very thankful for any hints.

Regards,
Jan Thiele

University of Copenhagen
Faculty of Life Science
Rolighedsvej 21
1958 Frederiksberg C
Danmark

Subset of the whole data set (csv format):

Nr;diameter;flowers;competition;population;genotype;plantind;time;timef
14;1.05;0;-0.95;Baca;Baca13;14;1;1
1289;1.71;5;-1.29;Baca;Baca13;14;2;2
2546;1.16;0;-2.14;Baca;Baca13;14;3;3
21;0.55;0;-0.45;Baca;Baca12;21;1;1
1296;1.71;0;-1.79;Baca;Baca12;21;2;2
2553;-0.44;0;-2.04;Baca;Baca12;21;3;3
35;0.05;0;0.55;Baca;Baca22;35;1;1
1310;0.21;2;-0.29;Baca;Baca22;35;2;2
2567;0.86;0;0.86;Baca;Baca22;35;3;3
90;-0.95;10;1.05;Deru;Deru13;90;1;1
1364;-1.79;6;1.71;Deru;Deru13;90;2;2
106;0.05;1;0.55;Deru;Deru43;106;1;1
1379;-3.29;11;0.71;Deru;Deru43;106;2;2
120;-1.45;1;0.55;Deru;Deru80;120;1;1
1392;-3.79;0;1.71;Deru;Deru80;120;2;2
133;1.55;0;-0.45;Vejo;Vejo9;133;1;1
1405;2.21;0;-0.29;Vejo;Vejo9;133;2;2
2658;2.66;19;-0.34;Vejo;Vejo9;133;3;3
189;0.58;0;-3.42;Baca;Baca50;189;1;1
1461;1.44;0;-4.06;Baca;Baca50;189;2;2
2714;2.38;0;-5.23;Baca;Baca50;189;3;3
203;1.58;0;-0.42;Bile;Bile10;203;1;1
1475;0.94;0;-0.56;Bile;Bile10;203;2;2
2727;0.28;37;-4.43;Bile;Bile10;203;3;3
211;-0.92;0;-0.92;Bile;Bile2;211;1;1
1483;-1.06;0;-0.56;Bile;Bile2;211;2;2
2735;-0.02;23;3.08;Bile;Bile2;211;3;3
218;-0.42;0;0.58;Bile;Bile19;218;1;1
1489;-0.06;0;0.94;Bile;Bile19;218;2;2
2742;-1.53;1;-0.63;Bile;Bile19;218;3;3
221;-0.42;0;-0.42;Bile;Bile38;221;1;1
1492;0.44;0;0.44;Bile;Bile38;221;2;2
2745;-2.43;0;0.68;Bile;Bile38;221;3;3
240;-0.42;0;0.58;Bile;Bile43;240;1;1
1510;-0.56;0;-0.06;Bile;Bile43;240;2;2
2763;-3.43;2;-0.02;Bile;Bile43;240;3;3
261;0.08;0;2.08;Deru;Deru35;261;1;1
1531;-1.06;0;2.94;Deru;Deru35;261;2;2
2784;-5.03;0;-0.82;Deru;Deru35;261;3;3
264;-0.42;24;0.08;Deru;Deru25;264;1;1
1534;-3.06;3;0.44;Deru;Deru25;264;2;2
2787;-5.23;0;-0.02;Deru;Deru25;264;3;3
272;-2.42;1;0.58;Deru;Deru22;272;1;1
1542;-4.06;0;1.44;Deru;Deru22;272;2;2
2795;-5.23;0;2.78;Deru;Deru22;272;3;3
293;0.08;0;0.58;Vejo;Vejo9;293;1;1
1563;-0.56;0;1.94;Vejo;Vejo9;293;2;2
2815;-1.33;2;4.38;Vejo;Vejo9;293;3;3
308;-3.42;0;0.58;Vejo;Vejo54;308;1;1
1578;-4.06;0;2.44;Vejo;Vejo54;308;2;2
2829;-5.23;0;3.68;Vejo;Vejo54;308;3;3
313;-0.92;10;0.58;Vejo;Vejo27;313;1;1
1583;-1.06;8;1.44;Vejo;Vejo27;313;2;2
2834;-0.82;3;5.28;Vejo;Vejo27;313;3;3
338;-2.04;0;0.46;Baca;Baca27;338;1;1
1608;-3.73;0;1.27;Baca;Baca27;338;2;2
2858;-3.48;0;6.52;Baca;Baca27;338;3;3
340;-0.54;19;0.46;Baca;Baca33;340;1;1
1610;-0.23;8;-0.23;Baca;Baca33;340;2;2
2860;1.52;41;-0.48;Baca;Baca33;340;3;3
359;-0.04;0;2.96;Baca;Baca39;359;1;1
1628;-0.23;11;2.77;Baca;Baca39;359;2;2
2878;-1.48;4;2.52;Baca;Baca39;359;3;3
445;1.46;0;-0.04;Vejo;Vejo8;445;1;1
1711;1.27;2;-0.23;Vejo;Vejo8;445;2;2
2963;0.72;0;-0.98;Vejo;Vejo8;445;3;3
449;-1.04;5;0.96;Vejo;Vejo17;449;1;1
1715;-1.23;17;0.77;Vejo;Vejo17;449;2;2
2967;-2.38;10;-0.28;Vejo;Vejo17;449;3;3
476;-0.54;0;-0.04;Vejo;Vejo25;476;1;1
1742;-0.73;3;-0.23;Vejo;Vejo25;476;2;2
2994;-2.28;9;0.02;Vejo;Vejo25;476;3;3
480;-0.54;0;1.46;Vejo;Vejo21;480;1;1
1746;-0.23;1;1.77;Vejo;Vejo21;480;2;2
2998;-2.28;0;-0.48;Vejo;Vejo21;480;3;3
490;0.3;34;0.3;Baca;Baca10;490;1;1
1756;1.25;5;1.25;Baca;Baca10;490;2;2
3008;3.64;10;0.14;Baca;Baca10;490;3;3
505;-0.2;23;0.3;Baca;Baca32;505;1;1
1771;-0.25;23;0.25;Baca;Baca32;505;2;2
3022;-1.26;16;0.04;Baca;Baca32;505;3;3
518;0.8;29;0.3;Baca;Baca28;518;1;1

Re: [R] Tweaking my plot of matrix as image

2007-04-12 Thread Petr PIKAL
Hi

Did you by chance look at the help page of image? If you did, you could 
read


x,y
locations of grid lines at which the values in z are measured. These must 
be finite, non-missing and in (strictly) ascending order. By default, 
equally spaced values from 0 to 1 are used. If x is a list, its components 
x$x and x$y are used for x and y, respectively. If the list has component 
z this is used for z.
z
a matrix containing the values to be plotted (NAs are allowed). Note that 
x can be used instead of z for convenience.

and therefore

image(1:20, 1:20, your.matrix)

shall do what you probably want. And if you have different matrix size 
then

1:dim(your.matrix)[1]

can give you suitable sequence.

Regards

Petr Pikal
[EMAIL PROTECTED]

[EMAIL PROTECTED] napsal dne 12.04.2007 10:55:21:

 Greetings list,
 
 I have a rectangular 20 x 20 matrix with values in the range of [0 , 
 1]. I'd like to plot it as an image. To that end, I have used the 
 image() function that seems to do what I want. Now, I just want to 
 tweak it to look perfect. So here is my question:
 
 At the moment, the values of the axis range from [0, 1]. I want it to 
 show the row and column of the matrix. How do I do that?
 
   Thanks in advance.
 
 Wee-Jin
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Reasons to Use R

2007-04-12 Thread Jim Lemon
Charilaos Skiadas wrote:
 A new fortune candidate perhaps?
 
 On Apr 10, 2007, at 6:27 PM, Greg Snow wrote:
 
 
Remember, everything is better than everything else given the right
comparison.

Only if we remove the grammatical blip that turns it into an infinite 
regress, i.e.

Remember, anything is better than everything else given the right 
comparison

Jim

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


Re: [R] Tweaking my plot of matrix as image

2007-04-12 Thread Jim Lemon
Wee-Jin Goh wrote:
 Greetings list,
 
 I have a rectangular 20 x 20 matrix with values in the range of [0 ,  
 1]. I'd like to plot it as an image. To that end, I have used the  
 image() function that seems to do what I want. Now, I just want to  
 tweak it to look perfect. So here is my question:
 
 At the moment, the values of the axis range from [0, 1]. I want it to  
 show the row and column of the matrix. How do I do that?
 
Perhaps color2D.matplot will suit you. It automatically shows the row 
and column indices on the plot in the same order as conventional matrix 
displays.

Jim

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


[R] reporting multinomial logistic regression results

2007-04-12 Thread Bob Green
I am hoping to obtain information regarding the reporting of 
multinomial logistic regression results - either recommendations of 
published studies employing R or suggestions about what output should 
be reported. I am used to SPSS which routinely produces a broader 
range of output than R (e.g wald statistic p values, exp(B) and 
associated confidence intervals).

Below is the code I have been using for a series of analyses.

mod.multacute - multinom(offence ~ in.acute.danger * 
violent.convictions, data = kc,  na.action = na.omit)
summary(mod.multacute, cor=F, Wald=T)
Anova (mod.multacute)
predictors - expand.grid(in.acute.danger = c(y,n), 
violent.convictions = c(y,n))
p.fita - predict(mod.multacute, predictors, type='probs')


Any assistance is appreciated,

regards

Bob Green

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


[R] using install.packages via proxy

2007-04-12 Thread Erbe, Nicole
Hello everybody,

I'm trying to install rJava to use JRI in a Java program as JRI is a part of 
rJava. There should be the option to install this package via 
install.packages(rJava). Unfortunately I'm connected to the internet via a 
proxy. I have no idea how to tell R to connect via the proxy. The R-help tells 
me something about environment variables like http_proxy. But I have no idea 
how and where to set these variable as I'm new to R. I don't know whether this 
is the right way to solve my problem.

Is there anyone out there who knows how to solve this problem? Any help is 
appreciated.

Thank in advance

Nicole Erbe
Production Engineering
Verigy Germany GmbH
Herrenberger Str. 130
71034 Böblingen
Tel: +49 7031 4357327
Mail: [EMAIL PROTECTED]

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


Re: [R] Regression on two time series

2007-04-12 Thread rdporto1
Ron,

you're right. It's not legitimate at all. I suggest you
to take a look at the HUGE bibliography on cointegration,
as a start up.

Rogerio

 Dear all R user,
   
  Please forgive me if my question is too simple.
   
  My question is related to Statistics rather directly to R. Suppose I have 
 two time series of spot prices of two commodities X and Y for two years. Now 
 I want to see what percentage of spot price of X is explained by Y. Yes I can 
 fit a regression equation of X on Y. But my question is, is it legitimate? 
 Because both series are non-stationary with very high auto-correlation of 
 order 1. And regression analysis is basically designed for cross-sectional 
 data, not for time series data.
   
  Your help will be highly appreciable.
   
  Thanks and regards,
  Ron

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


Re: [R] Positioning in xyplot

2007-04-12 Thread Michael Kubovy
Wow! Thanks to Sundar and to Deepayan for this selfless effort.(I  
rather suspect they had a good time figuring this out.) The outcome  
is that I will be able to publish just the right figure for the job.  
I will be sure to aknowledge your contribtution.

Michael

On Apr 12, 2007, at 12:48 AM, Deepayan Sarkar wrote:

 On 4/11/07, Sundar Dorai-Raj [EMAIL PROTECTED] wrote:

 Hi, Deepayan,

 See the attached image for what your code produced. Not sure if  
 this is
 what you intended.

 Here's the correct version of callAfterMoving (I thought I had fixed
 it, but I guess I pasted the wrong thing):

 ## this calls 'fun' after moving its viewport if panel.number() == 5

 callAfterMoving -
   function(fun, border = TRUE, move.x = 1, ...)
 {
   if (panel.number() != 5) {  ## was == 5
   fun(...)
   if (border) grid.rect()
   }
   else {
   cpl - current.limits()
   pushViewport(viewport(x = move.x,
 width = unit(1, npc),
 xscale = cpl$xlim,
 yscale = cpl$ylim,
 clip = off))
   fun(...)
   if (border) grid.rect()
   upViewport()
   }
 }

 -Deepayan

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


Re: [R] using install.packages via proxy

2007-04-12 Thread Vladimir Eremeev

What operating system do you use?

If you use Windows, than open the Control Panel, double click on the System
icon, go to Advanced tab, press 
Environment variables button, then press New to create one more new
variable, enter http_proxy as the Name of variable, and
http://address.of.your.proxy:port; as its value.

In unix you should consult with your shell manual for the proper command and
proper startup script file
(in bash, this would be export and ~/.bash_profile)

You also could use Sys.putenv R function


Erbe, Nicole wrote:
 
 I'm trying to install rJava to use JRI in a Java program as JRI is a part
 of rJava. There should be the option to install this package via
 install.packages(rJava). Unfortunately I'm connected to the internet via
 a proxy. I have no idea how to tell R to connect via the proxy. The R-help
 tells me something about environment variables like http_proxy. But I
 have no idea how and where to set these variable as I'm new to R. I don't
 know whether this is the right way to solve my problem.
 
 Is there anyone out there who knows how to solve this problem? Any help is
 appreciated.
 

-- 
View this message in context: 
http://www.nabble.com/using-install.packages-via-proxy-tf3564991.html#a9958606
Sent from the R help mailing list archive at Nabble.com.

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


[R] data file import - numbers and letters in a matrix(!)

2007-04-12 Thread Felix Wave
Hello,
I have a problem with the import of a date file. I seems verry tricky.
I have a text file (end of the mail). Every file has a different number of 
measurments 
witch start with START OF HEIGHT DATA and ende with END OF HEIGHT DATA.

I imported the file in a matrix but the letters before the numbers are my 
problem 
(S= ,S=,x=,y=).
Because through the letters and the space after S= I got a different number
of columns in my matrix and with letters in my matrix I can't count.


My question. Is it possible to import the file to got 3 columns only with 
numbers and 
no letters like x=, y=?

Thank's a lot
Felix




My R Code:
--

# na.strings = S=

Measure1 - matrix(scan(data.dat, n= 5063 * 4, skip =   20, what = 
character() ), 5063, 3, byrow = TRUE)
Measure2 - matrix(scan(data.dat, n= 5063 * 4, skip = 5220, what = 
character() ), 5063, 3, byrow = TRUE)



My data file:
---

FILEDATE:02.02.2007
...

START OF HEIGHT DATA
S= 0 y=0.0 x=0.
S= 0 y=0.1 x=0.00055643
...
S= 9 y=4.9 x=1.67278117
S= 9 y=5.0 x=1.74873257
S=10 y=0.0 x=0.
S=10 y=0.1 x=0.00075557
...
S=99 y=5.3 x=1.94719490
END OF HEIGHT DATA
...

START OF HEIGHT DATA
S= 0 y=0.0 x=0.
S= 0 y=0.1 x=0.00055643



The imported matrix: 

  [,1]   [,2]   [,3]   [,4]  
 [6,] S=   9y=4.9x=1.67278117
 [7,] S=   9y=5.0x=1.74873257
 [8,] S=10 y=0.0x=0. S=10
 [9,] y=0.1x=0.00075557 S=10 y=0.2   
[10,] x=0.00277444 S=10 y=0.3x=0.00605958

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


Re: [R] using install.packages via proxy

2007-04-12 Thread Richard Gott
I had that problme and ended up downloading the package and installing 
locally.

there is probably a better way

Richard

Erbe, Nicole wrote:

Hello everybody,

I'm trying to install rJava to use JRI in a Java program as JRI is a part of 
rJava. There should be the option to install this package via 
install.packages(rJava). Unfortunately I'm connected to the internet via a 
proxy. I have no idea how to tell R to connect via the proxy. The R-help tells 
me something about environment variables like http_proxy. But I have no idea 
how and where to set these variable as I'm new to R. I don't know whether this 
is the right way to solve my problem.

Is there anyone out there who knows how to solve this problem? Any help is 
appreciated.

Thank in advance

Nicole Erbe
Production Engineering
Verigy Germany GmbH
Herrenberger Str. 130
71034 Böblingen
Tel: +49 7031 4357327
Mail: [EMAIL PROTECTED]

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


  


-- 
Richard Gott
Professor of Science Education
School of Education
Durham University

[EMAIL PROTECTED]
0191 3348 354

DISCLAIMER:\ \ This e-mail is intended solely for the addres...{{dropped}}

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


Re: [R] using install.packages via proxy

2007-04-12 Thread Erbe, Nicole

Hi,

I'm (currently forced to) use Win XP. I actually found an easy way to solve the 
problem of installing the rJava package. To avoid the problems with the proxy I 
just downloaded the zip file and installed the package in R from a local 
source. Now I can use the JRI libraries in eclipse by adding the jar to the 
path. It works fine. 

Using the libraries is now another issue...I will see how well it works and if 
the results are what I need.

Thanks a lot
 
Nicole Erbe
Production Engineering
Verigy Germany GmbH
Herrenberger Str. 130
71034 Böblingen
Tel: +49 7031 4357327
Mail: [EMAIL PROTECTED] 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Vladimir Eremeev
Sent: Donnerstag, 12. April 2007 14:41
To: [EMAIL PROTECTED]
Subject: Re: [R] using install.packages via proxy


What operating system do you use?

If you use Windows, than open the Control Panel, double click on the System
icon, go to Advanced tab, press 
Environment variables button, then press New to create one more new
variable, enter http_proxy as the Name of variable, and
http://address.of.your.proxy:port; as its value.

In unix you should consult with your shell manual for the proper command and
proper startup script file
(in bash, this would be export and ~/.bash_profile)

You also could use Sys.putenv R function


Erbe, Nicole wrote:
 
 I'm trying to install rJava to use JRI in a Java program as JRI is a part
 of rJava. There should be the option to install this package via
 install.packages(rJava). Unfortunately I'm connected to the internet via
 a proxy. I have no idea how to tell R to connect via the proxy. The R-help
 tells me something about environment variables like http_proxy. But I
 have no idea how and where to set these variable as I'm new to R. I don't
 know whether this is the right way to solve my problem.
 
 Is there anyone out there who knows how to solve this problem? Any help is
 appreciated.
 

-- 
View this message in context: 
http://www.nabble.com/using-install.packages-via-proxy-tf3564991.html#a9958606
Sent from the R help mailing list archive at Nabble.com.

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

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


Re: [R] using install.packages via proxy

2007-04-12 Thread Prof Brian Ripley
On Thu, 12 Apr 2007, Vladimir Eremeev wrote:

 What operating system do you use?

 If you use Windows, than open the Control Panel, double click on the System
 icon, go to Advanced tab, press
 Environment variables button, then press New to create one more new
 variable, enter http_proxy as the Name of variable, and
 http://address.of.your.proxy:port; as its value.

For Windows, the rw-FAQ has two much more comprehensive (and accurate) 
answers with examples!

[Please don't post partial answers to FAQs.]

 In unix you should consult with your shell manual for the proper command and
 proper startup script file
 (in bash, this would be export and ~/.bash_profile)

 You also could use Sys.putenv R function

Or the command line or .Renviron (preferred, I think).  Please do not set 
http_proxy globally: other programs may read it and have a different 
format.


 Erbe, Nicole wrote:

 I'm trying to install rJava to use JRI in a Java program as JRI is a part
 of rJava. There should be the option to install this package via
 install.packages(rJava). Unfortunately I'm connected to the internet via
 a proxy. I have no idea how to tell R to connect via the proxy. The R-help
 tells me something about environment variables like http_proxy. But I
 have no idea how and where to set these variable as I'm new to R. I don't
 know whether this is the right way to solve my problem.

 Is there anyone out there who knows how to solve this problem? Any help is
 appreciated.




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

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


Re: [R] Reasons to Use R

2007-04-12 Thread Joel J. Adamson
Douglas Bates writes:
  One
  can do data analysis by using the computer as a blunt instrument with
  which to bludgeon the problem to death but one can't do elegant data
  analysis like that.

One nice thing about a blunt instrument like Stata is the ability to
hold an entire dataset in memory and interactively play with the model
and generate new variables all in one session.  I figure out what I
want interactively and then separate the data management and analysis in
.do-files, then run them in batch mode.

However, when I first read of the approach of using Perl, sed or awk
to manage data and then only doing the analysis in R, I immediately
thought Wow, that is a really great idea, I never thought of it like
that before.  It would really get me to think about the modelling and
the data management clearly.  A little voice said Dude, you're not
using a PDP-11...(oh wait, that might be kinda cool) but the logic of
it immediately made sense.  I consider it a big part of my
re-Unix-ization.

Joel

-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109





The information transmitted in this electronic communication...{{dropped}}

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


Re: [R] Reasons to Use R

2007-04-12 Thread Lucke, Joseph F
A re-interpretation of Zorn's lemma? 

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jim Lemon
Sent: Thursday, April 12, 2007 5:14 AM
To: [EMAIL PROTECTED]
Subject: Re: [R] Reasons to Use R

Charilaos Skiadas wrote:
 A new fortune candidate perhaps?
 
 On Apr 10, 2007, at 6:27 PM, Greg Snow wrote:
 
 
Remember, everything is better than everything else given the right 
comparison.

Only if we remove the grammatical blip that turns it into an infinite
regress, i.e.

Remember, anything is better than everything else given the right
comparison

Jim

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

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


[R] pattern

2007-04-12 Thread Schmitt, Corinna
Dear R-experts,

I have the following function:

userInput - function() {  
   ANSWER - readline(saving place of the data (example
Z:/Software/test.mat)? )
   x = c(.mat)
   endingTest = x %in% ANSWER
   print (endingTest)
   if (endingTest == ??)
  cat (saving place not accepted\n)
   else 
  cat(Thank you! The current workspace will be stored in:
,ANSWER,\n\n)
   print(ANSWER )
}
filename = userInput()

Before I enter the if loop I must test if the text stored in ANSWER has
the pattern .mat. If yes than endingTest = TRUE else endingTest =
FALSE.

Another problem is the last codeline. Later on in my program I need the
userinput to ad it to another variable. How can I manage this. I get the
following error message:

saving place of the data (example Z:/Software/test.mat)? Z:/data.mat
[1] FALSE
Thank you! The current workspace will be stored in:  Z:/data.mat 

[1] Z:/data.mat
Error in as.vector(x, mode) : cannot change into vector


Thanks, Corinna

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


Re: [R] graphs superimposed on pictures?

2007-04-12 Thread Michael Dewey
At 14:39 11/04/2007, Robert Biddle wrote:
Hi:

I am doing some work that involves plotting points of interest
superimposed on photographs and maps. I can produce the plots fine 
in R, but so far
I have had to do the superimposition externally, which makes it 
tedious to do exploratory work.
I have looked to see if there is some capability to put a background 
picture on a plot window,
but I have not found anything.
Advice, anyone?

Although my situation was not exactly the same as yours you may find

http://finzi.psych.upenn.edu/R/Rhelp02a/archive/42884.html

a help

Cheers
Robert Biddle



Michael Dewey
http://www.aghmed.fsnet.co.uk

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


[R] Method dispatch for print() in package its

2007-04-12 Thread Albrecht, Dr. Stefan (AZ Private Equity Partner)
Dear all,
 
in the package its the print() method does not seem to correctly work in all 
circumstances:
 
 
 selectMethod(print, its)
Method Definition:
 
function (x, ...) 
{
print([EMAIL PROTECTED] mailto:[EMAIL PROTECTED] , ...)
}
environment: namespace:its
 
Signatures:
x
target  its
defined its

 
 
 fundPME.lst[[1]]$irr
An object of class its
 IRR  HSBC MEEM
2005-10-31 0.1926175 0.07802736
Slot dates:
[1] 2005-10-31 Westeuropäische Normalzeit
 
 
 [EMAIL PROTECTED]
 IRR  HSBC MEEM
2005-10-31 0.1926175 0.07802736
 
 
 print(fundPME.lst[[1]]$irr)
 IRR  HSBC MEEM
2005-10-31 0.1926175 0.07802736

 
So, is it necessary to define a print.its S3 method, or what should we do?
 
Many thanks and best regards,
Stefan
 

Dr. Stefan Albrecht, CFA
Allianz Private Equity Partners GmbH
Königinstr. 19 | 80539 Munich | Germany

Phone: +49.(0)89.3800.18317
Fax: +49.(0)89.3800.818317
EMail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 
Web: www.apep.com http://www.apep.com/ 


Allianz Private Equity Partners GmbH | Geschäftsführung: Wan Ching Ang, Karl 
Ralf Jung
Sitz der Gesellschaft: München | Registergericht: München HRB 126221 | 
Ust-ID-Nr.: DE 813 264 786

 

[[alternative HTML version deleted]]

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


Re: [R] data file import - numbers and letters in a matrix(!)

2007-04-12 Thread Gabor Grothendieck
Try pasting this into an R session:


Lines.raw - FILEDATE:02.02.2007
...

START OF HEIGHT DATA
S= 0 y=0.0 x=0.
S= 0 y=0.1 x=0.00055643
...
S= 9 y=4.9 x=1.67278117
S= 9 y=5.0 x=1.74873257
S=10 y=0.0 x=0.
S=10 y=0.1 x=0.00075557
...
S=99 y=5.3 x=1.94719490
END OF HEIGHT DATA
...

START OF HEIGHT DATA
S= 0 y=0.0 x=0.
S= 0 y=0.1 x=0.00055643


# next line would be replaced by
#  somthing like: Lines - readLines(myfile.dat)
Lines - readLines(textConnection(Lines.raw))

# extract those lines that contain an =
Lines - grep(=, Lines, value = TRUE)

# get col names by removing all but letters  spaces from line 1
cn - gsub([^a-zA-Z ], , Lines[1])
cn - scan(textConnection(cn), what = )

# remove anything that is not a number, dot or space and read in
Lines - gsub([^ .0-9], , Lines)
DF - read.table(textConnection(Lines), col.names = cn)
closeAllConnections()
DF




On 4/12/07, Felix Wave [EMAIL PROTECTED] wrote:
 Hello,
 I have a problem with the import of a date file. I seems verry tricky.
 I have a text file (end of the mail). Every file has a different number of 
 measurments
 witch start with START OF HEIGHT DATA and ende with END OF HEIGHT DATA.

 I imported the file in a matrix but the letters before the numbers are my 
 problem
 (S= ,S=,x=,y=).
 Because through the letters and the space after S= I got a different number
 of columns in my matrix and with letters in my matrix I can't count.


 My question. Is it possible to import the file to got 3 columns only with 
 numbers and
 no letters like x=, y=?

 Thank's a lot
 Felix




 My R Code:
 --

 # na.strings = S=

 Measure1 - matrix(scan(data.dat, n= 5063 * 4, skip =   20, what = 
 character() ), 5063, 3, byrow = TRUE)
 Measure2 - matrix(scan(data.dat, n= 5063 * 4, skip = 5220, what = 
 character() ), 5063, 3, byrow = TRUE)



 My data file:
 ---

 FILEDATE:02.02.2007
 ...

 START OF HEIGHT DATA
 S= 0 y=0.0 x=0.
 S= 0 y=0.1 x=0.00055643
 ...
 S= 9 y=4.9 x=1.67278117
 S= 9 y=5.0 x=1.74873257
 S=10 y=0.0 x=0.
 S=10 y=0.1 x=0.00075557
 ...
 S=99 y=5.3 x=1.94719490
 END OF HEIGHT DATA
 ...

 START OF HEIGHT DATA
 S= 0 y=0.0 x=0.
 S= 0 y=0.1 x=0.00055643



 The imported matrix:
 
  [,1]   [,2]   [,3]   [,4]
  [6,] S=   9y=4.9x=1.67278117
  [7,] S=   9y=5.0x=1.74873257
  [8,] S=10 y=0.0x=0. S=10
  [9,] y=0.1x=0.00075557 S=10 y=0.2
 [10,] x=0.00277444 S=10 y=0.3x=0.00605958

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


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


Re: [R] Method dispatch for print() in package its

2007-04-12 Thread Gabor Grothendieck
Without a reproducible example I can't tell what the problem is
but as a workaround you could print it as a zoo object:

library(its)
library(zoo)

# create an its object
example(its)
ii - its(mat, times)

# print it without using its' print
print(as.zoo(ii))

# or from the command line just
as.zoo(ii)


On 4/12/07, Albrecht, Dr. Stefan (AZ Private Equity Partner)
[EMAIL PROTECTED] wrote:
 Dear all,

 in the package its the print() method does not seem to correctly work in all 
 circumstances:


  selectMethod(print, its)
 Method Definition:

 function (x, ...)
 {
print([EMAIL PROTECTED] mailto:[EMAIL PROTECTED] , ...)
 }
 environment: namespace:its

 Signatures:
x
 target  its
 defined its



  fundPME.lst[[1]]$irr
 An object of class its
 IRR  HSBC MEEM
 2005-10-31 0.1926175 0.07802736
 Slot dates:
 [1] 2005-10-31 Westeuropäische Normalzeit


  [EMAIL PROTECTED]
 IRR  HSBC MEEM
 2005-10-31 0.1926175 0.07802736


  print(fundPME.lst[[1]]$irr)
 IRR  HSBC MEEM
 2005-10-31 0.1926175 0.07802736


 So, is it necessary to define a print.its S3 method, or what should we do?

 Many thanks and best regards,
 Stefan

 
 Dr. Stefan Albrecht, CFA
 Allianz Private Equity Partners GmbH
 Königinstr. 19 | 80539 Munich | Germany

 Phone: +49.(0)89.3800.18317
 Fax: +49.(0)89.3800.818317
 EMail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
 Web: www.apep.com http://www.apep.com/


 Allianz Private Equity Partners GmbH | Geschäftsführung: Wan Ching Ang, Karl 
 Ralf Jung
 Sitz der Gesellschaft: München | Registergericht: München HRB 126221 | 
 Ust-ID-Nr.: DE 813 264 786



[[alternative HTML version deleted]]


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



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


Re: [R] Method dispatch for print() in package its

2007-04-12 Thread Seth Falcon
Albrecht,  Dr. Stefan (AZ Private Equity Partner)
[EMAIL PROTECTED] writes:

 Dear all,
  
 in the package its the print() method does not seem to correctly
 work in all circumstances:

My understanding is that one should define only a method for the show
generic for S4 classes and leave print alone.

Not sure if that helps you.

+ seth

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

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


Re: [R] Reasons to Use R

2007-04-12 Thread Joel J. Adamson
Lucke, Joseph F writes:
  A re-interpretation of Zorn's lemma? 
  
  -Original Message-
  From: [EMAIL PROTECTED]
  [mailto:[EMAIL PROTECTED] On Behalf Of Jim Lemon
  Sent: Thursday, April 12, 2007 5:14 AM
  To: [EMAIL PROTECTED]
  Subject: Re: [R] Reasons to Use R
  
  Charilaos Skiadas wrote:
   A new fortune candidate perhaps?
   
   On Apr 10, 2007, at 6:27 PM, Greg Snow wrote:
   
   
  Remember, everything is better than everything else given the right 
  comparison.
  
  Only if we remove the grammatical blip that turns it into an infinite
  regress, i.e.
  
  Remember, anything is better than everything else given the right
  comparison
  
  Jim

Anything is potentially better than any other thing given the right
comparison.

Joel
-- 
Joel J. Adamson
Biostatistician
Pediatric Psychopharmacology Research Unit
Massachusetts General Hospital
Boston, MA  02114
(617) 643-1432
(303) 880-3109





The information transmitted in this electronic communication...{{dropped}}

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


Re: [R] Memory management

2007-04-12 Thread yoooooo

Okay thanks, I'm going through the docs now.. and I came through this.. 

The named field is set and accessed by the SET_NAMED and NAMED macros, and
take values 0, 1 and 2. R has a `call by value' illusion, so an assignment
like 
 b - a
appears to make a copy of a and refer to it as b. However, if neither a nor
b are subsequently altered there is no need to copy. What really happens is
that a new symbol b is bound to the same value as a and the named field on
the value object is set (in this case to 2). When an object is about to be
altered, the named field is consulted. A value of 2 means that the object
must be duplicated before being changed. 

What does it mean the new symbol b is bound to the same value as a. 
Does it mean b has a pointer pointing to a? 

Thanks!!
- yooo


yoo wrote:
 
 I guess I have more reading to do Are there any website that I can
 read up on memory management, or specifically what happen when we 'pass
 in' variables, which strategy is better at which situation? 
 
 Thanks~
 - y
 
 
 Prof Brian Ripley wrote:
 
 On Tue, 10 Apr 2007, yoo wrote:
 

 Hi all, I'm just curious how memory management works in R... I need to
 run an
 optimization that keeps calling the same function with a large set of
 parameters... so then I start to wonder if it's better if I attach the
 variables first vs passing them in (coz that involves a lot of copying..
 )
 
 Your paranethetical comment is wrong: no copying is needed to 'pass in' a 
 variable.
 
 Thus, I do this
 fn3 - function(x, y, z, a, b, c){ sum(x, y, z, a, b, c) }
 fn4 - function(){ sum(x, y, z, a, b, c) }

 rdn - rep(1.1, times=1e8)
 r - proc.time()
 for (i in 1:5)
  fn3(rdn, rdn, rdn, rdn, rdn, rdn)
 time1 - proc.time() - r
 print(time1)

 lt - list(x = rdn, y = rdn, z = rdn, a = rdn, b = rdn, c = rdn)
 attach(lt)
 r - proc.time()
 for (i in 1:5)
  fn4()
 time2 - proc.time() - r
 print(time2)
 detach(lt)

 The output is
 [1] 25.691  0.003 25.735  0.000  0.000
 [1] 25.822  0.005 25.860  0.000  0.000

 Turns out attaching takes longer to run.. which is counter intuitive
 (unless
 the search to the pos=2 envir takes long time as well) Do you guys know
 why
 this is the case?
 
 I would not trust timing differences of that nature: they often depend on 
 the state of the system, and in particular of the garbage collector.
 You should be using system.time() for that reason: it calls the garbage 
 collector immediately before timing.
 
 -- 
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Memory-management-tf3556238.html#a9961010
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] Method dispatch for print() in package its

2007-04-12 Thread Prof Brian Ripley

Setting S4 methods for print() works correctly, as in your examples.
Your first example does not call print(), so it is not suprising that no 
method dispatch takes place.


You seem to suppose that such a method should be used for top-level 
auto-printing, and it will not be as your example shows.  Auto-printing 
calls show() on S4 objects, and in this case show() is handling the object 
by its default method.


Note that if there is no S4 print method set, print(x) on an S4 object 'x' 
will in fact call show(x).  So had an S4 show() method been set, all three 
examples would have given the same output (via show()).




On Thu, 12 Apr 2007, Albrecht, Dr. Stefan (AZ Private Equity Partner) wrote:


Dear all,

in the package its the print() method does not seem to correctly work in all 
circumstances:



selectMethod(print, its)

Method Definition:

function (x, ...)
{
   print([EMAIL PROTECTED] mailto:[EMAIL PROTECTED] , ...)


(sic!)


}
environment: namespace:its

Signatures:
   x
target  its
defined its




fundPME.lst[[1]]$irr

An object of class its
IRR  HSBC MEEM
2005-10-31 0.1926175 0.07802736
Slot dates:
[1] 2005-10-31 Westeuropäische Normalzeit



[EMAIL PROTECTED]

IRR  HSBC MEEM
2005-10-31 0.1926175 0.07802736



print(fundPME.lst[[1]]$irr)

IRR  HSBC MEEM
2005-10-31 0.1926175 0.07802736


So, is it necessary to define a print.its S3 method, or what should we do?

Many thanks and best regards,
Stefan


Dr. Stefan Albrecht, CFA
Allianz Private Equity Partners GmbH
Königinstr. 19 | 80539 Munich | Germany

Phone: +49.(0)89.3800.18317
Fax: +49.(0)89.3800.818317
EMail: [EMAIL PROTECTED] mailto:[EMAIL PROTECTED]
Web: www.apep.com http://www.apep.com/


Allianz Private Equity Partners GmbH | Geschäftsführung: Wan Ching Ang, Karl 
Ralf Jung
Sitz der Gesellschaft: München | Registergericht: München HRB 126221 | 
Ust-ID-Nr.: DE 813 264 786



[[alternative HTML version deleted]]




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


[R] How to manipulate the pointer of a file?

2007-04-12 Thread Yuchen Luo
Dear friends.

With file( ) to obtain a pointer of a file,  every time we use scan ( ) to
read one row of it, the pointer will point to the next row of the file. In
the following example, d1 and d2 are obtained the same way but they
correspond to different rows of the same file because the pointer of the
file moves down a row when a row of the file is read.

 The following is an example:

 a1 - list(name=Fred, wife=Mary, no.children=3)

a2 - list(name=Tom, wife=Joy, no.children=9)

a3 - list(name=Paul, wife=Alic, no.children=5)


write.table(a1, file = tt.csv, sep=',',row.names=FALSE,col.name=TRUE)

write.table(a2, file=tt.csv, sep=',', append=TRUE, row.names=FALSE,
col.names=FALSE)

write.table(a3, file=tt.csv, sep=',', append=TRUE, row.names=FALSE,
col.names=FALSE)


fp=file(tt.csv,r)

 c=scan(file=fp, sep=',', what=list(c1=, c2=, c3=), flush=TRUE,
nlines=1)

 d1=scan(file=fp, sep=',', what=list(name=, wife=, no.kids=0),
flush=TRUE, nlines=1)

d1


R output:

---

$name

[1] Fred



$wife

[1] Mary



$no.kids

[1] 3

-

 d2=scan(file=fp, sep=',', what=list(name=, wife=, no.kids=0),
flush=TRUE, nlines=1)
d2



R Output:



$name

[1] Tom



$wife

[1] Joy



$no.kids

[1] 9

--

My question is, how to manipulate the pointer of the file further? For
example, what if I need the pointer to go back to the previous row?


Best Wishes

Yuchen Luo

[[alternative HTML version deleted]]

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


Re: [R] data file import - numbers and letters in a matrix(!)

2007-04-12 Thread Adaikalavan Ramasamy
Here is the contents of my testdata.txt :

-
START OF HEIGHT DATA
S= 0y=0.0 x=0.
S= 0 y=0.1 x=0.00055643
  S= 9 y=4.9 x=1.67278117
   S= 9 y=5.0 x=1.74873257
S=10   y=0.0   x=0.
 S=10y=0.1 x=0.00075557
S=99 y=5.3x=1.94719490
END OF HEIGHT DATA
-

If you have access to a shell command, you can try changing the input 
file for read.delim using

cat testdata.txt | grep -v ^START | grep -v ^END | sed 's/ //g' | 
sed 's/S=//' | sed 's/y=/\t/' | sed 's/x=/\t/'

or here is my ugly fix in R

  my.read.file - function(file=file){

   v1 - readLines( con=file, n=-1)
   v2 - v1[ - grep( ^START|^END, v1 ) ]
   v3 - gsub( , , v2)
   v4 - gsub( S=|y=|x=,  , v3 )
   v5 - gsub(^ , , v4)

   m  - t( sapply( strsplit(v5, split= ), as.numeric ) )
   colnames(m) - c(S, y, x )
   return(m)
  }

  my.read.file( testdata.txt )

Regards, Adai




Felix Wave wrote:
 Hello,
 I have a problem with the import of a date file. I seems verry tricky.
 I have a text file (end of the mail). Every file has a different number of 
 measurments 
 witch start with START OF HEIGHT DATA and ende with END OF HEIGHT DATA.
 
 I imported the file in a matrix but the letters before the numbers are my 
 problem 
 (S= ,S=,x=,y=).
 Because through the letters and the space after S= I got a different number
 of columns in my matrix and with letters in my matrix I can't count.
 
 
 My question. Is it possible to import the file to got 3 columns only with 
 numbers and 
 no letters like x=, y=?
 
 Thank's a lot
 Felix
 
 
 
 
 My R Code:
 --
 
 # na.strings = S=
 
 Measure1 - matrix(scan(data.dat, n= 5063 * 4, skip =   20, what = 
 character() ), 5063, 3, byrow = TRUE)
 Measure2 - matrix(scan(data.dat, n= 5063 * 4, skip = 5220, what = 
 character() ), 5063, 3, byrow = TRUE)
 
 
 
 My data file:
 ---
 
 FILEDATE:02.02.2007
 ...
 
 START OF HEIGHT DATA
 S= 0 y=0.0 x=0.
 S= 0 y=0.1 x=0.00055643
 ...
 S= 9 y=4.9 x=1.67278117
 S= 9 y=5.0 x=1.74873257
 S=10 y=0.0 x=0.
 S=10 y=0.1 x=0.00075557
 ...
 S=99 y=5.3 x=1.94719490
 END OF HEIGHT DATA
 ...
 
 START OF HEIGHT DATA
 S= 0 y=0.0 x=0.
 S= 0 y=0.1 x=0.00055643
 
 
 
 The imported matrix: 
   [,1]   [,2]   [,3]   [,4]  
  [6,] S=   9y=4.9x=1.67278117
  [7,] S=   9y=5.0x=1.74873257
  [8,] S=10 y=0.0x=0. S=10
  [9,] y=0.1x=0.00075557 S=10 y=0.2   
 [10,] x=0.00277444 S=10 y=0.3x=0.00605958
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 


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


Re: [R] how to reverse a list

2007-04-12 Thread Weiwei Shi
Thanks all of you!

But my next question is, how to improve R programming skills? I never
have time in improving it but I feel I need to.

Regards,

W

On 4/11/07, Seth Falcon [EMAIL PROTECTED] wrote:
 Weiwei Shi [EMAIL PROTECTED] writes:

  I forgot to add my bad solution here:
 
  reverseList - function(xlist){
blist - xlist[!is.na(xlist)]
x0 - unlist(blist)
l0 - length(blist)
d0 - as.data.frame(matrix(0, l0, 3))
d0[,1] - names(x0)
d0[,2] - x0
 

 There is a helper function in Biobase that does this:

 reverseSplit

   reverseSplit
  function (inList)
  {
  lens = sapply(inList, length)
  nms = rep(names(inList), lens)
  vals = unlist(inList)
  split(nms, vals)
  }
  environment: namespace:Biobase

 + seth

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

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



-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

Did you always know?
No, I did not. But I believed...
---Matrix III

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


Re: [R] pattern

2007-04-12 Thread Uwe Ligges


Schmitt, Corinna wrote:
 Dear R-experts,
 
 I have the following function:
 
 userInput - function() {  
ANSWER - readline(saving place of the data (example
 Z:/Software/test.mat)? )
x = c(.mat)
endingTest = x %in% ANSWER
print (endingTest)
if (endingTest == ??)
   cat (saving place not accepted\n)
else 
   cat(Thank you! The current workspace will be stored in:
 ,ANSWER,\n\n)
print(ANSWER )
 }
 filename = userInput()

Example:


userInput - function(){
   ANSWER - readline(saving place of the data (example 
Z:/Software/test.mat)?)
   endingTest -  length(grep(\\.mat$, ANSWER))
   if(!endingTest)
 cat(saving place not accepted\n)
   else
 cat(Thank you! The current workspace will be stored in:,
  ANSWER, \n\n)
}
filename -  userInput()


Uwe Ligges



 Before I enter the if loop I must test if the text stored in ANSWER has
 the pattern .mat. If yes than endingTest = TRUE else endingTest =
 FALSE.
 
 Another problem is the last codeline. Later on in my program I need the
 userinput to ad it to another variable. How can I manage this. I get the
 following error message:
 
 saving place of the data (example Z:/Software/test.mat)? Z:/data.mat
 [1] FALSE
 Thank you! The current workspace will be stored in:  Z:/data.mat 
 
 [1] Z:/data.mat
 Error in as.vector(x, mode) : cannot change into vector
 
 
 Thanks, Corinna
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


[R] zoo merge() method

2007-04-12 Thread Matthew.Findley
R users:

I'd like to get some insight on an error I encounter when attempting to
work with two moderately sized sets of time series data.  FYI - I'm
using the following versions of R and supporting packages on a Windows
2000 OS:

- R version 2.4.1 (2006-12-18) 
- zoo version 1.2-2
- chron version 2.3-10

The two time series I'm working with are from the summer of 2004 and
are: 
1.) wet.bulb.air.temp: air temperatures recorded on an hourly basis, and

2.) creek.temperature: surface water body temperatures collected every
12 minutes.

I would ultimately like to observe the difference in temperatures and
attempted to get at this by merging the two time series (by union),
interpolating the NAs, and finally, subtracting one vector from the
other.  The problem is that I can not combine the two zoo time series
objects using the merge() or cbind() functions.  I get the following
error:

Error in z[match0(index(a), indexes), ] - a[match0(indexes, index(a))]
: 
number of items to replace is not a multiple of replacement
length

The input/output from a recent R Console session might help, so I've
included it as follows:

 summary(creek.temperature)

 Index creek.temperature
 Min.   :(07/21/04 00:03:00)   Min.   :12.82
 1st Qu.:(08/11/04 03:00:00)   1st Qu.:16.28
 Median :(09/01/04 03:45:00)   Median :18.53
 Mean   :(09/01/04 04:45:13)   Mean   :18.87
 3rd Qu.:(09/22/04 06:37:00)   3rd Qu.:21.48
 Max.   :(10/13/04 09:22:00)   Max.   :27.72

 length(creek.temperature)

[1] 10140

 summary(wet.bulb.air.temp)

 Index wet.bulb.air.temp
 Min.   :(07/01/04 00:00:00)   Min.   : 3.889   
 1st Qu.:(07/31/04 12:00:00)   1st Qu.:12.778   
 Median :(08/31/04 00:00:00)   Median :14.444   
 Mean   :(08/31/04 00:00:00)   Mean   :14.469   
 3rd Qu.:(09/30/04 12:00:00)   3rd Qu.:16.667   
 Max.   :(10/31/04 00:00:00)   Max.   :22.222   

 length(wet.bulb.air.temp)

[1] 2929

 class(creek.temperature)

[1] zoo

 class(wet.bulb.air.temp)

[1] zoo

 merge(wet.bulb.air.temp, creek.temperature)

Error in z[match0(index(a), indexes), ] - a[match0(indexes, index(a))]
: 
number of items to replace is not a multiple of replacement
length

 cbind(wet.bulb.air.temp, creek.temperature)

Error in z[match0(index(a), indexes), ] - a[match0(indexes, index(a))]
: 
number of items to replace is not a multiple of replacement
length

The really puzzling part about this error is that it does not occur when
I pare down the data sets and only look at a 24 hour window of data (for
brevity, the input/output from that exercise has not been included in
this e-mail).

My question to the R user community is as follows:  What is this error?
How do I get past it and get these two data sets to play nice with each
other?

Thanks,

Matt Findley

-
Matthew C. Findley, CPSSc
Environmental Scientist
 
CH2M HILL
2300 NW Walnut Blvd
Corvallis, OR 97330-3538
 
Tel: 541.768.3504
Fax: 541.752.0276
 
[EMAIL PROTECTED]

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


Re: [R] How to manipulate the pointer of a file?

2007-04-12 Thread Prof Brian Ripley
On Thu, 12 Apr 2007, Yuchen Luo wrote:

 With file( ) to obtain a pointer of a file,  every time we use scan ( ) to
 read one row of it, the pointer will point to the next row of the file. In
 the following example, d1 and d2 are obtained the same way but they
 correspond to different rows of the same file because the pointer of the
 file moves down a row when a row of the file is read.

Yes, as documented.  Isn't that good?

[...]

 My question is, how to manipulate the pointer of the file further? For
 example, what if I need the pointer to go back to the previous row?

See ?seek, which is linked from the help page for file().

Using accurate terminology helps: file() gives you a connection.  Part of 
a connection is two positions (one each for read and write).

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

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


Re: [R] How to manipulate the pointer of a file?

2007-04-12 Thread Greg Snow
?seek

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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Yuchen Luo
 Sent: Thursday, April 12, 2007 9:33 AM
 To: [EMAIL PROTECTED]
 Subject: [R] How to manipulate the pointer of a file?
 
 Dear friends.
 
 With file( ) to obtain a pointer of a file,  every time we 
 use scan ( ) to read one row of it, the pointer will point to 
 the next row of the file. In the following example, d1 and d2 
 are obtained the same way but they correspond to different 
 rows of the same file because the pointer of the file moves 
 down a row when a row of the file is read.
 
  The following is an example:
 
  a1 - list(name=Fred, wife=Mary, no.children=3)
 
 a2 - list(name=Tom, wife=Joy, no.children=9)
 
 a3 - list(name=Paul, wife=Alic, no.children=5)
 
 
 write.table(a1, file = tt.csv, 
 sep=',',row.names=FALSE,col.name=TRUE)
 
 write.table(a2, file=tt.csv, sep=',', append=TRUE, row.names=FALSE,
 col.names=FALSE)
 
 write.table(a3, file=tt.csv, sep=',', append=TRUE, row.names=FALSE,
 col.names=FALSE)
 
 
 fp=file(tt.csv,r)
 
  c=scan(file=fp, sep=',', what=list(c1=, c2=, c3=), flush=TRUE,
 nlines=1)
 
  d1=scan(file=fp, sep=',', what=list(name=, wife=, 
 no.kids=0), flush=TRUE, nlines=1)
 
 d1
 
 
 R output:
 
 ---
 
 $name
 
 [1] Fred
 
 
 
 $wife
 
 [1] Mary
 
 
 
 $no.kids
 
 [1] 3
 
 -
 
  d2=scan(file=fp, sep=',', what=list(name=, wife=, 
 no.kids=0), flush=TRUE, nlines=1)
 d2
 
 
 
 R Output:
 
 
 
 $name
 
 [1] Tom
 
 
 
 $wife
 
 [1] Joy
 
 
 
 $no.kids
 
 [1] 9
 
 --
 
 My question is, how to manipulate the pointer of the file 
 further? For example, what if I need the pointer to go back 
 to the previous row?
 
 
 Best Wishes
 
 Yuchen Luo
 
   [[alternative HTML version deleted]]
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


[R] Subsetting list of vectors with list of (boolean) vectors?

2007-04-12 Thread Johannes Graumann
Dear Rologists,

I'm stuck with this. How would you do this efficiently:

 aPGI
[[1]]
[1] 864  5576


 aPGItest
[[1]]
[1]  TRUE FALSE

 result - [magic box involving subset)

 result
[[1]]
[1] 864

Thanks for any hints,

Joh

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


Re: [R] zoo merge() method

2007-04-12 Thread Achim Zeileis
On Thu, 12 Apr 2007 [EMAIL PROTECTED] wrote:

 attempted to get at this by merging the two time series (by union),
 interpolating the NAs, and finally, subtracting one vector from the
 other.  The problem is that I can not combine the two zoo time series
 objects using the merge() or cbind() functions.  I get the following
 error:

 Error in z[match0(index(a), indexes), ] - a[match0(indexes, index(a))]
 :
 number of items to replace is not a multiple of replacement
 length

Usually, problems like this occur when the time stamps in one of your time
series are not unique. Maybe we should improve the error message by
explicitely trying to catch this error.

You can easily check this, e.g., via
  any(table(time(zoo_object))  1)

 The input/output from a recent R Console session might help,

Not really, the data itself would have been much more helpful...and even
better some simplified artificial data set.

hth,
Z

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


Re: [R] Subsetting list of vectors with list of (boolean) vectors?

2007-04-12 Thread Marc Schwartz
On Thu, 2007-04-12 at 18:12 +0200, Johannes Graumann wrote:
 Dear Rologists,
 
 I'm stuck with this. How would you do this efficiently:
 
  aPGI
 [[1]]
 [1] 864  5576
 
 
  aPGItest
 [[1]]
 [1]  TRUE FALSE
 
  result - [magic box involving subset)
 
  result
 [[1]]
 [1] 864
 
 Thanks for any hints,
 
 Joh


 lapply(seq(along = length(aPGI)), function(x) aPGI[[x]][aPGItest[[x]]])
[[1]]
[1] 864


I think that this should be a generic solution for multiple (but common) levels 
in each list.

HTH,

Marc Schwartz

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


Re: [R] Subsetting list of vectors with list of (boolean) vectors?

2007-04-12 Thread Seth Falcon
Johannes Graumann [EMAIL PROTECTED] writes:

 Dear Rologists,

 I'm stuck with this. How would you do this efficiently:

 aPGI
 [[1]]
 [1] 864  5576


 aPGItest
 [[1]]
 [1]  TRUE FALSE

 result - [magic box involving subset)

result - aPGI[aPGItest[[1]]]

 result
 [[1]]
 [1] 864


+ seth

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

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


Re: [R] Subsetting list of vectors with list of (boolean) vectors?

2007-04-12 Thread Liaw, Andy
From: Marc Schwartz
 
 On Thu, 2007-04-12 at 18:12 +0200, Johannes Graumann wrote:
  Dear Rologists,
  
  I'm stuck with this. How would you do this efficiently:
  
   aPGI
  [[1]]
  [1] 864  5576
  
  
   aPGItest
  [[1]]
  [1]  TRUE FALSE
  
   result - [magic box involving subset)
  
   result
  [[1]]
  [1] 864
  
  Thanks for any hints,
  
  Joh
 
 
  lapply(seq(along = length(aPGI)), function(x) 
  aPGI[[x]][aPGItest[[x]]])
 [[1]]
 [1] 864

Alternatively:

R mapply([, aPGI, aPGItest, SIMPLIFY=FALSE)
[[1]]
[1] 864

Cheers,
Andy

 
 
 I think that this should be a generic solution for multiple 
 (but common) levels in each list.
 
 HTH,
 
 Marc Schwartz
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 
 
 


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

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


Re: [R] sas.get problem

2007-04-12 Thread John Kane

--- Tim Churches [EMAIL PROTECTED] wrote:

 John Kane wrote:
  I  have 3 SAS files all in the directory F:/sas,
 two
  data files
  and a format file :
  form.ea1.sas7bdat
  form.ea2.sas7bdat
  sas.fmts.sas7bdat
  
  F is a USB.
  
  I am trying import them to R using sas.get.
  
  I have not used SAS since I was downloading data
 from 
  mainframe
  and having to write JCL.  I had forgotten how
 bizarre
  SAS can be.
  I currently have not even figured out how to load
 the
  files into SAS but
  they look fine since I can import them with no
 problem
  into SPSS.
  
  I am using R2.4.1 under Windows XP
  SAS files were created with SAS 9.x
  They convert easily into SPSS 14
  
  I
  n the example below I have tried various versions
 of
  the file names with
  with no luck.
  Can anyone suggest some approach(s) that I might
 take.
  
  Example.
  
  library(Hmisc)
  mydata - sas.get(library=F:/sas,
 mem=form.ea1,
   format.library=sas.fmts.sas7bdat,
 sasprog = 'C:Program Files/SAS/SAS
  9.1/sas.exe')
  
  Error message  (one of several that I have gotten
  while trying various things.)
  The filename, directory name, or volume label
 syntax
  is incorrect.
  Error in sas.get(library = F:/sas, mem =
 form.ea1,
  format.library = sas.fmts.sas7bdat,  :
  SAS job failed with status 1
  In addition: Warning messages:
  1: sas.fmts.sas7bdat/formats.sc? or
 formats.sas7bcat 
  not found. Formatting ignored.
   in: sas.get(library = F:/sas, mem = form.ea1,
  format.library = sas.fmts.sas7bdat,
  2: 'cmd' execution failed with error code 1 in:
  shell(cmd, wait = TRUE, intern = output)
 
 The sas.get function in the Hmisc library is broken
 under Windows.
 
 Change line 127 from:
 
 status - sys(paste(shQuote(sasprog),
 shQuote(sasin), -log,
 shQuote(log.file)), output = FALSE)
 
 to:
 
 status - system(paste(shQuote(sasprog),
 shQuote(sasin), -log,
 shQuote(log.file)))
 


Just how would I go about making this change in the
code or where would I look?

Thanks




 I found this fix in the R-help archives, sorry,
 don't have the original
 to hand so I can't give proper attribution, but the
 fix is not due to
 me. But it does work for me. I believe Frank Harrell
 has been notified
 of the problem and the fix. Once patched and working
 correctly, the
 sas.get function in the Hmisc library is fantastic -
 thanks Frank!
 
 Tim C
 


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


[R] Construct time series objects from raw data stored in csv files

2007-04-12 Thread tom soyer
Hi,

I have time series data stored in csv files (see below for an example of the
data). I understand that in order to analyze my data in R, I need to first
transform it into a ts object. Howeve, I could not find an example on how
exactly to do that. Is ts the only function I need? What are the steps that
I need to go through to build a time series object from raw data like this?

Thanks,

Tom

--- DATE,VALUE
1921-01-01,19.000
1921-02-01,18.400
1921-03-01,18.300
1921-04-01,18.100
1921-05-01,17.700
1921-06-01,17.600
1921-07-01,17.700
1921-08-01,17.700
1921-09-01,17.500
1921-10-01,17.500
1921-11-01,17.400
1921-12-01,17.300
1922-01-01,16.900
1922-02-01,16.900
1922-03-01,16.700
1922-04-01,16.700
1922-05-01,16.700
1922-06-01,16.700
1922-07-01,16.800
1922-08-01,16.600
1922-09-01,16.600
1922-10-01,16.700
1922-11-01,16.800
1922-12-01,16.900

[[alternative HTML version deleted]]

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


[R] Putting 2 breaks on Y axis

2007-04-12 Thread Inman, Brant A. M.D.

R plotting experts:

I have a bivariate dataset composed of 300 (x,y) continuous datapoints.
297 of these points are located within the y range of [0,10], while 2
are located at 20 and one at 55.  No coding errors, real outliers.

When plotting these data with a scatterplot, I obviously have a problem.
If I plot the full dataset with ylim = c(0,55), then I cannot see the
structure in the data in the [0, 10] range.  If I truncate the y axis
with ylim = c(0,10), then I cannot see the 3 outliers.  If I break the y
axis from 10 to 20 (using plotrix functions), I still do not see the
data optimally because of the white space from y=20 to y=55.

What I would like to do is break the y axis at 2 points, roughly 10-20
and 20-55. Is there a function that can break an axis in 2 places?

Thanks in advance for any suggestions.

Brant

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


Re: [R] sas.get problem

2007-04-12 Thread John Kane
Cancel this! .  I see that Hmisc is already changed. 
When I updated today it was changed.  

My thanks to Mr Dupont the maintainer. 

I still have a problem with sas.get but that's another
post.  
--- John Kane [EMAIL PROTECTED] wrote:

 
 --- Tim Churches [EMAIL PROTECTED] wrote:
 
  John Kane wrote:
   I  have 3 SAS files all in the directory F:/sas,
  two
   data files
   and a format file :
   form.ea1.sas7bdat
   form.ea2.sas7bdat
   sas.fmts.sas7bdat
   
   F is a USB.
   
   I am trying import them to R using sas.get.
   
   I have not used SAS since I was downloading data
  from 
   mainframe
   and having to write JCL.  I had forgotten how
  bizarre
   SAS can be.
   I currently have not even figured out how to
 load
  the
   files into SAS but
   they look fine since I can import them with no
  problem
   into SPSS.
   
   I am using R2.4.1 under Windows XP
   SAS files were created with SAS 9.x
   They convert easily into SPSS 14
   
   I
   n the example below I have tried various
 versions
  of
   the file names with
   with no luck.
   Can anyone suggest some approach(s) that I might
  take.
   
   Example.
   
   library(Hmisc)
   mydata - sas.get(library=F:/sas,
  mem=form.ea1,
format.library=sas.fmts.sas7bdat,
  sasprog = 'C:Program Files/SAS/SAS
   9.1/sas.exe')
   
   Error message  (one of several that I have
 gotten
   while trying various things.)
   The filename, directory name, or volume label
  syntax
   is incorrect.
   Error in sas.get(library = F:/sas, mem =
  form.ea1,
   format.library = sas.fmts.sas7bdat,  :
   SAS job failed with status 1
   In addition: Warning messages:
   1: sas.fmts.sas7bdat/formats.sc? or
  formats.sas7bcat 
   not found. Formatting ignored.
in: sas.get(library = F:/sas, mem =
 form.ea1,
   format.library = sas.fmts.sas7bdat,
   2: 'cmd' execution failed with error code 1 in:
   shell(cmd, wait = TRUE, intern = output)
  
  The sas.get function in the Hmisc library is
 broken
  under Windows.
  
  Change line 127 from:
  
  status - sys(paste(shQuote(sasprog),
  shQuote(sasin), -log,
  shQuote(log.file)), output = FALSE)
  
  to:
  
  status - system(paste(shQuote(sasprog),
  shQuote(sasin), -log,
  shQuote(log.file)))
  
 
 
 Just how would I go about making this change in the
 code or where would I look?
 
 Thanks
 
 
 
 
  I found this fix in the R-help archives, sorry,
  don't have the original
  to hand so I can't give proper attribution, but
 the
  fix is not due to
  me. But it does work for me. I believe Frank
 Harrell
  has been notified
  of the problem and the fix. Once patched and
 working
  correctly, the
  sas.get function in the Hmisc library is fantastic
 -
  thanks Frank!
  
  Tim C
  
 
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


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


Re: [R] Construct time series objects from raw data stored in csv files

2007-04-12 Thread Achim Zeileis
On Thu, 12 Apr 2007, tom soyer wrote:

 Hi,

 I have time series data stored in csv files (see below for an example of the
 data). I understand that in order to analyze my data in R, I need to first
 transform it into a ts object. Howeve, I could not find an example on how
 exactly to do that. Is ts the only function I need? What are the steps that
 I need to go through to build a time series object from raw data like this?

With the zoo package you can do
  library(zoo)
  z - read.zoo(yourdata.csv, sep = ,)
  plot(z)

See
  vignette(zoo, package = zoo)
for more information and also some more details about other time series
classes.
Z

 Thanks,

 Tom

 --- DATE,VALUE
 1921-01-01,19.000
 1921-02-01,18.400
 1921-03-01,18.300
 1921-04-01,18.100
 1921-05-01,17.700
 1921-06-01,17.600
 1921-07-01,17.700
 1921-08-01,17.700
 1921-09-01,17.500
 1921-10-01,17.500
 1921-11-01,17.400
 1921-12-01,17.300
 1922-01-01,16.900
 1922-02-01,16.900
 1922-03-01,16.700
 1922-04-01,16.700
 1922-05-01,16.700
 1922-06-01,16.700
 1922-07-01,16.800
 1922-08-01,16.600
 1922-09-01,16.600
 1922-10-01,16.700
 1922-11-01,16.800
 1922-12-01,16.900

   [[alternative HTML version deleted]]

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



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


Re: [R] Construct time series objects from raw data stored in csv files

2007-04-12 Thread Gabor Grothendieck
On 4/12/07, tom soyer [EMAIL PROTECTED] wrote:
 Hi,

 I have time series data stored in csv files (see below for an example of the
 data). I understand that in order to analyze my data in R, I need to first
 transform it into a ts object. Howeve, I could not find an example on how
 exactly to do that. Is ts the only function I need? What are the steps that
 I need to go through to build a time series object from raw data like this?


Try pasting this into an R session:



Lines.raw - DATE,VALUE
1921-01-01,19.000
1921-02-01,18.400
1921-03-01,18.300
1921-04-01,18.100
1921-05-01,17.700
1921-06-01,17.600
1921-07-01,17.700
1921-08-01,17.700
1921-09-01,17.500
1921-10-01,17.500
1921-11-01,17.400
1921-12-01,17.300
1922-01-01,16.900
1922-02-01,16.900
1922-03-01,16.700
1922-04-01,16.700
1922-05-01,16.700
1922-06-01,16.700
1922-07-01,16.800
1922-08-01,16.600
1922-09-01,16.600
1922-10-01,16.700
1922-11-01,16.800
1922-12-01,16.900

library(zoo)
# replace next line with something like this:
#  z - read.zoo(myfile.dat, header = TRUE, sep = ,)
z - read.zoo(textConnection(Lines.raw), header = TRUE, sep = ,)
time(z) - as.yearmon(time(z))
as.ts(z)

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


Re: [R] Construct time series objects from raw data stored in csv files

2007-04-12 Thread tom soyer
Thanks Gabor!

I think your example works, but check this out:

 as.ts(z)
  Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
1921 19.0 18.4 18.3 18.1 17.7 17.6 17.7 17.7 17.5 17.5 17.4 17.3
1922 16.9 16.9 16.7 16.7 16.7 16.7 16.8 16.6 16.6 16.7 16.8 16.9
 is.ts(z)
[1] FALSE


How come R does not recognize z as a ts object? It is a ts object, isn't it?

On 4/12/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:

 On 4/12/07, tom soyer [EMAIL PROTECTED] wrote:
  Hi,
 
  I have time series data stored in csv files (see below for an example of
 the
  data). I understand that in order to analyze my data in R, I need to
 first
  transform it into a ts object. Howeve, I could not find an example on
 how
  exactly to do that. Is ts the only function I need? What are the steps
 that
  I need to go through to build a time series object from raw data like
 this?
 

 Try pasting this into an R session:



 Lines.raw - DATE,VALUE
 1921-01-01,19.000
 1921-02-01,18.400
 1921-03-01,18.300
 1921-04-01,18.100
 1921-05-01,17.700
 1921-06-01,17.600
 1921-07-01,17.700
 1921-08-01,17.700
 1921-09-01,17.500
 1921-10-01,17.500
 1921-11-01,17.400
 1921-12-01,17.300
 1922-01-01,16.900
 1922-02-01,16.900
 1922-03-01,16.700
 1922-04-01,16.700
 1922-05-01,16.700
 1922-06-01,16.700
 1922-07-01,16.800
 1922-08-01,16.600
 1922-09-01,16.600
 1922-10-01,16.700
 1922-11-01,16.800
 1922-12-01,16.900
 
 library(zoo)
 # replace next line with something like this:
 #  z - read.zoo(myfile.dat, header = TRUE, sep = ,)
 z - read.zoo(textConnection(Lines.raw), header = TRUE, sep = ,)
 time(z) - as.yearmon(time(z))
 as.ts(z)




-- 
Tom

[[alternative HTML version deleted]]

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


Re: [R] Construct time series objects from raw data stored in csv files

2007-04-12 Thread Gabor Grothendieck
On 4/12/07, tom soyer [EMAIL PROTECTED] wrote:
 Thanks Gabor!

 I think your example works, but check this out:

  as.ts(z)
   Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
 1921 19.0 18.4 18.3 18.1 17.7 17.6 17.7 17.7 17.5 17.5 17.4 17.3
 1922 16.9 16.9 16.7 16.7 16.7 16.7 16.8 16.6 16.6 16.7 16.8 16.9
  is.ts(z)
 [1] FALSE

The above outputs as.ts(z) on the console.  If you want to
assign it to a variable you need to do so:

tz - as.ts(z)
is.ts(tz) # TRUE

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


Re: [R] Construct time series objects from raw data stored in csv files

2007-04-12 Thread tom soyer
Oh yes, I forgot. Thanks!!

On 4/12/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:

 On 4/12/07, tom soyer [EMAIL PROTECTED] wrote:
  Thanks Gabor!
 
  I think your example works, but check this out:
 
   as.ts(z)
Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
  1921 19.0 18.4 18.3 18.1 17.7 17.6 17.7 17.7 17.5 17.5 17.4 17.3
  1922 16.9 16.9 16.7 16.7 16.7 16.7 16.8 16.6 16.6 16.7 16.8 16.9
   is.ts(z)
  [1] FALSE

 The above outputs as.ts(z) on the console.  If you want to
 assign it to a variable you need to do so:

 tz - as.ts(z)
 is.ts(tz) # TRUE




-- 
Tom

[[alternative HTML version deleted]]

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


Re: [R] Construct time series objects from raw data stored in csv files

2007-04-12 Thread tom soyer
Gabor,

What should I do for weekly and daily data series? Are there functions
similar to yearmon() for other time intervals? I see that there is a
built-in yearqtr() function for quarterly data, but that's it.

Thanks!

On 4/12/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:

 On 4/12/07, tom soyer [EMAIL PROTECTED] wrote:
  Thanks Gabor!
 
  I think your example works, but check this out:
 
   as.ts(z)
Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
  1921 19.0 18.4 18.3 18.1 17.7 17.6 17.7 17.7 17.5 17.5 17.4 17.3
  1922 16.9 16.9 16.7 16.7 16.7 16.7 16.8 16.6 16.6 16.7 16.8 16.9
   is.ts(z)
  [1] FALSE

 The above outputs as.ts(z) on the console.  If you want to
 assign it to a variable you need to do so:

 tz - as.ts(z)
 is.ts(tz) # TRUE




-- 
Tom

[[alternative HTML version deleted]]

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


Re: [R] Putting 2 breaks on Y axis

2007-04-12 Thread Marc Schwartz
On Thu, 2007-04-12 at 13:41 -0500, Inman, Brant A. M.D. wrote:
 R plotting experts:
 
 I have a bivariate dataset composed of 300 (x,y) continuous datapoints.
 297 of these points are located within the y range of [0,10], while 2
 are located at 20 and one at 55.  No coding errors, real outliers.
 
 When plotting these data with a scatterplot, I obviously have a problem.
 If I plot the full dataset with ylim = c(0,55), then I cannot see the
 structure in the data in the [0, 10] range.  If I truncate the y axis
 with ylim = c(0,10), then I cannot see the 3 outliers.  If I break the y
 axis from 10 to 20 (using plotrix functions), I still do not see the
 data optimally because of the white space from y=20 to y=55.
 
 What I would like to do is break the y axis at 2 points, roughly 10-20
 and 20-55. Is there a function that can break an axis in 2 places?
 
 Thanks in advance for any suggestions.
 
 Brant


Brant, 

I am not a particular fan of broken axes (though others will disagree),
much less two breaks.

Presuming that your data might look something like this:

http://www.itl.nist.gov/div898/handbook/eda/section3/scattera.htm

A couple of thoughts:

1. Not being sure if your data range above actually includes 0, you may
want to consider a log scaled axis, if not.

2. I might be tempted to use two plots:

  A. A first a plot of the entire data set, showing the 3 outliers

  B. A second plot of the 297 pairs with axes constrained to the
 appropriate ranges to enable better visualization of the data
 structure.

If number 2 is more appropriate, you could also use par(mfcol) to set
up side by side plots. See ?par.

HTH,

Marc Schwartz

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


[R] making a counter of consecitive positive cases in time series

2007-04-12 Thread Jose Bustos Melo
Hi all..RCounters!
   
  I´m working with standarized time series, and i need make a counter of 
consecutives positves numbers to  make a cumulative experimental funtion. I 
have x: the time series (0,1) and y: my counter, i have this for step. What is 
wrong?.. any can help me please!
   
  x-rbinom(15,1,.3)
  y-NULL;s-0
  for (i in 1: length (x))
  {if (x[i]0)
  {s-s+x[i]
  s=0}
  else
  y-c(y,s)}
  y
  x
   
   
  Thk u all!
  José Bustos
   
   

   
-




[[alternative HTML version deleted]]

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


Re: [R] Putting 2 breaks on Y axis

2007-04-12 Thread Stephen Weigand
On 4/12/07, Marc Schwartz [EMAIL PROTECTED] wrote:
 On Thu, 2007-04-12 at 13:41 -0500, Inman, Brant A. M.D. wrote:
  R plotting experts:
 
  I have a bivariate dataset composed of 300 (x,y) continuous datapoints.
  297 of these points are located within the y range of [0,10], while 2
  are located at 20 and one at 55.  No coding errors, real outliers.
 
  When plotting these data with a scatterplot, I obviously have a problem.
  If I plot the full dataset with ylim = c(0,55), then I cannot see the
  structure in the data in the [0, 10] range.  If I truncate the y axis
  with ylim = c(0,10), then I cannot see the 3 outliers.  If I break the y
  axis from 10 to 20 (using plotrix functions), I still do not see the
  data optimally because of the white space from y=20 to y=55.
 
  What I would like to do is break the y axis at 2 points, roughly 10-20
  and 20-55. Is there a function that can break an axis in 2 places?
 
  Thanks in advance for any suggestions.
 
  Brant


 Brant,

 I am not a particular fan of broken axes (though others will disagree),
 much less two breaks.

 Presuming that your data might look something like this:

 http://www.itl.nist.gov/div898/handbook/eda/section3/scattera.htm

 A couple of thoughts:

 1. Not being sure if your data range above actually includes 0, you may
 want to consider a log scaled axis, if not.

 2. I might be tempted to use two plots:

   A. A first a plot of the entire data set, showing the 3 outliers

   B. A second plot of the 297 pairs with axes constrained to the
  appropriate ranges to enable better visualization of the data
  structure.

 If number 2 is more appropriate, you could also use par(mfcol) to set
 up side by side plots. See ?par.

 HTH,

 Marc Schwartz


I was thinking plot the data without the outliers and include a
smaller inscribed plot in a corner showing all the data (the global
view). But I couldn't figure out how to do this.

(I think legend() works very hard to do this type of thing.)

Stephen

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


[R] LME: internal workings of QR factorization --repost

2007-04-12 Thread Izmirlian, Grant \(NIH/NCI\) [E]

Hi:

I've been reading Computational Methods for Multilevel Modeling by Pinheiro 
and Bates, 
the idea of embedding the technique in my own c-level code. The basic idea is 
to rewrite 
the joint density in a form to mimic a single least squares problem conditional 
upon the 
variance parameters.  The paper is fairly clear except that some important 
level of detail 
is missing. For instance, when we first meet Q_(i):

/\  / \
| Z_i X_i   y_i  |  | R_11(i) R_10(i) c_1(i)  |
|| = Q_(i)  | |
| Delta   0 0|  |   0 R_00(i) c_0(i)  |
\/  \ /

the text indicates that the Q-R factorization is limited to the first q columns 
of the 
augmented matrix on the left.  If one plunks the first q columns of the 
augmented matrix 
on the left into a qr factorization, one obtains an orthogonal matrix Q that is 
(n_i + q) x q 
and a nonsingular upper triangular matrix R that is q x q.  While the text 
describes R as a 
nonsingular upper triangular q x q, the matrix Q_(i) is described as a square 
(n_i + q) x (n_i + q) 
orthogonal matrix.  The remaining columns in the matrix to the right are 
defined by applying 
transpose(Q_(i)) to both sides.  The question is how to augment my Q which is 
orthogonal (n_i + q) x q  
with the missing (n_i + q) x n_i portion producing the orthogonal square matrix 
mentioned in the text?  
I tried appending the n_i x n_i identity matrix to the block diagonal, but this 
doesn't work as the 
resulting likelihood is insensitive to the variance parameters.

Grant Izmirlian
NCI

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


Re: [R] Putting 2 breaks on Y axis

2007-04-12 Thread Greg Snow
Try something like this (modify to how you like it):

x - runif(100)
y - rnorm(100, 5, 2)
 
y[1:3] - c(19, 21, 50)

layout(matrix( 3:1, ncol=1 ), heights=c(2,3,4))

par(mar=c(5,4,0,2)+0.1)
plot(x,y, ylim=c(0,10), ylab='')

par(mar=c(0.5,4,0,2)+0.1)
plot(x,y, ylim=c(18,22), xlab='', xaxt='n' )
axis(1, labels=FALSE)

par(mar=c(0.5,4,4,2)+0.1) 
plot(x,y, ylim=c(49,51),xlab='', main='my title', xaxt='n', ylab='' )
axis(1, labels=FALSE)


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

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Inman, 
 Brant A. M.D.
 Sent: Thursday, April 12, 2007 12:41 PM
 To: [EMAIL PROTECTED]
 Subject: [R] Putting 2 breaks on Y axis
 
 
 R plotting experts:
 
 I have a bivariate dataset composed of 300 (x,y) continuous 
 datapoints.
 297 of these points are located within the y range of [0,10], 
 while 2 are located at 20 and one at 55.  No coding errors, 
 real outliers.
 
 When plotting these data with a scatterplot, I obviously have 
 a problem.
 If I plot the full dataset with ylim = c(0,55), then I cannot 
 see the structure in the data in the [0, 10] range.  If I 
 truncate the y axis with ylim = c(0,10), then I cannot see 
 the 3 outliers.  If I break the y axis from 10 to 20 (using 
 plotrix functions), I still do not see the data optimally 
 because of the white space from y=20 to y=55.
 
 What I would like to do is break the y axis at 2 points, 
 roughly 10-20 and 20-55. Is there a function that can break 
 an axis in 2 places?
 
 Thanks in advance for any suggestions.
 
 Brant
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] Putting 2 breaks on Y axis

2007-04-12 Thread Jim Lemon
Inman, Brant A. M.D. wrote:
 R plotting experts:
 
 I have a bivariate dataset composed of 300 (x,y) continuous datapoints.
 297 of these points are located within the y range of [0,10], while 2
 are located at 20 and one at 55.  No coding errors, real outliers.
 
 When plotting these data with a scatterplot, I obviously have a problem.
 If I plot the full dataset with ylim = c(0,55), then I cannot see the
 structure in the data in the [0, 10] range.  If I truncate the y axis
 with ylim = c(0,10), then I cannot see the 3 outliers.  If I break the y
 axis from 10 to 20 (using plotrix functions), I still do not see the
 data optimally because of the white space from y=20 to y=55.
 
 What I would like to do is break the y axis at 2 points, roughly 10-20
 and 20-55. Is there a function that can break an axis in 2 places?
 
Hi Brant,

gap.plot in the plotrix package can do one break, and it is possible to 
do two, as gap.boxplot does. It wouldn't be too difficult to recode 
gap.plot to get more than one break. I'll see what I can do today.

Jim

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


[R] LME: internal workings of QR factorization

2007-04-12 Thread Izmirlian, Grant \(NIH/NCI\) [E]
Hi:

I've been reading Computational Methods for Multilevel Modeling by Pinheiro 
and Bates, the idea of embedding the technique in my own c-level code. The 
basic idea is to rewrite the joint density in a form to mimic a single least 
squares problem conditional upon the variance parameters.  The paper is fairly 
clear except that some important level of detail is missing. For instance, when 
we first meet Q_(i):

/\  / \
| Z_i X_i   y_i  |  | R_11(i) R_10(i) c_1(i)  |
|| = Q_(i)  | |
| Delta   0 0|  |   0 R_00(i) c_0(i)  |
\/  \ /

the text indicates that the Q-R factorization is limited to the first q columns 
of the augmented matrix on the left.  If one plunks the first
q columns of the augmented matrix on the left into a qr factorization, one 
obtains an orthogonal matrix Q that is (n_i + q) x q and a nonsingular upper 
triangular matrix R that is q x q.  While the text describes R as a nonsingular 
upper triangular q x q, the matrix Q_(i) is described as a square (n_i + q) x 
(n_i + q) orthogonal matrix.  The remaining columns in the matrix to the right 
are defined by applying transpose(Q_(i)) to both sides.  The question is how to 
augment my Q which is orthogonal (n_i + q) x q  with the missing (n_i + q) x 
n_i portion producing the orthogonal square matrix mentioned in the text?  I 
tried appending the n_i x n_i identity matrix to the block diagonal, but this 
doesn't work as the resulting likelihood is insensitive to the variance 
parameters.

Grant Izmirlian
NCI

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


[R] Random Sequence

2007-04-12 Thread Anup Nandialath
Dear Friends,

I'm trying to generate a sequence of 100 observations
with either a 1 or -1. In other words the sequence
should look something like this.

y = 1 1 -1 1 -1 -1 -1 1 1 ..

Can somebody please give me some direction on how I
can do this in R.

Thanks

Anup


   

Don't get soaked.  Take a quick peak at the forecast

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


Re: [R] Random Sequence

2007-04-12 Thread Matthew Keller
Hi Anup,

(runif(100).5)*1   #would give you 0's and 1's.

sample(rep(c(-1,1),50),100)  #A bit slower I think, gives you -1's and 1's


Best,

Matt

On 4/12/07, Anup Nandialath [EMAIL PROTECTED] wrote:
 Dear Friends,

 I'm trying to generate a sequence of 100 observations
 with either a 1 or -1. In other words the sequence
 should look something like this.

 y = 1 1 -1 1 -1 -1 -1 1 1 ..

 Can somebody please give me some direction on how I
 can do this in R.

 Thanks

 Anup



 
 Don't get soaked.  Take a quick peak at the forecast

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



-- 
Matthew C Keller
Postdoctoral Fellow
Virginia Institute for Psychiatric and Behavioral Genetics

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


Re: [R] Random Sequence

2007-04-12 Thread Peter Dalgaard
Anup Nandialath wrote:
 Dear Friends,

 I'm trying to generate a sequence of 100 observations
 with either a 1 or -1. In other words the sequence
 should look something like this.

 y = 1 1 -1 1 -1 -1 -1 1 1 ..

 Can somebody please give me some direction on how I
 can do this in R.
   
sample(c(-1, 1), 100, replace=TRUE)

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


Re: [R] Random Sequence

2007-04-12 Thread Francisco J. Zagmutt
There are many ways to do this.
The first that comes to my mind is sample(c(1,-1),100,TRUE).  Notice 
that sample also has a prob argument that may be useful for you.

Francisco




Anup Nandialath wrote:
 Dear Friends,
 
 I'm trying to generate a sequence of 100 observations
 with either a 1 or -1. In other words the sequence
 should look something like this.
 
 y = 1 1 -1 1 -1 -1 -1 1 1 ..
 
 Can somebody please give me some direction on how I
 can do this in R.
 
 Thanks
 
 Anup
 
 

 
 Don't get soaked.  Take a quick peak at the forecast
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


Re: [R] Putting 2 breaks on Y axis

2007-04-12 Thread Greg Snow
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Stephen Weigand
 Sent: Thursday, April 12, 2007 2:32 PM
 To: Inman, Brant A. M.D.
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] Putting 2 breaks on Y axis
 

[snip]

 
 I was thinking plot the data without the outliers and include 
 a smaller inscribed plot in a corner showing all the data 
 (the global view). But I couldn't figure out how to do this.
 
 (I think legend() works very hard to do this type of thing.)

This is fairly easy to do with the subplot function in the TeachingDemos
package:


 
 Stephen
 




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

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


Re: [R] Random Sequence

2007-04-12 Thread Nordlund, Dan (DSHS/RDA)
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Matthew Keller
 Sent: Thursday, April 12, 2007 2:32 PM
 To: Anup Nandialath
 Cc: [EMAIL PROTECTED]
 Subject: Re: [R] Random Sequence
 
 Hi Anup,
 
 (runif(100).5)*1   #would give you 0's and 1's.
 
 sample(rep(c(-1,1),50),100)  #A bit slower I think, gives you 
 -1's and 1's
 

How about

  sample(c(-1,1), 100, replace=TRUE) 

Hope this is helpful,

Dan

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

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


[R] GLM with random effects

2007-04-12 Thread Brendan Connors
Hi R-Users,

I have 3 replicates ('Replicate) of counts of parasites ('nor.tot.lep') 
before and after an experiment ('In.Out'). I am trying to treat the 
three replicates as a random effect in order to determine if the main 
effect (In.Out) significantly influences my dependent variable 
(nor.tot.lep) after the variance explained by the replicates is 
accounted for. I have tried:

 lmer(nor.tot.lep ~ In.Out + (In.Out|Replicate),data=coho, family=poisson)
Generalized linear mixed model fit using PQL
Formula: nor.tot.lep ~ In.Out + (In.Out | Replicate)
Data: coho
Family: Poisson
AIC BIC logLik deviance
849.2 867.4 -419.6 839.2
Random effects:
Groups Name Variance Std.Dev. Corr
Replicate (Intercept) 0.78861 0.88804
In.Out 0.67232 0.81995 -1.000
Residual 2.96308 1.72136
number of obs: 279, groups: Replicate, 3

Fixed effects:
Estimate Std. Error t value
(Intercept) -0.2431 0.6619 -0.3672
In.Out 1.6004 0.5645 2.8349

Correlation of Fixed Effects:
(Intr)
In.Out -0.975
There were 30 warnings (use warnings() to see them)

  warnings()
Warning messages:
1: Estimated variance-covariance for factor ‘Replicate’ is singular
in: LMEopt(x = mer, value = cv)
2: nlminb returned message false convergence (8)
in: LMEopt(x = mer, value = cv)

but as Mr. Bates pointed out, this is inappropriate b/c I am trying to 
use 3 distinct replicates to estimate 3 variance-covariance
parameters. It won't work. Notice that the estimated correlation is
-1.000. Your estimated variance-covariance matrix is singular

I have also tried:

 glmmPQL(nor.tot.lep ~ In.Out, random = (In.Out|Replicate), family = 
poisson, data = coho)

Error in glmmPQL(nor.tot.lep ~ In.Out, random = (In.Out | Replicate), :
object In.Out not found

and R cannot find In.Out

If anyone has any suggestions they would be extremely appreciated!

Cheers,

Brendan

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


[R] problems in loading MASS

2007-04-12 Thread Weiwei Shi
Hi, there:

After I upgraded my R to 2.4.1, it is my first time of trying to use
MASS and found the following error message:
 install.packages(MASS)
--- Please select a CRAN mirror for use in this session ---
trying URL 
'http://cran.cnr.Berkeley.edu/bin/macosx/universal/contrib/2.4/VR_7.2-33.tgz'
Content type 'application/x-gzip' length 995260 bytes
opened URL
==
downloaded 971Kb


The downloaded packages are in
/tmp/RtmpmAzBwa/downloaded_packages

 library(MASS)
Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
'/Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/libs/i386/MASS.so':
  
dlopen(/Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/libs/i386/MASS.so,
6): Library not loaded:
/usr/local/gcc4.0/i686-apple-darwin8/lib/libgcc_s.1.0.dylib
  Referenced from:
/Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/libs/i386/MASS.so
  Reason: image not found
Error: package/namespace load failed for 'MASS'


 sessionInfo()
R version 2.4.1 (2006-12-18)
i386-apple-darwin8.8.1

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

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

other attached packages:
randomForestdprep
4.5-181.0


 version
   _
platform   i386-apple-darwin8.8.1
arch   i386
os darwin8.8.1
system i386, darwin8.8.1
status
major  2
minor  4.1
year   2006
month  12
day18
svn rev40228
language   R
version.string R version 2.4.1 (2006-12-18)


Thanks
-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

Did you always know?
No, I did not. But I believed...
---Matrix III

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


[R] Question on ridge regression with R

2007-04-12 Thread Benny Wong
Hi,
  I am working on a project about hospital efficiency. Due to the high
multicolinearlity of the data, I want to fit the model using ridge
regression. However,  I believe that the data from large hospital(indicated
by the number of  patients they treat a year)  is more accurate than from
small hosptials, and I want to put more weight on them. How do I do this
with lm.ridge?
I know I just need to put weights=*** in lm function, but for lm.ridge, i
don't see that option in lm.ridge.

Could somebody give me suggestions on that?


thanks
ben

[[alternative HTML version deleted]]

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


Re: [R] Reasons to Use R

2007-04-12 Thread Ted Harding
On 12-Apr-07 10:14:21, Jim Lemon wrote:
 Charilaos Skiadas wrote:
 A new fortune candidate perhaps?
 
 On Apr 10, 2007, at 6:27 PM, Greg Snow wrote:
 
 
Remember, everything is better than everything else given the
right comparison.

 Only if we remove the grammatical blip that turns it into an infinite 
 regress, i.e.
 
 Remember, anything is better than everything else given the right 
 comparison
 
 Jim

Oh dear, I would be disappointed with that, Jim.

I was rather enjoying the vision of a topological sort tree
(ordered by better according to some comparison) in which every
single thing had everything else hanging off it, and in turn was
hanging off everything else!

Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 12-Apr-07   Time: 11:45:05
-- XFMail --

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


Re: [R] GLM with random effects

2007-04-12 Thread Andrew Robinson
Hello Brendan,

do you have any particular objection to

lmer(nor.tot.lep ~ In.Out + (1|Replicate), data=coho, family=poisson)

?

Andrew

On Thu, Apr 12, 2007 at 02:58:07PM -0700, Brendan Connors wrote:
 Hi R-Users,
 
 I have 3 replicates ('Replicate) of counts of parasites ('nor.tot.lep') 
 before and after an experiment ('In.Out'). I am trying to treat the 
 three replicates as a random effect in order to determine if the main 
 effect (In.Out) significantly influences my dependent variable 
 (nor.tot.lep) after the variance explained by the replicates is 
 accounted for. I have tried:
 
  lmer(nor.tot.lep ~ In.Out + (In.Out|Replicate),data=coho, family=poisson)
 Generalized linear mixed model fit using PQL
 Formula: nor.tot.lep ~ In.Out + (In.Out | Replicate)
 Data: coho
 Family: Poisson
 AIC BIC logLik deviance
 849.2 867.4 -419.6 839.2
 Random effects:
 Groups Name Variance Std.Dev. Corr
 Replicate (Intercept) 0.78861 0.88804
 In.Out 0.67232 0.81995 -1.000
 Residual 2.96308 1.72136
 number of obs: 279, groups: Replicate, 3
 
 Fixed effects:
 Estimate Std. Error t value
 (Intercept) -0.2431 0.6619 -0.3672
 In.Out 1.6004 0.5645 2.8349
 
 Correlation of Fixed Effects:
 (Intr)
 In.Out -0.975
 There were 30 warnings (use warnings() to see them)
 
   warnings()
 Warning messages:
 1: Estimated variance-covariance for factor ?Replicate? is singular
 in: LMEopt(x = mer, value = cv)
 2: nlminb returned message false convergence (8)
 in: LMEopt(x = mer, value = cv)
 
 but as Mr. Bates pointed out, this is inappropriate b/c I am trying to 
 use 3 distinct replicates to estimate 3 variance-covariance
 parameters. It won't work. Notice that the estimated correlation is
 -1.000. Your estimated variance-covariance matrix is singular
 
 I have also tried:
 
  glmmPQL(nor.tot.lep ~ In.Out, random = (In.Out|Replicate), family = 
 poisson, data = coho)
 
 Error in glmmPQL(nor.tot.lep ~ In.Out, random = (In.Out | Replicate), :
 object In.Out not found
 
 and R cannot find In.Out
 
 If anyone has any suggestions they would be extremely appreciated!
 
 Cheers,
 
 Brendan
 
 __
 [EMAIL PROTECTED] mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

-- 
Andrew Robinson  
Department of Mathematics and StatisticsTel: +61-3-8344-9763
University of Melbourne, VIC 3010 Australia Fax: +61-3-8344-4599
http://www.ms.unimelb.edu.au/~andrewpr
http://blogs.mbs.edu/fishing-in-the-bay/

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


Re: [R] LME: internal workings of QR factorization

2007-04-12 Thread Douglas Bates
On 4/12/07, Izmirlian, Grant (NIH/NCI) [E] [EMAIL PROTECTED] wrote:
 Hi:

 I've been reading Computational Methods for Multilevel Modeling by Pinheiro 
 and Bates, the idea of embedding the technique in my own c-level code. The 
 basic idea is to rewrite the joint density in a form to mimic a single least 
 squares problem conditional upon the variance parameters.  The paper is 
 fairly clear except that some important level of detail is missing. For 
 instance, when we first meet Q_(i):

 /\  / \
 | Z_i X_i   y_i  |  | R_11(i) R_10(i) c_1(i)  |
 || = Q_(i)  | |
 | Delta   0 0|  |   0 R_00(i) c_0(i)  |
 \/  \ /

 the text indicates that the Q-R factorization is limited to the first q 
 columns of the augmented matrix on the left.  If one plunks the first
 q columns of the augmented matrix on the left into a qr factorization, one 
 obtains an orthogonal matrix Q that is (n_i + q) x q and a nonsingular upper 
 triangular matrix R that is q x q.  While the text describes R as a 
 nonsingular upper triangular q x q, the matrix Q_(i) is described as a square 
 (n_i + q) x (n_i + q) orthogonal matrix.  The remaining columns in the matrix 
 to the right are defined by applying transpose(Q_(i)) to both sides.  The 
 question is how to augment my Q which is orthogonal (n_i + q) x q  with the 
 missing (n_i + q) x n_i portion producing the orthogonal square matrix 
 mentioned in the text?  I tried appending the n_i x n_i identity matrix to 
 the block diagonal, but this doesn't work as the resulting likelihood is 
 insensitive to the variance parameters.

 Grant Izmirlian


The QR decomposition of an n by p matrix (n  p) can be written as the
product of an orthogonal n by n matrix Q and an n by p matrix R which
is zero below the main diagonal.  Because the rows of R beyond the pth
are zero, there is no need to store them.  For some purposes it is
more convenient to write the decomposition as the product of Q1, an n
by p matrix with orthonormal columns and R1 a p by p upper triangular
matrix.

If you are going to be incorporating calculations like this in your
own code I would recommend looking at the Implementation vignette in
the lme4 package.  It describes the computational approach used in the
latest version of lmer (currently called lmer2 but to become lmer at
some point) which allows for multiple non-nested grouping factors.
The techniques that Jose and I describe in the paper you mention only
handles nested grouping factors cleanly.

That vignette has been updated after the last release of the lme4
package.  You can get the expanded version from the SVN repository or
wait until after R-2.5.0 is released and we release new versions of
the Matrix and lme4 packages for R-2.5.0.

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


[R] class and method

2007-04-12 Thread jiho.han

Hi, R-experts

I defined a new class of object, called alpha, which is basically a
data.frame. And (I think) I know how to create a method for alpha, such as
summary.alpha, plot.alpha. The problem is, when I try to access alpha
object by usual data.frame method, it won't.

For example, suppose X is an object of class alpha. Then, the commands
such as dim(X), X[1,1], none of these works. 

I want to know how to define a class so that when there is appropriate
methods use it, but when there's not use the predetermined method for
underlying object. Any comments would be appreciated. Thanks-





-- 
View this message in context: 
http://www.nabble.com/class-and-method-tf3568696.html#a9969691
Sent from the R help mailing list archive at Nabble.com.

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


Re: [R] problems in loading MASS

2007-04-12 Thread Charilaos Skiadas
Weiwei,

I have never had much success installing packages from within R.app  
on MacOSX, because the location that it is supposed to save things, / 
Library/Frameworks/, needs elevated priviledges, which the app  
doesn't seem to try to get.  So it at best ends up saving it in some  
temporary location, and it has to be downloaded again next time R is  
restarted.

As a result, I have always downloaded the tgz file from my browser,  
then go to the terminal in that folder and do a sudo R CMD INSTALL  
packagename.tgz.

But perhaps I am doing something wrong and one can do this properly  
from within R.app, I would love to be wrong on this one.

  sessionInfo()
R version 2.4.1 (2006-12-18)
powerpc-apple-darwin8.8.0

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

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

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

On Apr 12, 2007, at 6:04 PM, Weiwei Shi wrote:

 Hi, there:

 After I upgraded my R to 2.4.1, it is my first time of trying to use
 MASS and found the following error message:
 install.packages(MASS)
 --- Please select a CRAN mirror for use in this session ---
 trying URL 'http://cran.cnr.Berkeley.edu/bin/macosx/universal/ 
 contrib/2.4/VR_7.2-33.tgz'
 Content type 'application/x-gzip' length 995260 bytes
 opened URL
 ==
 downloaded 971Kb


 The downloaded packages are in
   /tmp/RtmpmAzBwa/downloaded_packages

 library(MASS)
 Error in dyn.load(x, as.logical(local), as.logical(now)) :
   unable to load shared library
 '/Library/Frameworks/R.framework/Versions/2.4/Resources/library/ 
 MASS/libs/i386/MASS.so':
   dlopen(/Library/Frameworks/R.framework/Versions/2.4/Resources/ 
 library/MASS/libs/i386/MASS.so,
 6): Library not loaded:
 /usr/local/gcc4.0/i686-apple-darwin8/lib/libgcc_s.1.0.dylib
   Referenced from:
 /Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/ 
 libs/i386/MASS.so
   Reason: image not found
 Error: package/namespace load failed for 'MASS'


 sessionInfo()
 R version 2.4.1 (2006-12-18)
 i386-apple-darwin8.8.1

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

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

 other attached packages:
 randomForestdprep
 4.5-181.0


 version
_
 platform   i386-apple-darwin8.8.1
 arch   i386
 os darwin8.8.1
 system i386, darwin8.8.1
 status
 major  2
 minor  4.1
 year   2006
 month  12
 day18
 svn rev40228
 language   R
 version.string R version 2.4.1 (2006-12-18)


 Thanks
 -- 
 Weiwei Shi, Ph.D
 Research Scientist
 GeneGO, Inc.

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


Re: [R] problems in loading MASS

2007-04-12 Thread Weiwei Shi
Hi Charilaos:

I think the installation has no problem as indicated by
install.packages(). Anyway, I tried your way but unfortunately it
does not help.

Thanks though,

-W

On 4/12/07, Charilaos Skiadas [EMAIL PROTECTED] wrote:
 Weiwei,

 I have never had much success installing packages from within R.app
 on MacOSX, because the location that it is supposed to save things, /
 Library/Frameworks/, needs elevated priviledges, which the app
 doesn't seem to try to get.  So it at best ends up saving it in some
 temporary location, and it has to be downloaded again next time R is
 restarted.

 As a result, I have always downloaded the tgz file from my browser,
 then go to the terminal in that folder and do a sudo R CMD INSTALL
 packagename.tgz.

 But perhaps I am doing something wrong and one can do this properly
 from within R.app, I would love to be wrong on this one.

   sessionInfo()
 R version 2.4.1 (2006-12-18)
 powerpc-apple-darwin8.8.0

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

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

 Haris Skiadas
 Department of Mathematics and Computer Science
 Hanover College

 On Apr 12, 2007, at 6:04 PM, Weiwei Shi wrote:

  Hi, there:
 
  After I upgraded my R to 2.4.1, it is my first time of trying to use
  MASS and found the following error message:
  install.packages(MASS)
  --- Please select a CRAN mirror for use in this session ---
  trying URL 'http://cran.cnr.Berkeley.edu/bin/macosx/universal/
  contrib/2.4/VR_7.2-33.tgz'
  Content type 'application/x-gzip' length 995260 bytes
  opened URL
  ==
  downloaded 971Kb
 
 
  The downloaded packages are in
/tmp/RtmpmAzBwa/downloaded_packages
 
  library(MASS)
  Error in dyn.load(x, as.logical(local), as.logical(now)) :
unable to load shared library
  '/Library/Frameworks/R.framework/Versions/2.4/Resources/library/
  MASS/libs/i386/MASS.so':
dlopen(/Library/Frameworks/R.framework/Versions/2.4/Resources/
  library/MASS/libs/i386/MASS.so,
  6): Library not loaded:
  /usr/local/gcc4.0/i686-apple-darwin8/lib/libgcc_s.1.0.dylib
Referenced from:
  /Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/
  libs/i386/MASS.so
Reason: image not found
  Error: package/namespace load failed for 'MASS'
 
 
  sessionInfo()
  R version 2.4.1 (2006-12-18)
  i386-apple-darwin8.8.1
 
  locale:
  en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
 
  attached base packages:
  [1] stats graphics  grDevices utils datasets
  methods   base
 
  other attached packages:
  randomForestdprep
  4.5-181.0
 
 
  version
 _
  platform   i386-apple-darwin8.8.1
  arch   i386
  os darwin8.8.1
  system i386, darwin8.8.1
  status
  major  2
  minor  4.1
  year   2006
  month  12
  day18
  svn rev40228
  language   R
  version.string R version 2.4.1 (2006-12-18)
 
 
  Thanks
  --
  Weiwei Shi, Ph.D
  Research Scientist
  GeneGO, Inc.







-- 
Weiwei Shi, Ph.D
Research Scientist
GeneGO, Inc.

Did you always know?
No, I did not. But I believed...
---Matrix III

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


Re: [R] Construct time series objects from raw data stored in csv files

2007-04-12 Thread Gabor Grothendieck
On 4/12/07, tom soyer [EMAIL PROTECTED] wrote:
 What should I do for weekly and daily data series? Are there functions
 similar to yearmon() for other time intervals? I see that there is a
 built-in yearqtr() function for quarterly data, but that's it.

ts series cannot directly represent daily and weekly
series other than somehow deciding on a numeric representation
for time.

Here we will use the number of days and the number of weeks
since the Epoch (1970-01-01) and assume we assume weeks
start on Sunday.  We will also do it over again using the number
of weeks since the first point in the series and the number of
days since the first point.

Lines.raw is from my original post on this thread.


z - read.zoo(textConnection(Lines.raw), header = TRUE, sep = ,)

# ts series will represent days as no of days since Epoch
zday - z
frequency(zday) - 1
tsday - as.ts(zday)

# ts series will represent weeks as no of weeks since Epoch
zweek - zday
offset - -3 # weeks start on Sun
# offset - -4 # weeks start on Mon
zweek - aggregate(z, (as.numeric(time(z)) + offset) %/% 7, mean)
frequency(zweek) - 1
tsweek - as.ts(zweek)

##
# alternately use number of days since first day in series
# and number of weeks since first week in series


zday0 - aggregate(zday, time(zday) - min(time(zday)), c)
frequency(zday0) - 1
tsday0 - as.ts(zday0)

zweek0 - aggregate(zweek, time(zweek) - min(time(zweek)), c)
frequency(zweek0) - 1
tsweek0 - as.ts(zweek0)

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


[R] NYC Area R / S / S-Plus Users Group Forming, Thursday, April 26th

2007-04-12 Thread Talbot Katz

Hi gang.

So I'm actually carrying through on the threat I made a couple of months 
back, and helping to start a local users group for the NYC Metropolitan 
area.  Here's a copy of the announcement of our introductory / planning 
meeting, I also can send a flyer version of this to anyone who wants (Open 
Office document, should be viewable in MS-Office).  Please feel free to 
attend, invite friends and colleagues, and spread the word around.  Thanks!


*
!!!NYC Area R / S / S-Plus Users Group Forming!!!

Yes, it's really happening!  An organization for users of the popular R
and S-Plus statistical / analytical / graphical software environments in
the NYC Metropolitan Area to call their own.  Swap ideas, share code,
learn cool tricks and techniques!

Introductory / Organizing Meeting

WHEN: Thursday, April 26th, 2007, 6:30 – 8:00 PM

WHERE: Pragma Financial Systems, 447 Broadway, 4th Floor, NYC, 10013
PFS is on the west side of Broadway, between Grand and Howard Streets, a
block and a half north of the Canal / Lafayette Street subway stop
(6,J,M,N,Q,R,W,Z trains)


WHAT: Here's your opportunity to be a Founding MembeR – give your input
about what you'd like the group to be; we'll also have short presentations
on Vectorization  Efficiency, and on Robust Statistical procedures in R.

Light refreshment will be served, so RSVP appreciated (not required).
Even if you can't attend, you can still join,
CONTACT: Talbot Katz, [EMAIL PROTECTED], 646.461.7840

If you don't already use R, you could (should!) start today – download R
for free from the official R Project website (http://www.r-project.org/).
The R Project site contains a wealth of resources for users, including FAQ
pages, a user Wiki, Help List / newsgroup, book suggestions, etc.  There
is already an active R / S / S-Plus user community online, but nothing
compares with having live presentations, forums,  workshops – you'll see!
*

--  TMK  --

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


[R] trouble getting bw plots using trellis graphics

2007-04-12 Thread Brian Riordan
I'm having trouble getting a black and white plot using the trellis device.  
I have color graphics, but I'd like to use bw for a paper.  For example,

trellis.device(color=F)
d - read.table(textConnection(
A,B
0,1
1,2), header=T, sep=,)
xyplot(A ~ B, data=d, type=o, lty=c(1:2), col=2, pch=19:20)
dev.off()

gives me a red line even though I specify color=F.

sessionInfo()
R version 2.4.1 (2006-12-18)
i386-pc-mingw32

locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United 
States.1252;LC_MONETARY=English_United 
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252

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

other attached packages:
  lattice
0.14-17

Thank you,
Brian

_
Need a break? Find your escape route with Live Search Maps.

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


Re: [R] trouble getting bw plots using trellis graphic

2007-04-12 Thread Deepayan Sarkar
On 4/12/07, Brian Riordan [EMAIL PROTECTED] wrote:
 I'm having trouble getting a black and white plot using the trellis device.
 I have color graphics, but I'd like to use bw for a paper.  For example,

 trellis.device(color=F)
 d - read.table(textConnection(
 A,B
 0,1
 1,2), header=T, sep=,)
 xyplot(A ~ B, data=d, type=o, lty=c(1:2), col=2, pch=19:20)
 dev.off()

 gives me a red line even though I specify color=F.

Yes, the 'color' argument controls the default settings. If you don't
want a non-default color, don't specify a color. You can't expect to
say draw these points in red and then be surprised when the points
are really drawn in red.

If you expected that somehow col=2 would become a black and white
color, then look at ?palette. For example, you can set the palette to
shades of grey using

palette(grey.colors(5))

-Deepayan

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


Re: [R] class and method

2007-04-12 Thread Prof Brian Ripley
On Thu, 12 Apr 2007, jiho.han wrote:


 Hi, R-experts

 I defined a new class of object, called alpha, which is basically a
 data.frame. And (I think) I know how to create a method for alpha, such as
 summary.alpha, plot.alpha. The problem is, when I try to access alpha
 object by usual data.frame method, it won't.

 For example, suppose X is an object of class alpha. Then, the commands
 such as dim(X), X[1,1], none of these works.

 I want to know how to define a class so that when there is appropriate
 methods use it, but when there's not use the predetermined method for
 underlying object. Any comments would be appreciated. Thanks-

class(X) - c(alpha, data.frame)

is I think what you want.


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

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


Re: [R] making a counter of consecitive positive cases in time series

2007-04-12 Thread Marc Schwartz
On Thu, 2007-04-12 at 22:30 +0200, Jose Bustos Melo wrote:
 Hi all..RCounters!

   Im working with standarized time series, and i need make a counter
 of consecutives positves numbers to  make a cumulative experimental
 funtion. I have x: the time series (0,1) and y: my counter, i have
 this for step. What is wrong?.. any can help me please!

   x-rbinom(15,1,.3)
   y-NULL;s-0
   for (i in 1: length (x))
   {if (x[i]0)
   {s-s+x[i]
   s=0}
   else
   y-c(y,s)}
   y
   x


   Thk u all!
   Jos Bustos


I may be mis-understanding your desired result, but is this what you
want:

x - rbinom(15, 1, .3)

 x
 [1] 1 1 0 0 1 0 0 0 1 1 0 1 1 0 1

 rle(x)
Run Length Encoding
  lengths: int [1:9] 2 2 1 3 2 1 2 1 1
  values : num [1:9] 1 0 1 0 1 0 1 0 1


See ?rle for more information.

HTH,

Marc Schwartz

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


Re: [R] problems in loading MASS

2007-04-12 Thread Prof Brian Ripley
MASS is part of the standard R installation, as a recommended package.

I suggest you try re-installing R and not then trying to download a 
different version.

I would also suggest trying 2.5.0 beta at this stage in preference to 
2.4.1 if you do need to re-install R.

Beyond that, there is a list (r-sig-mac) for Mac-specific problems
(and this is an OS-specific problem).

On Thu, 12 Apr 2007, Weiwei Shi wrote:

 Hi, there:

 After I upgraded my R to 2.4.1, it is my first time of trying to use
 MASS and found the following error message:
 install.packages(MASS)
 --- Please select a CRAN mirror for use in this session ---
 trying URL 
 'http://cran.cnr.Berkeley.edu/bin/macosx/universal/contrib/2.4/VR_7.2-33.tgz'
 Content type 'application/x-gzip' length 995260 bytes
 opened URL
 ==
 downloaded 971Kb


 The downloaded packages are in
   /tmp/RtmpmAzBwa/downloaded_packages

 library(MASS)
 Error in dyn.load(x, as.logical(local), as.logical(now)) :
   unable to load shared library
 '/Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/libs/i386/MASS.so':
  
 dlopen(/Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/libs/i386/MASS.so,
 6): Library not loaded:
 /usr/local/gcc4.0/i686-apple-darwin8/lib/libgcc_s.1.0.dylib
  Referenced from:
 /Library/Frameworks/R.framework/Versions/2.4/Resources/library/MASS/libs/i386/MASS.so
  Reason: image not found
 Error: package/namespace load failed for 'MASS'

[...]

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

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