Re: [R] Help creating a correlation matrix

2008-05-21 Thread Moshe Olshansky
Hi,

I tried the following one:
z - outer(1:14,1:14,function(i,j)
eval(parse(text=paste(cor(D2_,i,,D2_,j,),sep=

but this doen not work (why?).

Two alternatives which work are either

x - matrix(0,length(D2_1,14)
for (i in 1:14) x[,i] -
eval(parse(text=paste(D2_,i,sep=)))
z - cor(x)

or

z - diag(14)
for (i in 1:14) for (j in 1:14) z[i,j] -
eval(parse(text=paste(cor(D2_,i,,D2_,j,),sep=)))


--- Robert O'Brien [EMAIL PROTECTED]
wrote:

 Hello all. I have 14 variables, named D2_1,
 D2_2,...,D2_14 (inherited from a data set). I would
 like to create a matrix of correlations, although I
 would be content in just learning how to create a
 proper do loop. I tried something like this:
 
 
 (for i in 1:14){cor(D2_[i],D2_[i], use =
 complete.obs)}
 
 This is wrong, of course, but I don't know how to
 tell R to run through D2_1, D2_2,...,D2_14 giving
 me
 the correlations for each pair. 
 
 Any help or hints would be appreciated.
 
 Sincerely,
 
 Robert O'Brien
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


__
R-help@r-project.org 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] an unknown error message when using gamm function

2008-05-21 Thread Lung-Chang Chien
Dear everyone,

I'm encountering an unknown error message when using gamm function:

 fitoutput -
gamm(cvd~as.factor(dow)+pm10+s(time,bs=cr,k=15,fx=TRUE)+s(tmean,bs=cr,k=7,fx=TRUE)
+
,correlation=corAR1(form=~1|city),family=poisson,random=list(city=~pm10),data=mimp)


 Maximum number of PQL iterations:  20
iteration 1
iteration 2
iteration 3
iteration 4
iteration 5
iteration 6
Error in `*tmp*`[[k]] : attempt to select less than one element

I never saw this error message before, and there is also no related
information about this error from the Internet. Hope some people who once
encountered this problem can tell me what's wrong.

Many thanks,

LC

-- 
Lung-Chang Chien
Doctoral candidate, Department of Biostatistics
Statistical assistant, School of Nursing
University of North Carolina at Chapel Hill
Office: Carrington Hall, RSC, Room 2014
TEL: 919-843-2480

[[alternative HTML version deleted]]

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


[R] R help needed

2008-05-21 Thread Kamlesh Kumar
Dear Sir/Madam,
 I have tried to upload data in R but it showing some error
  in command window. It's should be noted that I am using Mac version of
  R. I am using Mac-text for writing my data. I am getting following
  message on the command window.

   source(/Users/kamleshkumar/Desktop/DS1.txt)
  Error in source(/Users/kamleshkumar/Desktop/DS1.txt) :
/Users/kamleshkumar/Desktop/DS1.txt: unexpected symbol at
  1: x y
I am attaching the the DS1.txt file also with this mail.
  Please go through it and guide me about this. I am waiting for a reply
  from your side. Thanking you.
  Yours Sincerely,
  Kamlesh Kumar


-- 
Kamlesh kumar
QEM1, Universität Bielefeld
Appt. No.- 313A,
29, Morganbreede,
33615 Bielefeld,
Germany.
x y
 0.43678295 -3.28526227
 0.13718621 -4.92480568
 0.17818460 -4.05188084
 0.16101891 -4.67132656
 0.07748958 -4.57308386
 0.07665154 -4.65652237
 0.93462605 -2.43577939
 0.08393081 -4.77342552
 0.21957806 -4.30777061
 0.72091525 -2.40654408
 0.78820620 -2.48382294
 0.03020949 -5.13427708
 0.68054097 -3.29446962
 0.30986188 -4.27261703
 0.95362188 -1.95420377
 0.55720882 -2.97490588
 0.43290669 -3.89988872
 0.70655859 -2.80856040
 0.27899269 -4.53354360
 0.86257070 -2.01097646
 0.05536443 -5.25322277
 0.63851330 -3.29444349
 0.61166177 -3.16909365
 0.53661890 -3.47439468
 0.04897602 -4.94514890
 0.40846848 -3.55536513
 0.48529544 -3.33571965
 0.62426309 -3.15729236
 0.51640396 -3.52697121
 0.48633149 -3.48081848
 0.56278950 -3.21171279
 0.84846483 -2.84878605
 0.78607647 -2.49938705
 0.08552248 -4.66611865
 0.27222455 -3.68753951
 0.52786212 -3.18143578
 0.42516159 -3.52162673
 0.79234991 -2.31155140
 0.84189899 -2.45189562
 0.23900177 -4.47138986
 0.91564840 -2.09537746
 0.67030122 -2.52637849
 0.94819300 -1.98333241
 0.18291447 -4.89865053
 0.52996478 -3.87409080
 0.50593282 -3.79463028
 0.73293227 -2.53096580
 0.47889233 -3.83944563
 0.10962530 -5.09931633
 0.28968145 -3.91778725
 0.51736481 -4.18277038
 0.51200367 -3.47252783
 0.69443868 -2.93954049
 0.85456938 -2.66937293
 0.85227096 -2.00744394
 0.39924035 -3.81892375
 0.76328850 -2.97426388
 0.26705593 -4.64157081
 0.78798635 -2.52137869
 0.08613956 -4.91270415
 0.50749160 -3.41245218
 0.88808879 -2.31015263
 0.93046255 -1.91780699
 0.61369620 -3.20740210
 0.62948767 -3.12272095
 0.14147349 -4.09641126
 0.46920070 -3.66767757
 0.35005896 -3.78436370
 0.55357248 -3.22255576
 0.04723303 -4.60194879
 0.52039850 -3.51374627
 0.06786648 -5.10241809
 0.98168950 -1.97958974
 0.01757815 -5.06735833
 0.36243887 -3.84462984
 0.42420613 -3.13386319
 0.22285663 -4.71020127
 0.08062803 -4.36007637
 0.36207742 -4.06609100
 0.13193842 -5.10268694
 0.69752291 -3.03723431
 0.22458552 -3.76104542
 0.76745054 -2.51812578
 0.58135253 -2.69485523
 0.90282985 -2.11135506
 0.96344637 -2.13711582
 0.74533493 -3.14761947
 0.41475951 -4.37647029
 0.80989250 -2.44450728
 0.18761541 -4.28119680
 0.86392396 -2.75540153
 0.86466167 -2.45686213
 0.03874840 -4.62795990
 0.70687607 -2.89780500
 0.36910319 -4.2300
 0.04626376 -5.21006098
 0.32207711 -4.36650935
 0.18580701 -5.27752600
 0.65028098 -3.37388899
 0.66456437 -3.07719445
__
R-help@r-project.org 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] R help needed

2008-05-21 Thread Simon Blomberg
Try:

dat - read.table(/Users/kamleshkumar/Desktop/DS1.txt, header=TRUE)

Please also read the F documentation. The use of read.table is in An
Introduction to R for example.

Simon.

On Wed, 2008-05-21 at 08:13 +0200, Kamlesh Kumar wrote:
 Dear Sir/Madam,
  I have tried to upload data in R but it showing some error
   in command window. It's should be noted that I am using Mac version of
   R. I am using Mac-text for writing my data. I am getting following
   message on the command window.
 
source(/Users/kamleshkumar/Desktop/DS1.txt)
   Error in source(/Users/kamleshkumar/Desktop/DS1.txt) :
 /Users/kamleshkumar/Desktop/DS1.txt: unexpected symbol at
   1: x y
 I am attaching the the DS1.txt file also with this mail.
   Please go through it and guide me about this. I am waiting for a reply
   from your side. Thanking you.
   Yours Sincerely,
   Kamlesh Kumar
 
 
 __
 R-help@r-project.org 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.
-- 
Simon Blomberg, BSc (Hons), PhD, MAppStat. 
Lecturer and Consultant Statistician 
Faculty of Biological and Chemical Sciences 
The University of Queensland 
St. Lucia Queensland 4072 
Australia
Room 320 Goddard Building (8)
T: +61 7 3365 2506
http://www.uq.edu.au/~uqsblomb
email: S.Blomberg1_at_uq.edu.au

Policies:
1.  I will NOT analyse your data for you.
2.  Your deadline is your problem.

The combination of some data and an aching desire for 
an answer does not ensure that a reasonable answer can 
be extracted from a given body of data. - John Tukey.

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


Re: [R] Converting Data Types

2008-05-21 Thread Martin Maechler
 EW == Edward Wijaya [EMAIL PROTECTED]
 on Wed, 21 May 2008 11:52:17 +0900 writes:

EW Hi Peter,
EW Thanks.

EW as.matrix()  does the trick.

and ... again my perennial remark to the above trick  :

Do use   data.matrix(dd)  instead of 
   as.matrix(dd)

if dd is a data frame ... it will also produce a numeric matrix
when dd contains factor (and similar) columns.

Martin Maechler, ETH Zurich


EW - Edward

EW On Wed, May 21, 2008 at 11:31 AM, Peter Alspach
EW [EMAIL PROTECTED] wrote:
 Edward
 
 Are you sure mymatrix is, in fact, a matrix and note a dataframe (which
 is a list)?  I get:
 
 is.matrix(mymatrix)
 [1] FALSE
 is.data.frame(mymatrix)
 [1] TRUE
 samples - mymatrix[1,]
 llgm - dgamma(samples, scale=1, shape=2, log = TRUE)
 Error in dgamma(x, shape, scale, log) :
 Non-numeric argument to mathematical function
 
 That is, the same error as you when mymatrix is a dataframe.  But
 convert it to a matrix and:
 
 mymatrix - as.matrix(mymatrix)
 is.matrix(mymatrix)
 [1] TRUE
 is.data.frame(mymatrix)
 [1] FALSE
 samples - mymatrix[1,]
 llgm - dgamma(samples, scale=1, shape=2, log = TRUE)
 llgm
 V1 V2 V3 V4 V5 V6
 -99.25657  -84.01700 -237.40735 -201.26922 -170.53122 -159.29770
 
 HTH 
 
 Peter Alspach
 
 
 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Edward Wijaya
 Sent: Wednesday, 21 May 2008 2:17 p.m.
 To: r-help@r-project.org
 Subject: [R] Converting Data Types
 
 Hi,
 
 How can I convert the matrices to list.
 
 For example I have this snippet:
 
 samples-mymatrix[1,]
 print(samples)
 
 which prints:
 
 V1   V2V3V4V5V6
 1 103.9 88.5 242.9 206.6 175.7 164.4
 
 
 How can I convert the object samples such that it prints:
 [1] 103.9 88.5 242.9 206.6 175.7 164.4
 
 The reason I ask this because I can't use the former
 samples object with this function:
 
 llgm - dgamma(samples, scale=1, shape=2, log = TRUE)
 
 which gives this error:
 e 1374Error in dgamma(x, shape, scale, log) :
 Non-numeric argument to mathematical function
 
 Regards,
 Edward
 
 __
 R-help@r-project.org 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.
 
 
 The contents of this e-mail are privileged and/or confidential to the 
named
 recipient and are not to be used by any other person and/or organisation.
 If you have received this e-mail in error, please notify the sender and 
delete
 all material pertaining to this e-mail.
 

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

__
R-help@r-project.org 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] Insufficient memory

2008-05-21 Thread Roy Williams
Dear Sir/Madam,

I have only started using a R-written script for modeling the distribution of 
disease vector species. Part of the script is to make a large GIS grid for use 
with GIS software, but it seems I have a memory problem. I get the following 
message: 

Reached total allocation of 1535Mb: see help(memory.size)

My hard disk has more than 100 gigabytes available, I just have to increase the 
allocated memory -  sofar unsuccesful. I've used the code: 
 memory.limit(4094)  which returns: NULL. 
When I then use the code:  memory.limit(size = NA) it returns: [1] 4094. But 
then when I run the code to produce the large grid, I still get the same error 
message as above. 
How do I go about to increase the memory to the maximum?

Your help is much appreciated.

Regards

Roy Williams


Dr R Williams
Diagnostic Products  GIS
ARC-Onderstepoort Vet Institute

Tel:  +27 12 529-9107
Fax: +27 12 529-9285
Cell: 072 200 0024

[EMAIL PROTECTED] 
Visit us at: www.arc.agric.za 


Disclaimer\ \ This message is confidential and may be co...{{dropped:20}}

__
R-help@r-project.org 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] Problem in converting natural numbers to bits and others

2008-05-21 Thread Jason Lee
Hi,

I just started using R for about one week and I have few problems.

i)I have a problem in finding right function to convert a table of natural
numbers to bitwise. For a simple example;

