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] colorspace package does not compile on ubuntu 7.04 32 bit

2008-05-21 Thread Mikhail Spivakov

Hi everyone, 
I am trying to install colorspace (needed as part of my favourite ggplot2)
on R v 2.7.0 running under ubuntu 7.04. The package is provided as source
files and the compilation fails as below.
I suspect this might be a problem with gcc v3/v4 incompatibility (or
anything else), but I don't really know how to resolve it. Any advice will
be appreciated - or perhaps somebody has got this package compiled and could
share the binaries?  
Many thanks!
Mikhail


Mikhail Spivakov, PhD
European Bioinformatics Institute
European Molecular Biology Laboratory
Germany/UK

* Installing *source* package 'colorspace' ...
** libs
gcc -std=gnu99 -I/usr/share/R/include  -fpic  -g -O2 -c colorspace.c -o
colorspace.o
In file included from colorspace.c:1:
/usr/share/R/include/R.h:28:20: error: stdlib.h: No such file or directory
/usr/share/R/include/R.h:29:19: error: stdio.h: No such file or directory
In file included from
/usr/lib/gcc/i486-linux-gnu/4.1.2/include/syslimits.h:7,
 from /usr/lib/gcc/i486-linux-gnu/4.1.2/include/limits.h:11,
 from /usr/share/R/include/R.h:30,
 from colorspace.c:1:
/usr/lib/gcc/i486-linux-gnu/4.1.2/include/limits.h:122:61: error: limits.h:
No such file or directory
In file included from colorspace.c:1:
/usr/share/R/include/R.h:32:18: error: math.h: No such file or directory
/usr/share/R/include/R.h:33:19: error: errno.h: No such file or directory
In file included from /usr/share/R/include/R.h:50,
 from colorspace.c:1:
/usr/share/R/include/R_ext/RS.h:24:39: error: string.h: No such file or
directory
In file included from colorspace.c:2:
/usr/share/R/include/Rinternals.h:770: error: expected declaration
specifiers or ‘...’ before ‘FILE’
/usr/share/R/include/Rinternals.h:773: error: expected declaration
specifiers or ‘...’ before ‘FILE’
colorspace.c: In function ‘gtrans’:
colorspace.c:28: warning: implicit declaration of function ‘pow’
colorspace.c:28: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c: In function ‘ftrans’:
colorspace.c:36: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c: In function ‘g’:
colorspace.c:92: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c: In function ‘LAB_to_XYZ’:
colorspace.c:106: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c:114: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c:117: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c:123: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c: In function ‘f’:
colorspace.c:132: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c: In function ‘XYZ_to_LAB’:
colorspace.c:144: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c: In function ‘XYZ_to_HLAB’:
colorspace.c:170: warning: implicit declaration of function ‘sqrt’
colorspace.c:170: warning: incompatible implicit declaration of built-in
function ‘sqrt’
colorspace.c: In function ‘LAB_to_polarLAB’:
colorspace.c:203: warning: implicit declaration of function ‘atan2’
colorspace.c:203: warning: incompatible implicit declaration of built-in
function ‘atan2’
colorspace.c:207: warning: incompatible implicit declaration of built-in
function ‘sqrt’
colorspace.c: In function ‘polarLAB_to_LAB’:
colorspace.c:216: warning: implicit declaration of function ‘cos’
colorspace.c:216: warning: incompatible implicit declaration of built-in
function ‘cos’
colorspace.c:217: warning: implicit declaration of function ‘sin’
colorspace.c:217: warning: incompatible implicit declaration of built-in
function ‘sin’
colorspace.c: In function ‘HSV_to_RGB’:
colorspace.c:272: warning: implicit declaration of function ‘floor’
colorspace.c:272: warning: incompatible implicit declaration of built-in
function ‘floor’
colorspace.c: In function ‘XYZ_to_LUV’:
colorspace.c:311: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c: In function ‘LUV_to_XYZ’:
colorspace.c:325: warning: incompatible implicit declaration of built-in
function ‘pow’
colorspace.c: In function ‘LUV_to_polarLUV’:
colorspace.c:342: warning: incompatible implicit declaration of built-in
function ‘sqrt’
colorspace.c:343: warning: incompatible implicit declaration of built-in
function ‘atan2’
colorspace.c: In function ‘polarLUV_to_LUV’:
colorspace.c:354: warning: incompatible implicit declaration of built-in
function ‘cos’
colorspace.c:355: warning: incompatible implicit declaration of built-in
function ‘sin’
colorspace.c: In function ‘CheckSpace’:
colorspace.c:373: warning: implicit declaration of function ‘strcmp’
colorspace.c: In function ‘CheckHex’:
colorspace.c:407: warning: implicit declaration of function ‘strlen’
colorspace.c:407: warning: incompatible implicit declaration of built-in
function ‘strlen’
colorspace.c:411: warning: 

[R] Sweave / Latex per-chapter output

2008-05-21 Thread Anne-Marie Ternes
Dear R-help,

I am using Sweave and pdflatex to generate a large report from data
contained in my database (Postgres via RODBC). Currently, I work with
a single R/Sweave file, containing several "chapter" indications for
the Latex engine. My master tex file sets the document class, and
includes the introduction, the main Sweave file, and a conclusions and
reference file. I use a makefile to produce the final PDF (based on
the thread "Sweave, R and complex latex projects:
http://tolstoy.newcastle.edu.au/R/e2/help/06/11/4891.html)

What I would like to do, is to be able to get 2 types of output with
the same code (I'm lazy ;-) ):
1. my large report in a single PDF file, for printing out and distributing
2. a PDF and HTML file *per chapter*, for displaying on our website
and allowing people to download individual chapters

I have tried the following things:
- see if pdflatex has an option to split PDF output per chapter; as
far as I see, it doesn't
- separate the Sweave file into chapter parts. The problems here are
1) that I do a certain number of R preparations (variables setting,
table querying) which are data that I will need in later parts of the
code, 2) that I would need to embed the generated tex files with
per-chapter master tex files setting the documentclass and other
options and including the chapter; I also tried to see if it was
possible to tell pdflatex to assume documentclass X even if it wasn't
specified in the file, but that doesn't seem to work either
- generate my large PDF report as usual and manually cut it into
chapters (tedious)
- use R via PHP to output per-chapter HTMLs which I could turn into
PDFs using output buffering; this works for the graphics, but I'm
unable to get back e.g. tabular data for proper display; also I would
loose the latex-y beauty of my PDF

As I'm a novice in Latex and Makefiles usage, I'd be glad if you could
tell me if what I want to do is feasible (I'm sure it is), and which
would be the best, fussless method to do it (i.e. generate both types
of output without changing the R/Sweave code).

I know you'll probably tell me to break my long Sweave code into
smaller parts, but as I briefly said above, I do some variable setting
and table querying at the start - things I will repeatedly need in
later chapters (e.g. I query a population table for computing
incidence rates several times in later chapters). If there is a better
way to split the code without having to requery the database at each
chapter, I'll be glad to know about that too!

BTW, I'm working on Ubuntu Linux.

Thanks a lot for your insight,

Anne-Marie

__
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 Duncan Murdoch

On 21/05/2008 5:40 AM, Anne-Marie Ternes wrote:

Dear R-help,

I am using Sweave and pdflatex to generate a large report from data
contained in my database (Postgres via RODBC). Currently, I work with
a single R/Sweave file, containing several "chapter" indications for
the Latex engine. My master tex file sets the document class, and
includes the introduction, the main Sweave file, and a conclusions and
reference file. I use a makefile to produce the final PDF (based on
the thread "Sweave, R and complex latex projects:
http://tolstoy.newcastle.edu.au/R/e2/help/06/11/4891.html)

What I would like to do, is to be able to get 2 types of output with
the same code (I'm lazy ;-) ):
1. my large report in a single PDF file, for printing out and distributing
2. a PDF and HTML file *per chapter*, for displaying on our website
and allowing people to download individual chapters

I have tried the following things:
- see if pdflatex has an option to split PDF output per chapter; as
far as I see, it doesn't
- separate the Sweave file into chapter parts. The problems here are
1) that I do a certain number of R preparations (variables setting,
table querying) which are data that I will need in later parts of the
code, 2) that I would need to embed the generated tex files with
per-chapter master tex files setting the documentclass and other
options and including the chapter; I also tried to see if it was
possible to tell pdflatex to assume documentclass X even if it wasn't
specified in the file, but that doesn't seem to work either
- generate my large PDF report as usual and manually cut it into
chapters (tedious)
- use R via PHP to output per-chapter HTMLs which I could turn into
PDFs using output buffering; this works for the graphics, but I'm
unable to get back e.g. tabular data for proper display; also I would
loose the latex-y beauty of my PDF

As I'm a novice in Latex and Makefiles usage, I'd be glad if you could
tell me if what I want to do is feasible (I'm sure it is), and which
would be the best, fussless method to do it (i.e. generate both types
of output without changing the R/Sweave code).


I think you will need to make some changes, including splitting your 
source into one main file and one file per chapter.  In your main file, 
use \include{foo} to include the chapter foo.  If you want the full 
document, do nothing else.  If you want to generate *only* that one 
chapter, then before any of the \include lines, use


\includeonly{foo}

Sweave will completely ignore these lines, but you can set up your 
makefile to only run Sweave when the Sweave source has changed, then run 
pdflatex once on the main file at the end.



I know you'll probably tell me to break my long Sweave code into
smaller parts, but as I briefly said above, I do some variable setting
and table querying at the start - things I will repeatedly need in
later chapters (e.g. I query a population table for computing
incidence rates several times in later chapters). If there is a better
way to split the code without having to requery the database at each
chapter, I'll be glad to know about that too!


If you want to avoid repeating some computations, then save them into a 
.Rdata file, and load that at the beginning of each chapter.  I normally 
keep code to do this in the main Sweave source, but mark it as 
eval=FALSE after the first time through.  It shouldn't print anything 
that you want in the final document, because the eval=FALSE marking will 
stop those print statements from running.  Put them into a separate code 
chunk that you run after loading.


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] 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] xlab at top in xyplot()