I have the below table:-

Column  Col1   Col2   Col3
Sample1 57  10
Sample2 02   1
Sample3 4 0   0


Supposedly i wanted to convert to :-


Column  Col1   Col2   Col3
Sample1 11   1
Sample2 01   1
Sample3 1 0   0

ii)Besides, I would like to create a formula of Sum(3*(Element in each
column for a row))..does it equivalent to 3*(data[1:3,1:2]) in this case?or
I need to have Sum(3*(data[1:3,1:2])). Basically I wanted to mutliply each
element of column table of a row and sum it  up.

iii)I would also like to know how to insert an if else statement where in
the above case, I wanted to check if data[1:3,]
returns me 1 or 0, it will execute some calculations.
I refer to the R intro pdf and it mentioned using if (expr_1 ) expr_2 else
expr_3. Does that mean if(data[1:3,1:2])0 output[1:3,1:2]=0
else output[1:3,1:2]=100. If I did this command, how does R knows which
row and column to map the output with?

Please advise. Appreciate alot. Thanks.

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] an unknown error message when using gamm function

2008-05-21 Thread Simon Wood
What version of mgcv are you using, please?

On Wednesday 21 May 2008 06:16, Lung-Chang Chien wrote:
 Dear everyone,

 I'm encountering an unknown error message when using gamm function:
  fitoutput -

 gamm(cvd~as.factor(dow)+pm10+s(time,bs=cr,k=15,fx=TRUE)+s(tmean,bs=cr,k
=7,fx=TRUE) +
 ,correlation=corAR1(form=~1|city),family=poisson,random=list(city=~pm10),da
ta=mimp)


  Maximum number of PQL iterations:  20
 iteration 1
 iteration 2
 iteration 3
 iteration 4
 iteration 5
 iteration 6
 Error in `*tmp*`[[k]] : attempt to select less than one element

 I never saw this error message before, and there is also no related
 information about this error from the Internet. Hope some people who once
 encountered this problem can tell me what's wrong.

 Many thanks,

 LC

-- 
 Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
 +44 1225 386603  www.maths.bath.ac.uk/~sw283

__
R-help@r-project.org 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] Odp: Problem in converting natural numbers to bits and others

2008-05-21 Thread Petr PIKAL
Hallo

[EMAIL PROTECTED] napsal dne 21.05.2008 09:42:40:

 Hi,
 
 I just started using R for about one week and I have few problems.
 
 i)I have a problem in finding right function to convert a table of 
natural
 numbers to bitwise. For a simple example;
 
 I have the below table:-
 
 Column  Col1   Col2   Col3
 Sample1 57  10
 Sample2 02   1
 Sample3 4 0   0
 
 
 Supposedly i wanted to convert to :-
 
 
 Column  Col1   Col2   Col3
 Sample1 11   1
 Sample2 01   1
 Sample3 1 0   0

data-read.table(clipboard, header=T
If data is your data frame, 

data.bit-data.frame(column=data[,1],(data[,-1]0)*1)

 
 ii)Besides, I would like to create a formula of Sum(3*(Element in each
 column for a row))..does it equivalent to 3*(data[1:3,1:2]) in this 
case?or
 I need to have Sum(3*(data[1:3,1:2])). Basically I wanted to mutliply 
each
 element of column table of a row and sum it  up.

Rather complicated. 

 3*(data[1:3,2:3])
  Col1 Col2
1   15   21
206
3   120
 sum(3*(data[1:3,2:3]))
[1] 54

Works but I am suspicious that you wont something else. 


 
 iii)I would also like to know how to insert an if else statement where 
in
 the above case, I wanted to check if data[1:3,]
 returns me 1 or 0, it will execute some calculations.
 I refer to the R intro pdf and it mentioned using if (expr_1 ) expr_2 
else
 expr_3. Does that mean if(data[1:3,1:2])0 output[1:3,1:2]=0
 else output[1:3,1:2]=100. If I did this command, how does R knows 
which
 row and column to map the output with?

If ... else ... is usually for working as programming steps

ifelse(..., ..., ...)

works with objects and is parts. You shall think first how to do your 
calculations with whole objects, it is usually more effective.

Regards
Petr

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

__
R-help@r-project.org 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] Proportional axes

2008-05-21 Thread Agustin Lobo

Hi!

If I'm plotting 2 variables with the same units
(i.e. wing length of 2 species), how can I force that X
and Y axes have the same size for length unit? For example, if
X ranges from 0 to 10 and Y ranges from 10 to 30, I want
Y axis to be twice as long as X axis. I know I can just
put xlim and ylim from 0 to 30, i.e.,
plot(runif(10,0,10),runif(10,10,30),xlim=c(0,30),ylim=c(0,30))

but this is a waste of space.

Thanks

--
Dr. Agustin Lobo
Institut de Ciencies de la Terra Jaume Almera (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: [EMAIL PROTECTED]
http://www.ija.csic.es/gt/obster

__
R-help@r-project.org 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] need some help in plotting xy graph

2008-05-21 Thread Kurapati, Ravichandra (Ravichandra)


fdf dataframe contains
 the data as follows

bin   rate  overlay   x
1   90  Assign First/cc _from_SN_53 RNC_20_to_SN_50
RNC_21_Success Rate   (04/01/08 16:02:30)
2   93  Assign First/cc _from_SN_53 RNC_20_to_SN_50
RNC_21_Success Rate   (04/01/08 16:07:30)
1   90  Assign First/cc _from_SN_50 RNC_21_to_SN_53
RNC_20_Success Rate   (04/01/08 16:02:30)
2   94  Assign First/cc _from_SN_50 RNC_21_to_SN_53
RNC_20_Success Rate   (04/01/08 16:07:30)


I want to plot a xygraph
  on xaxis-x  
  on y-axis-rate
  groups=overlay

formd-rate ~ as.numeric(x)
groups-overlay
lgnd.txt-levels(df$overlay)

print(xyplot(formula(formd),data = fdf, groups = overlay,
type = b, as.table = TRUE, cex=0.20,main = this is my first plot,
xlab = Time, ylab = session transfer,scales = c(xscales,yscales),key
= simpleKey(text = lgnd.txt, cex = 3/4,points = FALSE, lines = TRUE),
layout = c(1,1)))

but I didn't get any o/p

so
can u tel how can I get the desired xygraph from fdf dataframe



-Original Message-
From: Deepayan Sarkar [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, May 21, 2008 10:43 AM
To: Kurapati, Ravichandra (Ravichandra)
Cc: [EMAIL PROTECTED]
Subject: Re: [Rd] need some help in plotting xy graph

On 5/20/08, Kurapati, Ravichandra (Ravichandra)
[EMAIL PROTECTED] wrote:

Dataframedf contains



  bin rate
overlay

  1   1   90 Assign First/cc _from_SN_53 RNC_20_to_SN_50 RNC_21_Success
  Rate

  2   2   93 Assign First/cc _from_SN_53 RNC_20_to_SN_50 RNC_21_Success
  Rate

  3   1   90 Assign First/cc _from_SN_50 RNC_21_to_SN_53 RNC_20_Success
  Rate

  4   2   94 Assign First/cc _from_SN_50 RNC_21_to_SN_53 RNC_20_Success
  Rate

  time

  1 (04/01/08 16:02:30)

  2 (04/01/08 16:07:30)

  3 (04/01/08 16:02:30)

  4 (04/01/08 16:07:30)

It would be more work to read in your data than I have time for. Could
you post it in a more convenient format? (The output of dput(fdf)
should be fine.)

-Deepayan

__
R-help@r-project.org 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] Insufficient memory

2008-05-21 Thread Prof Brian Ripley
Presumably you are using Windows without telling us.  Please study the 
appropriate section of the rw-FAQ (and also the posting guide).


On Wed, 21 May 2008, Roy Williams wrote:


Dear Sir/Madam,

I have only started using a R-written script for modeling the 
distribution of disease vector species. Part of the script is to make a 
large GIS grid for use with GIS software, but it seems I have a memory 
problem. I get the following message:


Reached total allocation of 1535Mb: see help(memory.size)

My hard disk has more than 100 gigabytes available, I just have to increase the 
allocated memory -  sofar unsuccesful. I've used the code:

memory.limit(4094)  which returns: NULL.

When I then use the code:  memory.limit(size = NA) it returns: [1] 4094. But 
then when I run the code to produce the large grid, I still get the same error 
message as above.
How do I go about to increase the memory to the maximum?


Tell your unstated OS that you want more of the address space?  See the 
rw-FAQ.




Your help is much appreciated.

Regards

Roy Williams


Dr R Williams
Diagnostic Products  GIS
ARC-Onderstepoort Vet Institute

Tel:  +27 12 529-9107
Fax: +27 12 529-9285
Cell: 072 200 0024

[EMAIL PROTECTED]
Visit us at: www.arc.agric.za


Disclaimer\ \ This message is confidential and may be co...{{dropped:20}}

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



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

__
R-help@r-project.org 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] Proportional axes

2008-05-21 Thread Ivar Herfindal

Hello.

Try the to set asp=1 (aspect ratio between y- and x-axis):

plot(runif(10, 0, 10), runif(10, 10, 30), asp=1)

Best

Ivar Herfindal


Agustin Lobo skrev:

Hi!

If I'm plotting 2 variables with the same units
(i.e. wing length of 2 species), how can I force that X
and Y axes have the same size for length unit? For example, if
X ranges from 0 to 10 and Y ranges from 10 to 30, I want
Y axis to be twice as long as X axis. I know I can just
put xlim and ylim from 0 to 30, i.e.,
plot(runif(10,0,10),runif(10,10,30),xlim=c(0,30),ylim=c(0,30))

but this is a waste of space.

Thanks



__
R-help@r-project.org 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] Proportional axes

2008-05-21 Thread Agustin Lobo

Thanks, I looked
into the man pages of par() and
did not into the ones of plot()
Sorry about it,
Agus

Richard Rowe escribió:

plot(runif(10,0,10),runif(10,10,30),xlim=c(0,10),ylim=c(10,30), asp=1)
asp is the aspect parameter and ensures x  y metrics are the same (try 
the plot without it).


To save more space you will need to inform the plotting system you want 
a portrait perspective plot and control the size of the canvas. You can 
also drag the handles of the plot as the asp = 1 will maintain the 
metric relationship ... and rely on Brian Ripley's graphics drivers to 
deliver the information you want into a form you can incorporate elsewhere,


Richard


Agustin Lobo wrote:

Hi!

If I'm plotting 2 variables with the same units
(i.e. wing length of 2 species), how can I force that X
and Y axes have the same size for length unit? For example, if
X ranges from 0 to 10 and Y ranges from 10 to 30, I want
Y axis to be twice as long as X axis. I know I can just
put xlim and ylim from 0 to 30, i.e.,
plot(runif(10,0,10),runif(10,10,30),xlim=c(0,30),ylim=c(0,30))

but this is a waste of space.

Thanks






--
Dr. Agustin Lobo
Institut de Ciencies de la Terra Jaume Almera (CSIC)
LLuis Sole Sabaris s/n
08028 Barcelona
Spain
Tel. 34 934095410
Fax. 34 934110012
email: [EMAIL PROTECTED]
http://www.ija.csic.es/gt/obster

__
R-help@r-project.org 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] Search a string and modify it in a .txt file

2008-05-21 Thread Romain
Hi there,

I use R and I would like to be able to modify a file .txt init_file like this 
one :

#  #
# Parameters A
#  #
# Parameter 1
PA1 = 15

# Parameter 2
PA2 = 3

# Parameter 3
PA3 = 2

#  #


#  #
# Parameters B
#  #

# Parameter 1
PB1 = 6

...

I have in a first time stocked the values I want to attribute to each parameter 
and so I would like to create several config files like the first one but with 
different values for each parameter. I have an array like this one 

  PA1  PA2   PA3 PB1 
j=1   122 15
j=2   103 24
j=3   114 36
...



To create each file I use :

for (j in 1:Nb_config_file)
{
file.copy(fichier_init,paste(Config_file,j,sep=))
 }

How can I do to search in each config file j created to modify the values of 
the parameters according to the j-th row of the array?
I thought about looking for the lines 'Parameter' = Value and modify this 
line in 'Parameter' = New_value but I don't find any function to know the 
location of each string in my config_file...

I could also use such a function to modify the format of the date to replace 
the : by something which can be used in a Directory/file name.


Thanks you for your time and for your future help =)


Cheers

Romain



Vous aussi bénéficiez d'1 Go de stockage gratuit en ligne avec Voila  
http://macle.voila.fr

__
R-help@r-project.org 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] number of trading days

2008-05-21 Thread threshold

Hi, I work on the date format: mmdd. I would like to calculate the number
of (working or trading) days between two of such specified dates in specific
year at US stock exchange OR at least with respect to 252-days year.

What I did so far was the conversion (example):
x-20060213; y-20060402 # refering to January 13 and April 2, 2006
x1 - as.Date(as.character(x), %Y%m%d)
y1 - as.Date(as.character(y), %Y%m%d)
# nuber of calendar days
nr_cal-diff(rbind(x1,y1))

best regards, robert




-- 
View this message in context: 
http://www.nabble.com/number-of-trading-days-tp17364148p17364148.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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] number of trading days

2008-05-21 Thread Dirk Eddelbuettel
On Wed, May 21, 2008 at 04:44:32AM -0700, threshold wrote:
 
 Hi, I work on the date format: mmdd. I would like to calculate the number
 of (working or trading) days between two of such specified dates in specific
 year at US stock exchange OR at least with respect to 252-days year.
 
 What I did so far was the conversion (example):
 x-20060213; y-20060402 # refering to January 13 and April 2, 2006
 x1 - as.Date(as.character(x), %Y%m%d)
 y1 - as.Date(as.character(y), %Y%m%d)
 # nuber of calendar days
 nr_cal-diff(rbind(x1,y1))

Have a look at the fCalendar package on CRAN.

Dirk

-- 
Three out of two people have difficulties with fractions.

__
R-help@r-project.org 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] Sweave / Latex per-chapter output

2008-05-21 Thread Brett Presnell