2008-05-21 Thread Michael Kubovy
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')

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

(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.
_
Professor Michael Kubovy
University of Virginia
Department of Psychology
USPS: P.O.Box 400400Charlottesville, VA 22904-4400
Parcels:Room 102Gilmer Hall
 McCormick RoadCharlottesville, VA 22903
Office:B011+1-434-982-4729
Lab:B019+1-434-982-4751
Fax:+1-434-982-4766
WWW:http://www.people.virginia.edu/~mk9y/





[[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] 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: 
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] Nonlinear regression

2008-05-21 Thread Mike Prager
[EMAIL PROTECTED] wrote:

> Could someone help me on the following:
> SAS has DUD (Does not Use Derivatives) for nonlinear regression.
> 
> Does "R" has a similar capability?
> 

nls()

-- 
Mike Prager, NOAA, Beaufort, NC
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

__
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.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.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:

<>=
.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] problems with data frames, factors and lists

2008-05-21 Thread jim holtman
Try this:

doset <- function(sameset) {
do.call(rbind, lapply(unique(c(sameset$APID, sameset$BPID)),
function(.pid) mix(sameset, .pid)))
}

On Wed, May 21, 2008 at 11:33 AM, Karin Lagesen <[EMAIL PROTECTED]>
wrote:

>
> 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.
>



-- 
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] 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.


[R] how to do pairwise sums in a matrix

2008-05-21 Thread Gregory Gentlemen
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.


Re: [R] how to do pairwise sums in a matrix

2008-05-21 Thread Jorge Ivan Velez
Hi Gregory,
Try this:

cs=substr(colnames(Mat),1,1)
res=t(apply(t(Mat),2,tapply,cs,sum,na.rm=TRUE))
dim(res)
[1] 50  5

HTH,

Jorge


On Wed, May 21, 2008 at 1: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.
>

[[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] 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] Cumulative average

2008-05-21 Thread Jacques Wagnor
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.


Re: [R] Cumulative average

2008-05-21 Thread jim holtman
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.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.


[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 ->  -> 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.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 ->  -> 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 ->  -> 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] Sweave / Latex per-chapter output

2008-05-21 Thread Mark Wardle
Hi.

Either split the resulting PDF (either interactively in your PDF
reader or using something like pdftk) or do what I have done for my
thesis: Have separate Rnw files for each chapter, use a Makefile to
generate the tex files, and then have a master latex document for the
main project that uses \include to include the relevant chapters.  See
my Makefile below. This is based on the one discussed in that previous
thread.

I also generate standalone "chapters" (which end up as papers).  A
simple way to do this (if no changes are necessary), is to create
separate "master" latex files which only import that single "chapter".
For me, a thesis chapter always needs a lot of cutting to create a
paper, so I use subversion to create a "branch" and then can merge
changes back and forth as necessary.

Factor out common functionality into an .R file and import that code
(and run it) from within your first <> block. This does mean the
same stuff is computed multiple times, but you could choose to cache
data on a first run if it is a problem. I don't - the common stuff
(like database queries and fixing the data) are quick to perform.