Anne-Marie Ternes [EMAIL PROTECTED] writes:

 What I would like to do, is to be able to get 2 types of output with
 the same code (I'm lazy ;-) ):
 ...
 2. a PDF and HTML file *per chapter*, for displaying on our website
 and allowing people to download individual chapters
 
 ...
 
 BTW, I'm working on Ubuntu Linux.

I'm assuming that you are using pdflatex to process the latex file(s)
produced by Sweave.

Assuming also that you are using latex's \include command (e.g.,
\include{chap1}, \include{chap2}, etc.) inside your master file, you
could add a line like

\includeonly{chap2}

in the preamble to just create a pdf file containing only Chapter 2.
The easiest way to do this is probably to edit the master latex file
by hand, after having run pdflatex a few times to produce the full
document (you need to do this to get all the pagination and
cross-referencing information into the .aux, .toc, and other files).

Another way to accomplish 2 is to install Ubuntu's pdftk package then
use the pdftk command with the cat option to extract whatever pages
you want.

__
R-help@r-project.org 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] mixed effects models with nested factors

2008-05-21 Thread Luis Cayuela

Thanks for the help provided to fit the model. I still have two questions:

1) What is the syntax for nested fixed and random factors. I have tried 
using the %in% operator but it does not work. The model I want to fit would 
be as follow:


lmer 1 - lmer(Growing ~ Seed + Species%in%Seed + Treatment + 
(1|Block%in%Treatment), data)


2) Seed, Species and Treatment are intra-subject factors. This means that an 
ANOVA of repeated measure should apply here. How should this be specified in 
the model? Or should I assume that this is incorporated by specifying the 
Block as a random factor?


All the best,

Luis

Luis Cayuela
Departamento de Ecología
Universidad de Alcalá
Crta. de Barcelona km. 33,600
E-28871 Alcalá de Henares
Madrid
España
Tlf: (+0034) 918856407
Fax: (+0034) 918854929
- Original Message - 
From: Douglas Bates [EMAIL PROTECTED]

To: Luis Cayuela [EMAIL PROTECTED]
Cc: r-help@r-project.org
Sent: Thursday, May 15, 2008 5:22 PM
Subject: Re: [R] mixed effects models with nested factors


On Thu, May 15, 2008 at 9:22 AM, Luis Cayuela [EMAIL PROTECTED] wrote:

Hi everybody,


I am trying to fit a model with the lmer function for mixed effects. I 
have an experimental design consisting of 5 field plots. Each plot is 
divided in 12 subplots where the influence of three factors on the growing 
of tree seedlings is tested: (1) seed (1 = presence; 0 = absence); (2) 
seedling species (oak holm vs. pine); (3) treatment (three different 
treatments). In each of these subplots we planted 13 seedlings. Therefore 
I would have a model with three fixed factors and one random factor (a 
block?). If I´m not wrong the model would be as follows:


model2 - lmer(Growing ~ Seed + Species + Treatment +(Seed + Species + 
Treatment|Block), data)


That's unlikely. This specification would fit 5 fixed effects
parameters and 5, possibly correlated, random effects for each level
of the Block factor.  This would require estimating a total of 15
variance-covariance parameters for the random effects from the 5
blocks.

Can you indicate how many random effects you expect to obtain and how
many variance-covariance parameters would be involved?  For example, a
model with a simple random effect would be expressed as

lmer(Growing ~ Seed + Species + Treatment + (1|Block), data)

and would involve estimating the 5 fixed effects and one variance for
the random effects.
My first question is: if the three fixed factors occur within-subjects 
(considering the plot as a subject), is the model correctly defined 
(assuming no interactions)? Should I specify the model in some other way?




I second problem I had is that the factors are not crossed because some of 
the seedling died during the experiment. This means that some factors are 
nested. Specifically Species is nested within Seed and Block would be 
nested within Treatment. I have tried to use the %in% specification for 
nested designs but it does not work.




model2 - lmer(Growing ~ Seed + Species%in%Seed + Treatment +(Seed + 
Species + Treatment|Block%in%Treatment), data)




I get the following error:



Error en lmer(Growing ~ Seed + Species %in% Seed + Treatment +  : ..

 Leading minor of order 5 in downdated X'X is not positive definite



I would appreciate some help to fit this model.


Thanks to everybody,

Luis


__
R-help@r-project.org 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] scheduling - algorithm solution or iterate?

2008-05-21 Thread SocialProgrammer

Our final year students rank 5 classes (1st, 2nd, ..., 5th), and are
allocated 3, based on their choices and a minimum class size.
We want to maximise satisfaction (students getting their higher
preferences), but have a minimum viable class size.
Is there an algorithm out there to help, in R (like TSP for the travelling
salesman prob) or elsewhere, or must I just iterate and locate the highest
scoring ???

Thanks!
-- 
View this message in context: 
http://www.nabble.com/scheduling---algorithm-solution-or-iterate--tp17364154p17364154.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org 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] 'Extracting' plot area

2008-05-21 Thread Tine

Hi!

Does anyone know hot to save (to png, pdf, ...) only plot area. That is 
without box around, titles, axis, ...
I tried: par(mar=c(0,0,0,0)) and it works for internal viewer (linux and 
windows).
But when I save the image in png it adds that annoying margin around 
plot area.

Any ideas?

by, Tine

__
R-help@r-project.org 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] 'Extracting' plot area

2008-05-21 Thread Marc Schwartz

on 05/21/2008 08:02 AM Tine wrote:

Hi!

Does anyone know hot to save (to png, pdf, ...) only plot area. That is 
without box around, titles, axis, ...
I tried: par(mar=c(0,0,0,0)) and it works for internal viewer (linux and 
windows).
But when I save the image in png it adds that annoying margin around 
plot area.

Any ideas?

by, Tine


Is this what you want?

  pdf(plot.pdf, height = 4, width = 4)
  par(mar = c(0, 0, 0, 0))
  plot(1:10, ann = FALSE, axes = FALSE)
  dev.off()

See ?plot.default for more information on the 'ann' and 'axes' arguments.

HTH,

Marc Schwartz

__
R-help@r-project.org 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] 'Extracting' plot area

2008-05-21 Thread Duncan Murdoch

On 5/21/2008 9:02 AM, Tine wrote:

Hi!

Does anyone know hot to save (to png, pdf, ...) only plot area. That is 
without box around, titles, axis, ...
I tried: par(mar=c(0,0,0,0)) and it works for internal viewer (linux and 
windows).
But when I save the image in png it adds that annoying margin around 
plot area.

Any ideas?


Set up the options for no margins after opening the device.  (If you are 
copying from the screen device in Windows, you don't need to do it 
again; presumably the same is true in Linux.  But if you use png() to 
open a png device it will start up with default par settings.  You need 
to set the margins after that.)


For example,

 png(test.png)
 par(mar=c(0,0,0,0), xaxs=i, yaxs=i)
 plot(runif(1))
 dev.off()

produces a big ugly plot without those nice margins.

Duncan Murdoch

__
R-help@r-project.org 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] Rank Values in a Matrix

2008-05-21 Thread Marianne Promberger
On 05/19/08 13:46, Jens Oldeland wrote:
 Dear All,

 a short and maybe simple question:


 I have to rank all values in a matrix from 0 to X,

[1]   [2] [3]  [4]
 [1] 0.1  2   03
 [2] 50   3   31
 [3] 100 1   10
 [4] 100  2  20

 0-0
 0.1-1
 2-2
 3-3
 50-4
 100-5  (X=5)


Does this do what you want?

x - matrix(c(3,100,0.1,3,100,2,5,0,0,50),5)
y - as.data.frame(table(x))
y$Rank - rank(y$x)

m.


-- 
Marianne Promberger
Graduate student in Psychology
http://www.psych.upenn.edu/~mpromber

__
R-help@r-project.org 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] Search a string and modify it in a .txt file

2008-05-21 Thread jim holtman
Instead of trying to modify the file, why not generate it from the data that
you have.  Is the array in your mail an example of one of many that have the
configuration data?  If so, why don't you just create the output file from
that data.  You can just loop through and do 'writeLines' to create the
init_file.

On Wed, May 21, 2008 at 7:05 AM, Romain [EMAIL PROTECTED] wrote:

 Hi there,

 I use R and I would like to be able to modify a file .txt init_file like
 this one :

 #
 
 #
 # Parameters A
 #
 
 #
 # Parameter 1
 PA1 = 15

 # Parameter 2
 PA2 = 3

 # Parameter 3
 PA3 = 2

 #
 
 #


 #
 
 #
 # Parameters B
 #
 
 #

 # Parameter 1
 PB1 = 6

 ...

 I have in a first time stocked the values I want to attribute to each
 parameter and so I would like to create several config files like the first
 one but with different values for each parameter. I have an array like this
 one

  PA1  PA2   PA3 PB1 
 j=1   122 15
 j=2   103 24
 j=3   114 36
 ...



 To create each file I use :

 for (j in 1:Nb_config_file)
{
file.copy(fichier_init,paste(Config_file,j,sep=))
 }

 How can I do to search in each config file j created to modify the values
 of the parameters according to the j-th row of the array?
 I thought about looking for the lines 'Parameter' = Value and modify this
 line in 'Parameter' = New_value but I don't find any function to know the
 location of each string in my config_file...

 I could also use such a function to modify the format of the date to
 replace the : by something which can be used in a Directory/file name.


 Thanks you for your time and for your future help =)


 Cheers

 Romain

 

 Vous aussi bénéficiez d'1 Go de stockage gratuit en ligne avec Voila
 http://macle.voila.fr

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Odp: Problem in converting natural numbers to bits and others

2008-05-21 Thread Vincent Goulet


Le mer. 21 mai à 04:38, Petr PIKAL a écrit :


Hallo

[EMAIL PROTECTED] napsal dne 21.05.2008 09:42:40:


Hi,

I just started using R for about one week and I have few problems.

i)I have a problem in finding right function to convert a table of

natural

numbers to bitwise. For a simple example;

I have the below table:-

Column  Col1   Col2   Col3
Sample1 57  10
Sample2 02   1
Sample3 4 0   0


Supposedly i wanted to convert to :-


Column  Col1   Col2   Col3
Sample1 11   1
Sample2 01   1
Sample3 1 0   0


data-read.table(clipboard, header=T
If data is your data frame,

data.bit-data.frame(column=data[,1],(data[,-1]0)*1)


sign(data) will also do.

Vincent






ii)Besides, I would like to create a formula of Sum(3*(Element in  
each

column for a row))..does it equivalent to 3*(data[1:3,1:2]) in this

case?or

I need to have Sum(3*(data[1:3,1:2])). Basically I wanted to mutliply

each

element of column table of a row and sum it  up.


Rather complicated.


3*(data[1:3,2:3])

 Col1 Col2
1   15   21
206
3   120

sum(3*(data[1:3,2:3]))

[1] 54

Works but I am suspicious that you wont something else.




iii)I would also like to know how to insert an if else statement  
where

in

the above case, I wanted to check if data[1:3,]
returns me 1 or 0, it will execute some calculations.
I refer to the R intro pdf and it mentioned using if (expr_1 ) expr_2

else

expr_3. Does that mean if(data[1:3,1:2])0 output[1:3,1:2]=0
else output[1:3,1:2]=100. If I did this command, how does R knows

which

row and column to map the output with?


If ... else ... is usually for working as programming steps

ifelse(..., ..., ...)

works with objects and is parts. You shall think first how to do your
calculations with whole objects, it is usually more effective.

Regards
Petr



Please advise. Appreciate alot. Thanks.

  [[alternative HTML version deleted]]

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

http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.


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


__
R-help@r-project.org 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] Search a string and modify it in a .txt file

2008-05-21 Thread jim holtman
Here is an example of how to create the init files:

x - read.table(textConnection( PA1  PA2   PA3 PB1
j=1   122 15
j=2   103 24
j=3   114 36), header=TRUE)
closeAllConnections()
for (i in 1:nrow(x)){
outfile - file(paste(init., i, .txt, sep=''), w)
for (j in colnames(x)){
writeLines(paste(j, '=', x[i,j], sep=''), outfile)
}
close(outfile)
}
This will create a file that will look like this:

 readLines('init.1.txt')
[1] PA1=12 PA2=2  PA3=1  PB1=5



On Wed, May 21, 2008 at 7:05 AM, Romain [EMAIL PROTECTED] wrote:

 Hi there,

 I use R and I would like to be able to modify a file .txt init_file like
 this one :

 #
 
 #
 # Parameters A
 #
 
 #
 # Parameter 1
 PA1 = 15

 # Parameter 2
 PA2 = 3

 # Parameter 3
 PA3 = 2

 #
 
 #


 #
 
 #
 # Parameters B
 #
 
 #

 # Parameter 1
 PB1 = 6

 ...

 I have in a first time stocked the values I want to attribute to each
 parameter and so I would like to create several config files like the first
 one but with different values for each parameter. I have an array like this
 one

  PA1  PA2   PA3 PB1 
 j=1   122 15
 j=2   103 24
 j=3   114 36
 ...



 To create each file I use :

 for (j in 1:Nb_config_file)
{
file.copy(fichier_init,paste(Config_file,j,sep=))
 }

 How can I do to search in each config file j created to modify the values
 of the parameters according to the j-th row of the array?
 I thought about looking for the lines 'Parameter' = Value and modify this
 line in 'Parameter' = New_value but I don't find any function to know the
 location of each string in my config_file...

 I could also use such a function to modify the format of the date to
 replace the : by something which can be used in a Directory/file name.


 Thanks you for your time and for your future help =)


 Cheers

 Romain

 

 Vous aussi bénéficiez d'1 Go de stockage gratuit en ligne avec Voila
 http://macle.voila.fr

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




-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Sweave / Latex per-chapter output

2008-05-21 Thread Jean lobry

Dear Anne-Marie,

we had a similar problem to handle the LaTeX book that ships with the
seqinr package (http://pbil.univ-lyon1.fr/software/seqinr/seqinr_1_1-5.pdf).

Here is basically the approach we have used:

o Each book chapter is written first as a LaTeX article produced by Sweaving
  its corresponding *.rnw file. They are therefore available as individual
  articles in PDF.

o The book itself is produced by collating the core of each LaTeX source
  files and turning articles titles into chapter titles (among other things
  such as computing the full author list from article authors). The book is
  therefore also available in PDF without changing the *.rnw files.

There are of course some constraints for this to work (e.g. all articles
are sharing the same *.bib file, all figures are in the same folder and
we are using the following (ugly) construct:

hack, echo=FALSE, fig=FALSE, results=hide, eval=TRUE=
.CurFileName - get(file, env = parent.frame(3))
.PrefixName - strsplit(.CurFileName, \\.)[[1]][1]
@

\SweaveOpts{prefix.string = ../figs/\Sexpr{.PrefixName} }

to avoid collisions between figures names produced by Sweave by prefixing
them with the current *.rnw file name, etc.)

If you want to know more the source code for the book is distributed with
the seqinr package in the /doc/src folder, see /doc/src/template/template.pdf
file as a starter. Please send an e-mail to the seqinr diffusion list if you
have more questions.

HTH,

Jean

--
Jean R. Lobry([EMAIL PROTECTED])
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
allo  : +33 472 43 27 56 fax: +33 472 43 13 88
http://pbil.univ-lyon1.fr/members/lobry/

__
R-help@r-project.org 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 with data frames, factors and lists

2008-05-21 Thread Karin Lagesen

I have a function that creates a list based on some clustered data:

mix - function(Y, pid) {
hc = gethc(Y,pid)
maxheight = max(hc$height)
noingrp = processhc(hc)
one = noingrp$one
two = noingrp$two
twoisone = one
if (two != 1)
  twoisone = more
out = list(pid = pid,one = noingrp$one, two = noingrp$two, diff = maxheight, 
noseqs = length(hc$labels), twogrp = twoisone)
return(out)
}

example result:

 mix(tsus_same, 77)
$pid
[1] 77

$one
[1] 9

$two
[1] 2

$diff
[1] 8.577195

$noseqs
[1] 11

$twogrp
[1] more



I then use this function in another function that just runs this
function through a lot of data:


doset - function(sameset) {
pids = unique(c(sameset$APID, sameset$BPID))
for (f in pids) {
  oputframe = data.frame(rbind(oputframe, mix(sameset, f)))
  }
return(oputframe)
}

All values except $twogrp are numbers. There are two possible values
for $twogrp, one and more. the first one is more common and gets
added to the data frame first. The result is that I cannot add the
rows where this is more without getting

38: In `[-.factor`(`*tmp*`, ri, value = more) :
  invalid factor level, NAs generated


Now, this is a pain in the neck. How can I merge these lists to the
data frame and still have the value $twogrp as a factor?

Thanks, and I hope my code makes some sense!

Karin
-- 
Karin Lagesen, PhD student 
[EMAIL PROTECTED]
http://folk.uio.no/karinlag

__
R-help@r-project.org 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] an unknown error message when using gamm function

2008-05-21 Thread Lung-Chang Chien
The version is mgcv 1.3-27. Last night, I dropped out many arguments from my
program to test which part
might be the source of causing this error message, and found that the
program works when just using corAR1().

This program has no this kind of problem in the beginning, but doesn't work
after I impute some missing data
in PM10 and tmean by multiple imputation approach. Hope this information can
also help identify the
element of this problem.

LC

 From: Simon Wood [EMAIL PROTECTED]
 To: r-help@r-project.org
 Date: Wed, 21 May 2008 08:55:02 +0100
 Subject: Re: [R] an unknown error message when using gamm function
 What version of mgcv are you using, please?

 On Wednesday 21 May 2008 06:16, Lung-Chang Chien wrote:
 Dear everyone,

 I'm encountering an unknown error message when using gamm function:
  fitoutput -

 gamm(cvd~as.factor(dow)+pm10+s
(time,bs=cr,k=15,fx=TRUE)+s(tmean,bs=cr,k
=7,fx=TRUE) +

,correlation=corAR1(form=~1|city),family=poisson,random=list(city=~pm10),da
ta=mimp)


  Maximum number of PQL iterations:  20
 iteration 1
 iteration 2
 iteration 3
 iteration 4
 iteration 5
 iteration 6
 Error in `*tmp*`[[k]] : attempt to select less than one element

 I never saw this error message before, and there is also no related
 information about this error from the Internet. Hope some people who once
 encountered this problem can tell me what's wrong.

 Many thanks,

 LC