Best wishes,

Mark


My makefile:

#
# Makefile
#
# $Id: Makefile 1042 2008-05-03 16:27:16Z mark $
#
# Global project Makefile
#
#
# This makefile was based on
# 
http://209.85.135.104/search?q=cache:-fU4UEn36AgJ:kriemhild.uft.uni-bremen.de/viewcvs/Makefile.rnoweb+makefile+sweave+latex&hl=en&ct=clnk&cd=10&client=safari
# (The original site found on Google is no longer available and I
couldn't track a new version)
# This is credited to Johannes Ranke, based on work by Nicholas
Lewin-Koh and Rouben Rostmaian
# Further advice was provided by Deepayan Sarkar via the R-help mailing list.
#


# The master LaTeX document is thesis.tex, and \include{}'s the
required chapters
# Other master documents are acnr_master.tex (which includes
acnr_paper.tex), genetic_master and drpla_master
# This approach ensures integrity of the Sweave files for papers
MASTER = thesis.pdf acnr_master.pdf genetic_master.pdf
genetic_suppl.pdf drpla_master.pdf icars_master.pdf
clinical_master.pdf

# the master document depends on all of the tex files
RNWFILES = $(wildcard *.Rnw)
TEXFILES = $(wildcard *.tex)
DEPENDS = $(patsubst %.Rnw,%.tex,$(RNWFILES)) $(TEXFILES) $(RFILES)


RERUN = "(There were undefined references|Rerun to get
(citations|cross-references|the bars) (correct|right)|Table widths
have changed. Rerun LaTeX.|Linenumber reference failed)"
RERUNBIB = "No file.*\.bbl|Citation.*undefined"

all: $(MASTER)

$(MASTER): $(DEPENDS)

%.tex: %.Rnw ataxia.R
R CMD SWEAVE '$<'

%.pdf: %.tex
@pdflatex $<
@makeindex -s $*.ist -t $*.alg -o $*.acr $*.acn
@egrep -c $(RERUNBIB) $*.log && (bibtex $*;pdflatex $<); true
@egrep $(RERUN) $*.log && (pdflatex $<) ; true
@egrep $(RERUN) $*.log && (pdflatex $<) ; true

%.txt: %.pdf
@pdftotext -nopgbrk $<

clean:
@rm -f *.aux *.log *.bbl *.blg *.brf *.cb *.ind *.idx *.ilg  \
  *.inx *.ps *.dvi *.toc *.out *.lot *~ *.lof *.alg *.acn
*.acr *.glo *.ist *.ttt *.fff \
  *.eps *.pdf *.svn *.dot *.lol
@rm -f $(patsubst %.Rnw,%.tex,$(RNWFILES))




2008/5/21 Anne-Marie Ternes <[EMAIL PROTECTED]>:
> Dear R-help,
>
> I am using Sweave and pdflatex to generate a large report from data
> contained in my database (Postgres via RODBC). Currently, I work with
> a single R/Sweave file, containing several "chapter" indications for
> the Latex engine. My master tex file sets the document class, and
> includes the introduction, the main Sweave file, and a conclusions and
> reference file. I use a makefile to produce the final PDF (based on
> the thread "Sweave, R and complex latex projects:
> http://tolstoy.newcastle.edu.au/R/e2/help/06/11/4891.html)
>
> What I would like to do, is to be able to get 2 types of output with
> the same code (I'm lazy ;-) ):
> 1. my large report in a single PDF file, for printing out and distributing
> 2. a PDF and HTML file *per chapter*, for displaying on our website
> and allowing people to download individual chapters
>
> I have tried the following things:
> - see if pdflatex has an option to split PDF output per chapter; as
> far as I see, it doesn't
> - separate the Sweave file into chapter parts. The problems here are
> 1) that I do a certain number of R preparations (variables setting,
> table querying) which are data that I will need in later parts of the
> code, 2) that I would need to embed the generated tex files with
> per-chapter master tex files setting the documentclass and other
> options and including the chapter; I also tried to see if it was
> possible to tell pdflatex to assume documentclass X even if it wasn't
> specified in the file, but that doesn't seem to work either
> - generate my large PDF report as usual and manually cut it into
> chapters (tedious)
> - use R via PHP to output per-chapter HTMLs which I could turn into
> PDFs using output buffering; this works f