-- 
Lung-Chang Chien
Doctoral candidate, Department of Biostatistics
Statistical assistant, School of Nursing
University of North Carolina at Chapel Hill
Office: Carrington Hall, RSC, Room 2014
TEL: 919-843-2480

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] split character string in matrix into character vector and numeric vector

2008-05-21 Thread Kim Milferstedt

Hello,

I've got a matrix consisting of one column with n rows. Each field in 
the matrix is filled with a character vector.


I would like to convert this matrix into a character vector containing 
the B03_MAH-type entries from the beginning of each row and a data.frame 
that contains the numeric data, but I am stuck.


I have tried to use textConnection with sep =but since there is 
sometimes more than two spaces separating the entries, I obtain a result 
with columns full of NAs.


Then I tried sub() to replace the all multi-spaces to get only one space 
that separates each entry but that didn't work either.


Do you know a good way to convert this matrix?

Thanks already,

Kim

taxa.vec B03_MAH 0.2115  0.2087  0.2087  0.2147  0.2115  0.2176 
taxa.vec F02_SSBH0.2162  0.2191  0.2133  0.2130  0.2220  0.2158 
taxa.vec G04_MAH 0.2083  0.2111  0.2055  0.2115  0.2140  0.2087 
taxa.vec A04_MAH 0.2097  0.2126  0.2069  0.2065  0.2097  0.2037 
taxa.vec E03_MAH 0.2097  0.2069  0.2069  0.2130  0.2155  0.2101


__
R-help@r-project.org 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] split character string in matrix into character vector and numeric vector

2008-05-21 Thread Christos Hatzis
 x - B03_MAH 0.2115  0.2087  0.2087  0.2147  0.2115  0.2176
 strsplit(x,  +)
[[1]]
[1] B03_MAH 0.2115  0.2087  0.2087  0.2147  0.2115  0.2176 

-Christos

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Kim Milferstedt
 Sent: Wednesday, May 21, 2008 1:11 PM
 To: [EMAIL PROTECTED]
 Subject: [R] split character string in matrix into character 
 vector and numeric vector
 
 Hello,
 
 I've got a matrix consisting of one column with n rows. Each 
 field in the matrix is filled with a character vector.
 
 I would like to convert this matrix into a character vector 
 containing the B03_MAH-type entries from the beginning of 
 each row and a data.frame that contains the numeric data, but 
 I am stuck.
 
 I have tried to use textConnection with sep =but since 
 there is sometimes more than two spaces separating the 
 entries, I obtain a result with columns full of NAs.
 
 Then I tried sub() to replace the all multi-spaces to get 
 only one space that separates each entry but that didn't work either.
 
 Do you know a good way to convert this matrix?
 
 Thanks already,
 
 Kim
 
 taxa.vec B03_MAH 0.2115  0.2087  0.2087  0.2147  0.2115  0.2176 
 taxa.vec F02_SSBH0.2162  0.2191  0.2133  0.2130  0.2220  0.2158 
 taxa.vec G04_MAH 0.2083  0.2111  0.2055  0.2115  0.2140  0.2087 
 taxa.vec A04_MAH 0.2097  0.2126  0.2069  0.2065  0.2097  0.2037 
 taxa.vec E03_MAH 0.2097  0.2069  0.2069  0.2130  0.2155  0.2101
 
 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.
 


__
R-help@r-project.org 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 do pairwise sums in a matrix

2008-05-21 Thread Henrique Dallazuanna
Try this:

t(rowsum(t(Mat), substr(colnames(Mat), 1, 1)))

On Wed, May 21, 2008 at 2:22 PM, Gregory Gentlemen 
[EMAIL PROTECTED] wrote:

 I am looking for an efficient way to solve the following problem. I have a
 large matrix of continuous values with a small proportion of missing values.
 Columns correspond to variables where each variable has two measurements,
 call them A and B. The matrix is such that the columns are in sequence with
 respect to the variables. I would like to sum up the two measurements for
 each variable and each observation (the rows) for the whole matrix. Here is
 an example of such a matrix with 5 variables (R, S, T, U, V) and 50
 observations:

 set.seed(27)
 Mat - matrix(rnorm(500), nrow=50, ncol=10)
 dimnames(Mat)[[2]] -
 c(R.A,R.B,S.A,S.B,T.A,T.B,U.A,U.B,V.A,V.B)

 miss.ind - rbinom(500,1,prob=0.98)
 Mat[!as.logical(miss.ind)] - NA

 So I would like to produce 50 by 5 matrix where the columns are the sums of
 A+B measurements for each of the 5 variables.

 Thanks for any help.

 Gregory Gentlemen


 -

[[alternative HTML version deleted]]

 __
 R-help@r-project.org 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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Labeling a plot's x-axis with 12 strings, vertically oriented.

2008-05-21 Thread John

Hello,

I really enjoy using R for my plotting. I have a modest plot, containing 
24 data points, across 2 lines,12 points each. Ideally, the x-axis would 
be labeled with a series of strings, oriented vertically. Here is the R 
container holding the Search strings:


 Search
[1] Route To: NCENGR  Status: Open 
CR Route To: NCENGR   
[3] Status: Cancel Route To: TEST1   Status: ENG REQ 
Route To: TDELLE   
[5] (*) Customer Name: *(*) 
Customer Name: S*IT*   
[7] (*) Customer Name: SMITH   (*) Address: 
1***  
[9] (*) Address: 1** S ST   Route To: 
NCS  
[11] Route To: NCS  From Date: 01/01/2000 Name: 
SMITH
12 Levels: (*) Address: 1** S ST(*) Address: 
1*** ... Status: Open CR Route To: NCENGR



Is there a function to define the x-axis, using the above 12 strings as 
axis tick labels, from 1 - 12, vertically oriented? Any help would be 
appreciated, as my current work around is tedious, and not asthetically 
pleasing.


Cheers,

John

__
R-help@r-project.org 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] Labeling a plot's x-axis with 12 strings, vertically oriented.

2008-05-21 Thread Greg Snow
Here is one example:

 y - rnorm(12)
 x - 1:12

 par(mar=c(10, 4, 4, 1)+0.1)
 plot(x,y, xlab='', xaxt='n')
 axis(1, at=x, labels=month.name, las=2)


See help on par and axis for details.

--
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 John
 Sent: Wednesday, May 21, 2008 12:56 PM
 To: r-help@r-project.org
 Subject: [R] Labeling a plot's x-axis with 12 strings,
 vertically oriented.

 Hello,

 I really enjoy using R for my plotting. I have a modest plot,
 containing
 24 data points, across 2 lines,12 points each. Ideally, the
 x-axis would be labeled with a series of strings, oriented
 vertically. Here is the R container holding the Search strings:

   Search
  [1] Route To: NCENGR
 Status: Open
 CR Route To: NCENGR
  [3] Status: Cancel Route To: TEST1   Status: ENG REQ
 Route To: TDELLE
  [5] (*) Customer Name: *(*)
 Customer Name: S*IT*
  [7] (*) Customer Name: SMITH   (*) Address:
 1***
  [9] (*) Address: 1** S ST   Route To:
 NCS
 [11] Route To: NCS  From Date: 01/01/2000 Name:
 SMITH
 12 Levels: (*) Address: 1** S ST(*) Address:
 1*** ... Status: Open CR Route To: NCENGR


 Is there a function to define the x-axis, using the above 12
 strings as axis tick labels, from 1 - 12, vertically
 oriented? Any help would be appreciated, as my current work
 around is tedious, and not asthetically pleasing.

 Cheers,

 John

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


__
R-help@r-project.org 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] Labeling a plot's x-axis with 12 strings, vertically oriented.

2008-05-21 Thread Duncan Murdoch

On 5/21/2008 2:56 PM, John wrote:

Hello,

I really enjoy using R for my plotting. I have a modest plot, containing 
24 data points, across 2 lines,12 points each. Ideally, the x-axis would 
be labeled with a series of strings, oriented vertically. Here is the R 
container holding the Search strings:


  Search
 [1] Route To: NCENGR  Status: Open 
CR Route To: NCENGR   
 [3] Status: Cancel Route To: TEST1   Status: ENG REQ 
Route To: TDELLE   
 [5] (*) Customer Name: *(*) 
Customer Name: S*IT*   
 [7] (*) Customer Name: SMITH   (*) Address: 
1***  
 [9] (*) Address: 1** S ST   Route To: 
NCS  
[11] Route To: NCS  From Date: 01/01/2000 Name: 
SMITH
12 Levels: (*) Address: 1** S ST(*) Address: 
1*** ... Status: Open CR Route To: NCENGR



Is there a function to define the x-axis, using the above 12 strings as 
axis tick labels, from 1 - 12, vertically oriented? Any help would be 
appreciated, as my current work around is tedious, and not asthetically 
pleasing.


plot(1:12, axes=F)
axis(1, at=1:12, labels=c('one','two','three','four','five','six',
  'seven', 'eight', 'nine','ten','eleven','twelve'), las=2)
axis(2)
box()


You'll probably need bigger margins for your longer strings.

Duncan Murdoch

__
R-help@r-project.org 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 write fac.design (S-plus) in R

2008-05-21 Thread Becky lin
hi,

Anyone here know well of the fac.design of S-plus? I need to rewrite the
following code in R

code in S-plus
*pt.design = fac.design( c(2,2,3,2),factor.names = list(Hs=c(I,II),lef =
c(0,1),lep = c(0,1,2),Type=c(gt,sy)))
c.design=fac.design(
levels=c(2,2,2,2),factor=list(A=lohi,B=lohi,C=lohi,D=lohi),fraction=1/2)
f.design=fac.design(
rep(2,6),factor.names=c(XF,XE,XD,XC,XB,XA),fraction=~XA:XB:XC:XD+XB:XC:XE:XF)
*
I need to rewrite the above in R, but I have no idea what the results look
like under S-plus since I don't have such platform.
So could some one here help me out, or just give the result under S-plus
will also be appreciated.

Best Wishes,
Becky

-- 
+

Be not afraid of growing slowly,
be afraid only of standing still.
$B!]!](BChinese Proverb

+

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Course of R in Brazil

2008-05-21 Thread Ana Carol Nunes
Hello!

I´m Ana Carolina from UNICAMP (Campinas - SP - Brazil) and wonders, if there
is someone interested and qualified, to give a course of R during one week
in UNICAMP for the Department of Social and Preventive Medicine.
We need to be some lessons on use of mgcv, gam and VGAM packages.
If there is interest, please contact us. We have some urgency! The course
would be for June / 08.

Thanks,
Ana Carolina

[[alternative HTML version deleted]]

__
R-help@r-project.org 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] fac.design in R

2008-05-21 Thread Becky lin
hi,

Anyone here know well of the fac.design of S-plus? I need to rewrite the
following code in R

code in S-plus
*pt.design = fac.design( c(2,2,3,2),factor.names = list(Hs=c(I,II),lef =
c(0,1),lep = c(0,1,2),Type=c(gt,sy)))
c.design=fac.design(
levels=c(2,2,2,2),factor=list(A=lohi,B=lohi,C=lohi,D=lohi),fraction=1/2)
f.design=fac.design(
rep(2,6),factor.names=c(XF,XE,XD,XC,XB,XA),fraction=~XA:XB:XC:XD+XB:XC:XE:XF)
*
I need to rewrite the above in R, but I have no idea what the results look
like under S-plus since I don't have such platform.
So could some one here help me out, or just give the result under S-plus
will also be appreciated.

Best Wishes,
Becky

[[alternative HTML version deleted]]

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


[R] Converting a 'difftime' to integer - How to???

2008-05-21 Thread Martin Hvidberg
I want to find the DOY (Day of Year) of some dates. I think to substract the 
date 1. January from the data to achive this. Something like:

  d - as.Date(2006-03-13) - as.Date(2006-01-01) +1
 d
Time difference of 72 days

So far so good. But d is a 'difftime' object. How do I get an Integer value 
from that?

I tried severel things, incuding the following:

 dd - as(d,numeric)
Error in .classEnv(thisClass) : 
  unable to find an environment containing class difftime

Sugestions appriciated...

:-) [EMAIL PROTECTED]

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


Re: [R] Converting a 'difftime' to integer - How to???

2008-05-21 Thread Henrique Dallazuanna
Try :

as.numeric(d)

or also:

unclass(d)


On Wed, May 21, 2008 at 5:04 PM, Martin Hvidberg [EMAIL PROTECTED]
wrote:

 I want to find the DOY (Day of Year) of some dates. I think to substract
 the date 1. January from the data to achive this. Something like:

   d - as.Date(2006-03-13) - as.Date(2006-01-01) +1
  d
 Time difference of 72 days

 So far so good. But d is a 'difftime' object. How do I get an Integer value
 from that?

 I tried severel things, incuding the following:

  dd - as(d,numeric)
 Error in .classEnv(thisClass) :
  unable to find an environment containing class difftime

 Sugestions appriciated...

 :-) [EMAIL PROTECTED]

 __
 R-help@r-project.org 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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

[[alternative HTML version deleted]]

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


Re: [R] Converting a 'difftime' to integer - How to???

2008-05-21 Thread Erik Iverson
Or, convert your object of class Date to POSIXlt, and then use the yday 
element of the resulting list.  Example:


today - Sys.Date()
as.POSIXlt(today)$yday

Erik

Martin Hvidberg wrote:

I want to find the DOY (Day of Year) of some dates. I think to substract the 
date 1. January from the data to achive this. Something like:


 d - as.Date(2006-03-13) - as.Date(2006-01-01) +1
d

Time difference of 72 days

So far so good. But d is a 'difftime' object. How do I get an Integer value 
from that?

I tried severel things, incuding the following:


dd - as(d,numeric)
Error in .classEnv(thisClass) : 
  unable to find an environment containing class difftime


Sugestions appriciated...

:-) [EMAIL PROTECTED]

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


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


Re: [R] Converting a 'difftime' to integer - How to???

2008-05-21 Thread Peter Dalgaard

Martin Hvidberg wrote:

I want to find the DOY (Day of Year) of some dates. I think to substract the 
date 1. January from the data to achive this. Something like:

  

 d - as.Date(2006-03-13) - as.Date(2006-01-01) +1
d


Time difference of 72 days

So far so good. But d is a 'difftime' object. How do I get an Integer value 
from that?

I tried severel things, incuding the following:

  

dd - as(d,numeric)

Error in .classEnv(thisClass) : 
  unable to find an environment containing class difftime


Sugestions appriciated...

  

The canonical way is

 as.numeric(d, units=days)
[1] 72

In fact, you can leave out the units when dealing with differences 
between Date objects, because it is always days, but that is an 
undocumented implementation detail.


If you have differences between POSIXt objects, real confusion can arise:

 ISOdatetime(2008,1,1,12,0,2) - ISOdatetime(2008,1,1,12,0,0)
Time difference of 2 secs
 ISOdatetime(2008,1,1,12,2,0) - ISOdatetime(2008,1,1,12,0,0)
Time difference of 2 mins
 ISOdatetime(2008,1,1,14,0,0) - ISOdatetime(2008,1,1,12,0,0)
Time difference of 2 hours

--
  O__   Peter Dalgaard Øster Farimagsgade 5, Entr.B
 c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark  Ph:  (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-help@r-project.org 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] generating help files

2008-05-21 Thread Erin Hodgess
Hi R People!

Is there a quick way to generate help files for functions, please?

I know that if you use package.skeleton, that will work.  However,
I'm not using that for a new package.

(Hope this make sense)

this is for SUSE10.1, please.

thanks,
Erin


-- 
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: [EMAIL PROTECTED]

__
R-help@r-project.org 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] generating help files

2008-05-21 Thread baptiste Auguié

Hi,

try prompt(yourFunction)

hope thus helps,

baptiste

On 21 May 2008, at 21:40, Erin Hodgess wrote:


Hi R People!

Is there a quick way to generate help files for functions, please?

I know that if you use package.skeleton, that will work.  However,
I'm not using that for a new package.

(Hope this make sense)

this is for SUSE10.1, please.

thanks,
Erin


--  
Erin Hodgess

Associate Professor
Department of Computer and Mathematical Sciences
University of Houston - Downtown
mailto: [EMAIL PROTECTED]

__
R-help@r-project.org 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.


_

Baptiste Auguié

Physics Department
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
http://projects.ex.ac.uk/atto

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


Re: [R] Converting qqplot2 qplot() to grammar?

2008-05-21 Thread hadley wickham
 Now that this part is working there are two more aspects of the plot I
 would like to remove: (in order of importance)

 * The row/column facetting labels.

You should be able to find that using grid.ls()

 * the whitespace that surrounds the plot. I'd like the ggsave output to
 resemble the cropped.png file rather than the ggplot.png file
 (attached).

That's not easy to do at the moment, because you need to modify
properties of the viewports, which you can't currently do with grid.
I'm working on a better customisation solution that should allow you
to do this.  (And to package everything up into a theme that can
easily be applied to other plots)

 * the gaps between the subplots (or the ability to change the colour of
 the subplot border?, looks to be grey50.)

As above.

 Hmm, I just get the generic R help for ggplot that says go to the
 website for complete documentation.

That's weird - you might need to upgrade your R to get the latest
version of ggplot2.

Hadley


-- 
http://had.co.nz/

__
R-help@r-project.org 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] xlab at top in xyplot()

2008-05-21 Thread Deepayan Sarkar
On 5/21/08, Michael Kubovy [EMAIL PROTECTED] wrote:
 Dear R-helpers,

  (1) How do I add a 'top' label symmetric with the 'bottom' label' in:

  axis.td -
   function(side, ...)
   {
   ylim - current.panel.limits()$ylim
   switch(side,
  bottom = {
  panel.axis(side = side, outside = TRUE, rot = 0,
 at = 1:3, labels = c(2.0, 3.5, 5.0))
  },
  top = {
  panel.axis(side = side, outside = TRUE, rot = 45,
 at = 1:3, labels = c(0.143, 0.250, 0.357))
  },
  axis.default(side = side, ...))
   }

  xyplot(1:3 ~ 1:3, type = 'b', axis = axis.td, xlab = 'bottom', ylab =
  'left', aspect = 'xy')

No good way ('main' will be centered differently). I will consider
adding a new row for something like xlab.top (and a column for a
ylab.right).

  (2) Is there a simpler way to create the two axes?

Simpler? Probably not. ?axis.default has this and another approach as
examples; in theory, the other method is better because it gives
lattice a chance to automatically allocate space for the labels, but
that doesn't happen yet in practice.

  (3) A bit more complex:

  df - data.frame(x = rep(1:3, 3), y = 1:9, z = factor(rep(1:3, each =
  3)))
  xyplot(y ~ x | z, df, axis = axis.td, xlab = 'bottom', ylab = 'left',
  layout = c(3, 1), aspect = 'xy', type = 'b')

  Here I would like to have a different pair of top and bottom axes for
  each panel (i.e., different labels at 1:3), and a different top and
  bottom label.

You could use current.column() and current.row() inside axis.td().

The different bottom labels are easy: xlab = c(one, two, three),
but labels on the top are not. Of course, you could add a label from
inside each axis.td call, and add some space for them manually.

-Deepayan

__
R-help@r-project.org 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] automation of R? running an R script at a certain time each night?

2008-05-21 Thread Thomas Pujol
I am using R in a Windows environment. 

I store my data in a Microsoft SQL database that gets updated automatically 
nightly.  Once my SQL db is updated, I wish to automatically run an R script

Any tips on good ways to approach this task? 

Is there an easy way to launch an R script using the Windows or other 
scheduler? Can I have an R-script run every hour, and within the script check 
to determine if my database is updated, and proceed only if it is updated?

   
[[alternative HTML version deleted]]

__
R-help@r-project.org 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] automation of R? running an R script at a certain time each night?

2008-05-21 Thread Edward Wijaya
You might try cron job under Windows.

http://drupal.org/node/31506

HTH.

- Edward

On Thu, May 22, 2008 at 8:51 AM, Thomas Pujol [EMAIL PROTECTED] wrote:
 I am using R in a Windows environment.

 I store my data in a Microsoft SQL database that gets updated automatically 
 nightly.  Once my SQL db is updated, I wish to automatically run an R script

 Any tips on good ways to approach this task?

 Is there an easy way to launch an R script using the Windows or other 
 scheduler? Can I have an R-script run every hour, and within the script 
 check to determine if my database is updated, and proceed only if it is 
 updated?


[[alternative HTML version deleted]]

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


__
R-help@r-project.org 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] Computing Maximum Loglikelihood With nlm Problem

2008-05-21 Thread Edward Wijaya
Hi,

I tried to compute maximum likelihood under gamma distribution,
using nlm function. The code is this:

__BEGIN__

vsamples- c(103.9, 88.5, 242.9, 206.6, 175.7, 164.4)

mlogl - function(alpha, x) {
if (length(alpha)  1) stop(alpha must be scalar)
if (alpha = 0) stop(alpha must be positive)
return(- sum(dgamma(x, shape = alpha, log = TRUE)))
 }

mlogl_out - nlm(mlogl, mean(vsamples),vsamples=vsamples)
print(mlogl_out)

__END__

However, it gives the following error:

Error in f(x, ...) :
  unused argument(s) (vsamples = c(103.9, 88.5, 242.9, 206.6, 175.7, 164.4))
Calls: nlm - Anonymous - f
Execution halted


What's wrong in my way of calling 'nlm function?
Please advice.

- Edward

__
R-help@r-project.org 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] Cumulative average

2008-05-21 Thread Jacques Wagnor
Thank you!  Your interpretation was correct.

I'll remember to be more specific next time.  Thank you for being
patient and understanding.

Jacques

On 5/21/08, jim holtman [EMAIL PROTECTED] wrote:
 Not sure exactly what you want since you did not provide any data or an
 example of the expected out'  Here is my interpretation of what you were
 asking:

 x - sample(1:20)
 x
  [1]  6 16  8  1 17 11  2 19 18  5 15 13  3 20  9 14  7 10 12  4

 cumsum(x) / seq_along(x)
  [1]  6.00 11.00 10.00  7.75  9.60  9.83  8.714286
 10.00 10.89 10.30
 [11] 10.727273 10.916667 10.307692 11.00 10.87 11.062500 10.823529
 10.78 10.842105 10.50



 On Wed, May 21, 2008 at 9:48 PM, Jacques Wagnor [EMAIL PROTECTED]
 wrote:

 Dear List,

 Does there exist a function that calculates a cumulative average?
 Neither running() from library(gregmisc) nor running.mean() from
 library(igraph) seems to be able to give a cumulative average.

 Any help or pointers would be greatly appreciated.

 Jacques

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




 --
 Jim Holtman
 Cincinnati, OH
 +1 513 646 9390

 What is the problem you are trying to solve?


__
R-help@r-project.org 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] Cumulative average

2008-05-21 Thread Andrew Robinson
Jacques,

you should be able to construct a solution from cumsum().

Cheers

Andrew

On Wed, May 21, 2008 at 08:48:29PM -0500, Jacques Wagnor wrote:
 Dear List,
 
 Does there exist a function that calculates a cumulative average?
 Neither running() from library(gregmisc) nor running.mean() from
 library(igraph) seems to be able to give a cumulative average.
 
 Any help or pointers would be greatly appreciated.
 
 Jacques
 
 __
 R-help@r-project.org 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-6410
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/

__
R-help@r-project.org 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] Computing Maximum Loglikelihood With nlm Problem

2008-05-21 Thread Charilaos Skiadas

Try:

mlogl_out - nlm(mlogl, mean(vsamples), vsamples)

or

mlogl_out - nlm(mlogl, mean(vsamples), x=vsamples)

The argument vsamples=vsamples is passed to mlogl, since nlm does not  
recognize it. But mlogl doesn't have a vsamples argument, only alpha  
and x arguments. So you have to either leave mean(vsamples) and  
vsamples unnamed, or else name them alpha and x respectively, as you  
told mlogl. Or change the argument names in mlogl.


Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

On May 21, 2008, at 10:05 PM, Edward Wijaya wrote:


Hi,

I tried to compute maximum likelihood under gamma distribution,
using nlm function. The code is this:

__BEGIN__

vsamples- c(103.9, 88.5, 242.9, 206.6, 175.7, 164.4)

mlogl - function(alpha, x) {
if (length(alpha)  1) stop(alpha must be scalar)
if (alpha = 0) stop(alpha must be positive)
return(- sum(dgamma(x, shape = alpha, log = TRUE)))
 }

mlogl_out - nlm(mlogl, mean(vsamples),vsamples=vsamples)
print(mlogl_out)

__END__

However, it gives the following error:

Error in f(x, ...) :
  unused argument(s) (vsamples = c(103.9, 88.5, 242.9, 206.6,  
175.7, 164.4))

Calls: nlm - Anonymous - f
Execution halted


What's wrong in my way of calling 'nlm function?
Please advice.

- Edward



__
R-help@r-project.org 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] Computing Maximum Loglikelihood With nlm Problem

2008-05-21 Thread Edward Wijaya
Thanks so much.
- Edward

On Thu, May 22, 2008 at 11:17 AM, Charilaos Skiadas [EMAIL PROTECTED] wrote:
 Try:

 mlogl_out - nlm(mlogl, mean(vsamples), vsamples)

 or

 mlogl_out - nlm(mlogl, mean(vsamples), x=vsamples)

 The argument vsamples=vsamples is passed to mlogl, since nlm does not
 recognize it. But mlogl doesn't have a vsamples argument, only alpha and x
 arguments. So you have to either leave mean(vsamples) and vsamples unnamed,
 or else name them alpha and x respectively, as you told mlogl. Or change the
 argument names in mlogl.

 Haris Skiadas
 Department of Mathematics and Computer Science
 Hanover College

 On May 21, 2008, at 10:05 PM, Edward Wijaya wrote:

 Hi,

 I tried to compute maximum likelihood under gamma distribution,
 using nlm function. The code is this:

 __BEGIN__

 vsamples- c(103.9, 88.5, 242.9, 206.6, 175.7, 164.4)

 mlogl - function(alpha, x) {
if (length(alpha)  1) stop(alpha must be scalar)
if (alpha = 0) stop(alpha must be positive)
return(- sum(dgamma(x, shape = alpha, log = TRUE)))
  }

 mlogl_out - nlm(mlogl, mean(vsamples),vsamples=vsamples)
 print(mlogl_out)

 __END__

 However, it gives the following error:

 Error in f(x, ...) :
  unused argument(s) (vsamples = c(103.9, 88.5, 242.9, 206.6, 175.7,
 164.4))
 Calls: nlm - Anonymous - f
 Execution halted


 What's wrong in my way of calling 'nlm function?
 Please advice.

 - Edward








__
R-help@r-project.org 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.