Re: [R] MDS in 3D

2007-01-08 Thread Atte Tenkanen
Oh, it was nearer than I have thought! Thanks.

Atte

 
  I have tried to develop multidimensional scaling for 3D space 
 using PCA 
  without success, yet;-) Is there some application ready in R?
 
 Yes.
 
 stats has cmdscale. MASS has sammon and isoMDS.  All three have a 'k'
 argument to determine the output dimension.
 
 
 -- 
 Brian D. Ripley,  [EMAIL PROTECTED]
 Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
 University of Oxford, Tel:  +44 1865 272861 (self)
 1 South Parks Road, +44 1865 272866 (PA)
 Oxford OX1 3TG, UKFax:  +44 1865 272595


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


Re: [R] ifelse on data frames

2007-01-08 Thread Henric Nilsson
[EMAIL PROTECTED] said the following on 2007-01-05 04:18:

 [Using R 2.2.0 on Windows XP; OK, OK, I will update soon!]
 
 I have noticed some undesirable behaviour when applying
 ifelse to a data frame. Here is my code:
 
 A - scan()
  1.00 0.00 0.00  0 0.0
  0.027702 0.972045 0.000253  0 0.0
 
 A - matrix(A,nrow=2,ncol=5,byrow=T)
 A == 0
 ifelse(A==0,0,-A*log(A))
 
 A - as.data.frame(A)
 ifelse(A==0,0,-A*log(A))

How about using

sapply(A, function(x) ifelse(x == 0, 0, -x*log(x)))

?


HTH,
Henric



 
 and this is the output:
 
 A - scan()
 1:  1.00 0.00 0.00  0 0.0
 6:  0.027702 0.972045 0.000253  0 0.0
 11:
 Read 10 items
 A - matrix(A,nrow=2,ncol=5,byrow=T)
 A == 0
   [,1]  [,2]  [,3] [,4] [,5]
 [1,] FALSE  TRUE  TRUE TRUE TRUE
 [2,] FALSE FALSE FALSE TRUE TRUE
 ifelse(A==0,0,-A*log(A))
[,1]   [,2][,3] [,4] [,5]
 [1,] 0. 0. 0.000
 [2,] 0.09934632 0.02756057 0.00209537700
 A - as.data.frame(A)
 ifelse(A==0,0,-A*log(A))
 [[1]]
 [1] 0. 0.09934632
 
 [[2]]
 [1]NaN 0.02756057
 
 [[3]]
 [1] 0
 
 [[4]]
 [1] NaN NaN
 
 [[5]]
 [1] 0
 
 [[6]]
 [1] 0. 0.09934632
 
 [[7]]
 [1] 0
 
 [[8]]
 [1] 0
 
 [[9]]
 [1] 0
 
 [[10]]
 [1] 0
 
 
 Is this a bug or a feature? Can the behaviour be explained?
 
 Regards,  Murray Jorgensen

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


[R] Scripts to plot Taylor Diagram in R

2007-01-08 Thread Linda Smith
Dear All,

Are there any existing scripts to plot Taylor Diagram (definition see
http://www.ipsl.jussieu.fr/~jmesce/Taylor_diagram/taylor_diagram_definition.html)
? Thanks a lot!

Linda

[[alternative HTML version deleted]]

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


[R] Plot .jpeg image in margins?

2007-01-08 Thread Kari
Is it possible to plot an image (currently a jpeg) in the margins?


Thanks,
Kari

[[alternative HTML version deleted]]

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


[R] Contrasts for ordered factors

2007-01-08 Thread lorenz.gygax
Dear all,

I do not seem to grasp how contrasts are set for ordered factors. Perhaps 
someone can elighten me?

When I work with ordered factors, I would often like to be able to reduce the 
used polynomial to a simpler one (where possible). Thus, I would like to 
explicetly code the polynomial but ideally, the intial model (thus, the full 
polynomial) would be identical to one with an ordered factor.

Here is a toy example with an explanatory variable (EV) with three distinct 
values (1 to 3) and a continuous response variable (RV):

options (contrasts= c ('contr.treatment', 'contr.poly'))
example.df - data.frame (EV= rep (1:3, 5))
set.seed (298)
example.df$RV - 2 * example.df$EV + rnorm (15)

I evaluate this data using either an ordered factor or a polynomial with a 
linear and a quadratic term:

lm.ord - lm (RV ~ ordered (EV), example.df)
lm.pol - lm (RV ~ EV + I(EV^2), example.df)

I then see that the estimated coefficients differ (and in other examples that I 
have come across, it is often even more extreme):

coef (lm.ord)
(Intercept) ordered(EV).L ordered(EV).Q 
  3.9497767 2.9740535-0.1580798 
coef (lm.pol)
(Intercept)EV   I(EV^2) 
 -0.9015283 2.8774032-0.1936074 

but the predictions are the same (except for some rounding):

table (round (predict (lm.ord), 6) == round (predict (lm.pol), 6))
TRUE 
  15 

I thus conclude that the two models are the same and are just using a different 
parametrisation. I can easily interprete the parameters of the explicit 
polynomial but I started to wonder about the parametrisation of the ordered 
factor. In search of an answer, I did check the contrasts:

contr.poly (levels (ordered (example.df$EV)))
.L .Q
[1,] -7.071068e-01  0.4082483
[2,] -9.073264e-17 -0.8164966
[3,]  7.071068e-01  0.4082483

The linear part basically seems to be -0.707, 0 (apart for numerical rounding) 
and 0.707. I can understand that any even-spaced parametrisation is possible 
for the linear part. But does someone know where the value of 0.707 comes from 
(it seems to be the square-root of 0.5, but why?) and why the middle term is 
not exactly 0?

I do not understand the quadratic part at all. Wouldn't that need the be the 
linear part to the power of 2?

Thank you for your thoughts! Lorenz
- 
Lorenz Gygax
Swiss Federal Veterinary Office
Centre for proper housing of ruminants and pigs
Tänikon, CH-8356 Ettenhausen / Switzerland

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


[R] tapply, how to get level information

2007-01-08 Thread Antje

Hello,

I'm applying a self-written function to a matrix on basis of different 
levels.
Is there any way, to get the level information within the self-written 
function???

t - tapply(mat, levels, plotDensity)

plotDensity - function(x) {
??? print(level(x)) ???
}

Antje

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


[R] Speeding things up

2007-01-08 Thread Benjamin Dickgiesser
Hi,

is it possible to do this operation faster? I am going over 35k data
entries and this takes quite some time.

for(cnt in 2:length(sdata$date))
{

if(sdata$value[cnt]  sdata$value[cnt - 1]) {
sdata$ddtd[cnt] - sdata$ddtd[cnt - 1] + 
sdata$value[cnt - 1] -
sdata$value[cnt]
}
else sdata$ddtd[cnt] - 0

}
return(sdata)

Thank you,
Benjamin

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


Re: [R] Contrasts for ordered factors

2007-01-08 Thread Professor Brian Ripley
contr.poly is using orthoogonal polynomials: look at poly() for
further information.  It seems to me that you did not realize that,
or did not realize what they are, or ... and that may be enough of
a hint for you or you may need more help, in which case please ask
again.

[EMAIL PROTECTED] wrote:
 Dear all,
 
 I do not seem to grasp how contrasts are set for ordered factors. Perhaps 
 someone can elighten me?
 
 When I work with ordered factors, I would often like to be able to reduce the 
 used polynomial to a simpler one (where possible). Thus, I would like to 
 explicetly code the polynomial but ideally, the intial model (thus, the full 
 polynomial) would be identical to one with an ordered factor.
 
 Here is a toy example with an explanatory variable (EV) with three distinct 
 values (1 to 3) and a continuous response variable (RV):
 
 options (contrasts= c ('contr.treatment', 'contr.poly'))
 example.df - data.frame (EV= rep (1:3, 5))
 set.seed (298)
 example.df$RV - 2 * example.df$EV + rnorm (15)
 
 I evaluate this data using either an ordered factor or a polynomial with a 
 linear and a quadratic term:
 
 lm.ord - lm (RV ~ ordered (EV), example.df)
 lm.pol - lm (RV ~ EV + I(EV^2), example.df)
 
 I then see that the estimated coefficients differ (and in other examples that 
 I have come across, it is often even more extreme):
 
 coef (lm.ord)
 (Intercept) ordered(EV).L ordered(EV).Q 
   3.9497767 2.9740535-0.1580798 
 coef (lm.pol)
 (Intercept)EV   I(EV^2) 
  -0.9015283 2.8774032-0.1936074 
 
 but the predictions are the same (except for some rounding):
 
 table (round (predict (lm.ord), 6) == round (predict (lm.pol), 6))
 TRUE 
   15 
 
 I thus conclude that the two models are the same and are just using a 
 different parametrisation. I can easily interprete the parameters of the 
 explicit polynomial but I started to wonder about the parametrisation of the 
 ordered factor. In search of an answer, I did check the contrasts:
 
 contr.poly (levels (ordered (example.df$EV)))
 .L .Q
 [1,] -7.071068e-01  0.4082483
 [2,] -9.073264e-17 -0.8164966
 [3,]  7.071068e-01  0.4082483
 
 The linear part basically seems to be -0.707, 0 (apart for numerical 
 rounding) and 0.707. I can understand that any even-spaced parametrisation is 
 possible for the linear part. But does someone know where the value of 0.707 
 comes from (it seems to be the square-root of 0.5, but why?) and why the 
 middle term is not exactly 0?
 
 I do not understand the quadratic part at all. Wouldn't that need the be the 
 linear part to the power of 2?
 
 Thank you for your thoughts! Lorenz
 - 
 Lorenz Gygax
 Swiss Federal Veterinary Office
 Centre for proper housing of ruminants and pigs
 Tänikon, CH-8356 Ettenhausen / Switzerland
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.

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


Re: [R] Contrasts for ordered factors

2007-01-08 Thread Peter Dalgaard
[EMAIL PROTECTED] wrote:
 Dear all,

 I do not seem to grasp how contrasts are set for ordered factors. Perhaps 
 someone can elighten me?

 When I work with ordered factors, I would often like to be able to reduce the 
 used polynomial to a simpler one (where possible). Thus, I would like to 
 explicetly code the polynomial but ideally, the intial model (thus, the full 
 polynomial) would be identical to one with an ordered factor.

 Here is a toy example with an explanatory variable (EV) with three distinct 
 values (1 to 3) and a continuous response variable (RV):

 options (contrasts= c ('contr.treatment', 'contr.poly'))
 example.df - data.frame (EV= rep (1:3, 5))
 set.seed (298)
 example.df$RV - 2 * example.df$EV + rnorm (15)

 I evaluate this data using either an ordered factor or a polynomial with a 
 linear and a quadratic term:

 lm.ord - lm (RV ~ ordered (EV), example.df)
 lm.pol - lm (RV ~ EV + I(EV^2), example.df)

 I then see that the estimated coefficients differ (and in other examples that 
 I have come across, it is often even more extreme):

 coef (lm.ord)
 (Intercept) ordered(EV).L ordered(EV).Q 
   3.9497767 2.9740535-0.1580798 
 coef (lm.pol)
 (Intercept)EV   I(EV^2) 
  -0.9015283 2.8774032-0.1936074 

 but the predictions are the same (except for some rounding):

 table (round (predict (lm.ord), 6) == round (predict (lm.pol), 6))
 TRUE 
   15 

 I thus conclude that the two models are the same and are just using a 
 different parametrisation. I can easily interprete the parameters of the 
 explicit polynomial but I started to wonder about the parametrisation of the 
 ordered factor. In search of an answer, I did check the contrasts:

 contr.poly (levels (ordered (example.df$EV)))
 .L .Q
 [1,] -7.071068e-01  0.4082483
 [2,] -9.073264e-17 -0.8164966
 [3,]  7.071068e-01  0.4082483

 The linear part basically seems to be -0.707, 0 (apart for numerical 
 rounding) and 0.707. I can understand that any even-spaced parametrisation is 
 possible for the linear part. But does someone know where the value of 0.707 
 comes from (it seems to be the square-root of 0.5, but why?) and why the 
 middle term is not exactly 0?

 I do not understand the quadratic part at all. Wouldn't that need the be the 
 linear part to the power of 2?

   
These are orthogonal polynomials. 

To see the main point, try

 M - cbind(1,contr.poly (3))

 M

  .L .Q

[1,] 1 -7.071068e-01  0.4082483

[2,] 1 -7.850462e-17 -0.8164966

[3,] 1  7.071068e-01  0.4082483

 zapsmall(crossprod(M))

 .L .Q

   3  0  0

.L 0  1  0

.Q 0  0  1


This parametrization has better numerical properties than the
straightforward 1,x,x^2,... , especially in balanced designs.

(SOAPBOX: Some, including me, feel that  having polynomials as default
contrasts for ordered factors is a bit of a design misfeature - It was
inherited from S, but assigning equidistant numerical values to ordered
groups isn't really well-founded, and does become plainly wrong when the
levels are really something like 0, 3, 6, 12, 18, 24 months.)
 

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


Re: [R] different points and lines on the same plot

2007-01-08 Thread Petr Pikal
Hi

On 7 Jan 2007 at 9:32, Gabor Grothendieck wrote:

Date sent:  Sun, 7 Jan 2007 09:32:54 -0500
From:   Gabor Grothendieck [EMAIL PROTECTED]
To: [EMAIL PROTECTED] [EMAIL PROTECTED]
Copies to:  r-help@stat.math.ethz.ch
Subject:Re: [R] different points and lines on the same plot

 Try this:
 
 matplot(patient[,1], patient[,-1], type = o)

Another option is to use plot and lines.

first initialise plotting region without any actual plotting

 plot(patient[,1], patient[,2], type=n, ylim=range(patient[,-1]))

then add lines in a cycle

 for(i in 1:4) lines(patient[,1], patient[,i+1], col=i, lwd=2, 
lty=i)

HTH
Petr



 
 
 On 1/7/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
  Dear all,
 
  I have following data called paitent
 
  daypatient1patient4patient5patient6
  0   -0.27842688 -0.04080808 -0.41948398 -0.04508318
  56  -0.22275425 -0.01767067 -0.30977249 -0.03168185
  112 -0.08217659 -0.26209243 -0.29141451 -0.09876170
  252  0.08044537 -0.26701769  0.05727087 -0.09663701
 
  where each patient have response values at four time
  points. I want to plot each patient's values over time
  on the same plot where the value points are connected
  by line. That is, the graph will have four lines for
  the four patients. I tried the program below but
  couldn't make it work correctly. I'm new beginner and
  haven't yet learned how functions line and points work
  together. Hope you can help me out.
 
  Thanks for your help,
 
  Antonia
 
  par(mfrow=c(1,1))
 plot(patient[,1],patient[,2], pch=1,
  type=l,col=1,cex=1,lwd=2,
  xlab=Days, ylab=Patient
  response,cex.main =1,font.main= 1,
  main=NULL)
 
 
  points(patient[,1],patient[,3],col=2,pch=1,cex=1)
  lines(patient[,1],patient[,3],col=2,lty=1,cex=1)
 
  points(patient[,1],patient[,4],col=3,pch=1,cex=1)
  lines(patient[,1],patient[,4],col=2,lty=2,cex=1)
 
  points(patient[,1],patient[,5],col=4,pch=1,cex=1)
  lines(patient[,1],patient[,5],col=2,lty=1,cex=1)
   points(patient[,1],patient[,6],col=5,pch=1,cex=1)
   lines(patient[,1],patient[,6],col=2,lty=1,cex=1)
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
  http://www.R-project.org/posting-guide.html and provide commented,
  minimal, self-contained, reproducible code.
 
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.

Petr Pikal
[EMAIL PROTECTED]

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


[R] ACCESS/Office : connecting

2007-01-08 Thread Milton Cezar Ribeiro
Hi there, 
   
  How can I connect to a ACCESS (.mdb) file? In fact, I would like to connect 
to a blank file, write a data.frame as table and after that INSERT records 
using some insert command.
   
  Kind regards,
   
  Miltinho
  Brazil

 __


[[alternative HTML version deleted]]

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


[R] scripts with littler

2007-01-08 Thread John Lawrence Aspden
Hi,

I'm trying to write R scripts using littler (under Debian), and was
originally using the shebang line:

#!/usr/bin/env r

However this picks up any .RData file that happens to be lying around, which
I find a little disturbing, because it means that the script may not behave
the same way on successive invocations.

If you drop the /usr/bin/env trick then 

#!/usr/bin/r --vanilla

seems to work, but it also prevents the loading of the libraries in my home
directory, some of which I'd like to use.

#!/usr/bin/r --no-restore

doesn't work at all.

Ideally I'd like #!/usr/bin/env r --no-restore

Has anyone else been round this loop and can offer advice?

Cheers, John.

-- 
Contractor in Cambridge UK -- http://www.aspden.com

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


[R] Export dataframe to txt

2007-01-08 Thread Benjamin Dickgiesser
Hi all,

Is there a function to export a dataframe to a text file?
I want to store a large set of data which I have saved in a dataframe
in my workspace and copy and past doesn't cut it.

Thank you,
Benjamin

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


Re: [R] Speeding things up

2007-01-08 Thread Henrik Bengtsson
First, since you only update the 'ddtd' conditioned on 'value', you
should be able to vectorize removing the loop.  I let you figure out
how to do that yourself.

Second, you apply the $ operator multiple times in the loop that
will definitely add some overhead.  It should be faster to extract
'value' and 'ddtd' and work with those instead.

/Henrik

On 1/8/07, Benjamin Dickgiesser [EMAIL PROTECTED] wrote:
 Hi,

 is it possible to do this operation faster? I am going over 35k data
 entries and this takes quite some time.

 for(cnt in 2:length(sdata$date))
 {

 if(sdata$value[cnt]  sdata$value[cnt - 1]) {
 sdata$ddtd[cnt] - sdata$ddtd[cnt - 1] + 
 sdata$value[cnt - 1] -
 sdata$value[cnt]
 }
 else sdata$ddtd[cnt] - 0

 }
 return(sdata)

 Thank you,
 Benjamin

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


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


[R] outsourcing R work

2007-01-08 Thread damjan . krstajic
Dear Colleagues,

If you have a need to outsource any coding in R please check the web site
of the Research Centre for Cheminformatics in Belgrade, Serbia
http://www.rcc.org.yu . We have skilled statisticians experienced in R,
fluent in English and with work experience in the West.

For more information please check our website
http://www.rcc.org.yu/outsourcing.htm or contact me.

Kind regards,
DK
-
Damjan Krstajic
Director
Research Centre for Cheminformatics
e-mail: [EMAIL PROTECTED]
www.rcc.org.yu

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


Re: [R] Speeding things up

2007-01-08 Thread Benjamin Dickgiesser
Thanks for your answers, your help is highly appreciated!

On 1/8/07, Zoltan Kmetty [EMAIL PROTECTED] wrote:
 Hi Benjamin!


 ##TRY THIS: THIS MAYBE MUCH FASTER, BECAUSE ONLY WORK WITH THE IMPORTANAT
 ROWS - HOPE NO ERROR IN IT:D

 puffer1 - as.matrix(sdata$value)
 puffer2 - rbind(as.matrix(puffer1[2:nrow(puffer1),1]),0)

 speedy - puffer1  puffer2
 speedy - (as.matrix(which(puffer1==TRUE)))+1
 sdata$ddtd[]=0

 for(cnt in 1:nrow(speedy))
{

 sdata$ddtd[speedy[cnt,1]] - sdata$ddtd[(speedy[cnt,1]) - 1] +
 sdata$value[(speedy[cnt,1]) - 1] -sdata$value[speedy[cnt,1]]
}
return(sdata)




 #Zoltan



 2007/1/8, Benjamin Dickgiesser [EMAIL PROTECTED]:
 
  Hi,
 
  is it possible to do this operation faster? I am going over 35k data
  entries and this takes quite some time.
 
 for(cnt in 2:length(sdata$date))
 {
 
 if(sdata$value[cnt]  sdata$value[cnt - 1]) {
 sdata$ddtd[cnt] - sdata$ddtd[cnt - 1] +
 sdata$value[cnt - 1] -
  sdata$value[cnt]
 }
 else sdata$ddtd[cnt] - 0
 
 }
 return(sdata)
 
  Thank you,
  Benjamin
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 



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


Re: [R] Speeding things up

2007-01-08 Thread Zoltan Kmetty
Hi Benjamin!


##TRY THIS: THIS MAYBE MUCH FASTER, BECAUSE ONLY WORK WITH THE IMPORTANAT
ROWS - HOPE NO ERROR IN IT:D

puffer1 - as.matrix(sdata$value)
puffer2 - rbind(as.matrix(puffer1[2:nrow(puffer1),1]),0)

speedy - puffer1  puffer2
speedy - (as.matrix(which(puffer1==TRUE)))+1
sdata$ddtd[]=0

for(cnt in 1:nrow(speedy))
   {

sdata$ddtd[speedy[cnt,1]] - sdata$ddtd[(speedy[cnt,1]) - 1] +
sdata$value[(speedy[cnt,1]) - 1] -sdata$value[speedy[cnt,1]]
   }
   return(sdata)



#Zoltan



2007/1/8, Benjamin Dickgiesser [EMAIL PROTECTED]:

 Hi,

 is it possible to do this operation faster? I am going over 35k data
 entries and this takes quite some time.

for(cnt in 2:length(sdata$date))
{

if(sdata$value[cnt]  sdata$value[cnt - 1]) {
sdata$ddtd[cnt] - sdata$ddtd[cnt - 1] +
 sdata$value[cnt - 1] -
 sdata$value[cnt]
}
else sdata$ddtd[cnt] - 0

}
return(sdata)

 Thank you,
 Benjamin

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


[[alternative HTML version deleted]]

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


Re: [R] Export dataframe to txt

2007-01-08 Thread Detlef Steuer
On Mon, 8 Jan 2007 11:17:24 +
Benjamin Dickgiesser [EMAIL PROTECTED] wrote:

 Hi all,
 
 Is there a function to export a dataframe to a text file?
 I want to store a large set of data which I have saved in a dataframe
 in my workspace and copy and past doesn't cut it.

see ?write.table

Hth
Detlef

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

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


Re: [R] Export dataframe to txt

2007-01-08 Thread Henrique Dallazuanna
?write.table

On 08/01/07, Benjamin Dickgiesser [EMAIL PROTECTED] wrote:

 Hi all,

 Is there a function to export a dataframe to a text file?
 I want to store a large set of data which I have saved in a dataframe
 in my workspace and copy and past doesn't cut it.

 Thank you,
 Benjamin

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




-- 
Henrique Dallazuanna

[[alternative HTML version deleted]]

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


[R] scripts with littler / subroutines

2007-01-08 Thread John Lawrence Aspden
Hi (again),

Another difficulty I'm having is creating a common function (foo, say) to
share between two scripts.

I've tried making a third file containing the function and then sourcing it
with source (foo.R), but that only works if you run the script in the
directory where foo.R is. (or if the scripts know where they're
installed)

The other solutions that occur are copy-and-paste, a preprocessor, or some
sort of special-purpose library. I think I like the preprocessor best, but
it's still kind of nasty.

I have the feeling that I'm probably missing something obvious here! Can
anyone help?

Cheers, John.



-- 
Contractor in Cambridge UK -- http://www.aspden.com

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


Re: [R] Export dataframe to txt

2007-01-08 Thread Zoltan Kmetty
#Try:

Write.table(...)

#Zoltan

2007/1/8, Benjamin Dickgiesser [EMAIL PROTECTED]:

 Hi all,

 Is there a function to export a dataframe to a text file?
 I want to store a large set of data which I have saved in a dataframe
 in my workspace and copy and past doesn't cut it.

 Thank you,
 Benjamin

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


[[alternative HTML version deleted]]

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


Re: [R] Export dataframe to txt

2007-01-08 Thread Petr Pikal
Hi
AFAIK 
?sink
?write.table
are possible options.

HTH
Petr



On 8 Jan 2007 at 11:17, Benjamin Dickgiesser wrote:

Date sent:  Mon, 8 Jan 2007 11:17:24 +
From:   Benjamin Dickgiesser [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] Export dataframe to txt

 Hi all,
 
 Is there a function to export a dataframe to a text file?
 I want to store a large set of data which I have saved in a dataframe
 in my workspace and copy and past doesn't cut it.
 
 Thank you,
 Benjamin
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.

Petr Pikal
[EMAIL PROTECTED]

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


Re: [R] Plot .jpeg image in margins?

2007-01-08 Thread Oleg Sklyar
I am not sure what you mean by in margins, if this is keeping the aspect
ration, then the answer is yes. Please check EBImage,
http://www.ebi.ac.uk/~osklyar/EBImage/ . The package will allow to
read/write images in most image formats, the method image() redefined for
the Image class will produce an image plot using R graphics device keeping
the aspect ratio and display() can display images with zoom and browse
functions. Best regards, Oleg

On 08/01/07, Kari [EMAIL PROTECTED] wrote:

 Is it possible to plot an image (currently a jpeg) in the margins?


 Thanks,
 Kari

 [[alternative HTML version deleted]]

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


[[alternative HTML version deleted]]

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


Re: [R] ACCESS/Office : connecting

2007-01-08 Thread RINNER Heinrich
Hi,
you can use the RODBC pakage for that; see:

library(RODBC)
?RODBC
?odbcConnectAccess
?sqlSave

Regards,
Heinrich.

 -Ursprüngliche Nachricht-
 Von: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] Im Auftrag von 
 Milton Cezar Ribeiro
 Gesendet: Montag, 08. Jänner 2007 12:22
 An: R-help
 Betreff: [R] ACCESS/Office : connecting
 
 
 Hi there, 

   How can I connect to a ACCESS (.mdb) file? In fact, I would 
 like to connect to a blank file, write a data.frame as table 
 and after that INSERT records using some insert command.

   Kind regards,

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


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


[R] R Training Course in Paris

2007-01-08 Thread Romain Francois
Mango Solutions are pleased to announce the above course in Paris as
part of our schedule for Q1 2007.

---
Introduction to R and R Programming - 12th February 2008-14th February
---

(Please find a french version of this announcement from
http://www.mango-solutions.com/services/rtraining/r_paris_training_07_french.html)

* Who Should Attend ?

This is a course suitable for beginners and improvers in the R language
and is ideal for people wanting an all round introduction to R

* Course Goals

- To allow attendees to understand the technology behind the R package
- Improve attendees programming style and confidence
- To enable users to access a wide range of available functionality
- To enable attendees to program in R within their own environment
- To understand how to embed R routines within other applications

* Course Outline

1. Introduction to the R language and the R community
2. The R Environment
3. R data objects
4. Using R functions
5. The apply family of functions
6. Writing R functions
7. Standard Graphics
8. Advanced Graphics
9. R Statistics
10. R Applications


The cost of these courses is €1800 for commercial attendees and €850 for
academic attendees. A €100 discount will be offered to members of the R
Foundation (http://www.r-project.org/foundation/main.html).

Should your organization have more than 3 possible attendees why not
talk to us about hosting a customized and focused course delivered at
your premises? Details of further courses in alternative locations are
available at http://www.mango-solutions.com/services/training.html

More details about this course :
- in french :
http://www.mango-solutions.com/services/rtraining/r_paris_training_07_french.html
- in english :
http://www.mango-solutions.com/services/rtraining/r_paris_training_07.html

Should you want to book a place on this course or have any questions
please contact [EMAIL PROTECTED]


Cordialement,

Romain Francois

--
Mango Solutions
Tel +44 (0)1249 467 467
Mob +44 (0)7813 526 123
Fax +44 (0)1249 467 468

data analysis that delivers

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


Re: [R] R Training Course in Paris

2007-01-08 Thread Romain Francois
Romain Francois wrote:
 Mango Solutions are pleased to announce the above course in Paris as
 part of our schedule for Q1 2007.

 ---
 Introduction to R and R Programming - 12th February 2008-14th February
 ---
   
Small typo, the correct date is : 12th February 2007-14th February.

Cheers,

Romain

 (Please find a french version of this announcement from
 http://www.mango-solutions.com/services/rtraining/r_paris_training_07_french.html)

 * Who Should Attend ?

 This is a course suitable for beginners and improvers in the R language
 and is ideal for people wanting an all round introduction to R

 * Course Goals

 - To allow attendees to understand the technology behind the R package
 - Improve attendees programming style and confidence
 - To enable users to access a wide range of available functionality
 - To enable attendees to program in R within their own environment
 - To understand how to embed R routines within other applications

 * Course Outline

 1. Introduction to the R language and the R community
 2. The R Environment
 3. R data objects
 4. Using R functions
 5. The apply family of functions
 6. Writing R functions
 7. Standard Graphics
 8. Advanced Graphics
 9. R Statistics
 10. R Applications


 The cost of these courses is €1800 for commercial attendees and €850 for
 academic attendees. A €100 discount will be offered to members of the R
 Foundation (http://www.r-project.org/foundation/main.html).

 Should your organization have more than 3 possible attendees why not
 talk to us about hosting a customized and focused course delivered at
 your premises? Details of further courses in alternative locations are
 available at http://www.mango-solutions.com/services/training.html

 More details about this course :
 - in french :
 http://www.mango-solutions.com/services/rtraining/r_paris_training_07_french.html
 - in english :
 http://www.mango-solutions.com/services/rtraining/r_paris_training_07.html

 Should you want to book a place on this course or have any questions
 please contact [EMAIL PROTECTED]


 Cordialement,

 Romain Francois
   
-- 
Mango Solutions
Tel  +44 1249 467 467
Fax  +44 1249 467 468
Mob  +44 7813 526 123
data analysis that delivers

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


[R] garchFit in R

2007-01-08 Thread Melina Chen
Dear all,
   
  I have problem here : 
  I'm using garchFit from fSeries package, here is part of the script : 
   data - read.table(d:/data.txt)
   a - garchFit(~garch(1,1),ts(data))
   
  I also attached the file here. In my experience, I got my R not responding.
  I also tried with 
   a - garchFit(~garch(1,1),ts(data*10))
  and it's worked. 
   
  I wonder if something wrong with the first
   
  Thanks 

 __


0.0026668996
-0.0019157865
-0.0001120967
0.0005845345
0.0003697987
-0.0010323306
-0.0023072483
-0.0005885481
0.0012301371
0.0003082133
-0.0002494891
-0.0002006737
-0.0004800350
-0.0002843525
0.0027182299
-0.0004827581
0.0007702074
-0.0018742761
-0.0012589320
-0.0001864557
0.0019782314
0.00
-0.0016593427
0.0014883173
-0.0019642834
-0.0001129345
0.0003289013
0.0047631296
-0.0003933189
-0.777348
-0.0001992589
-0.0019439182
-0.0017467015
-0.0001716240
-0.0003041862
0.0028812028
-0.0006391600
-0.0004934305
0.0002638840
0.0004931309
0.0002341631
-0.0007321793
-0.0021696036
0.0011669581
-0.0003526987
0.0011745500
-0.0001808695
-0.0006997451
0.587632
0.0011198772
0.0017887369
0.0030052082
0.0012059188
0.0031819752
-0.0032446005
0.0009576615
-0.0030971545
-0.0033876838
0.0007118065
-0.0008289275
-0.0001171526
0.0004440365
-0.0016515719
0.0010317472
-0.0002638158
-0.0009735958
0.0011201799
0.0003223110
-0.0026539675
-0.0005848754
0.0010266956
0.0004805825
-0.0005100232
-0.0012333941
-0.0046007250
-0.0037661601
0.0030195219
0.0011691642
-0.0005518513
0.0012071954
-0.0009286963
-0.0013194775
-0.0010534771
-0.0018384612
0.0010729640
-0.0001352279
-0.0041928562
-0.0048981960
0.0035253602
-0.0007769906
-0.0065450379
0.0003404330
0.0018162840
-0.0008223038
-0.0003036179
-0.0016866227
-0.0038151118
0.0006511983
-0.0049316481
-0.0035685861
0.583904
0.0037786345
0.004192
-0.0019298763
-0.0030373119
-0.0006163457
-0.0058485648
0.0076319879
-0.0061118610
0.0014086934
0.0020437674
0.0014607365
0.0013718807
-0.0041446062
0.0010107937
-0.0025287507
0.0035741117
-0.0003428967
0.0004378049
-0.0009605837
-0.0010898236
0.0020398630
0.0009532263
0.0010508613
-0.0006039345
-0.0034717995
0.0027354396
-0.0039024422
-0.0002178340
0.0013848366
0.0018343314
-0.0003219009
-0.0018887114
0.0018939904
0.0007963918
0.0004529223
0.0008571518
0.0044218012
-0.0019126781
0.0045515451
0.0092559993
-0.0009015621
-0.0020175552
0.0002240705
0.0038168506
-0.0035878071
-0.0002901422
-0.0007389559
0.0051061545
-0.0021933090
0.0014213553
-0.0025780541
-0.0004574410
0.0005336344
-0.0004675298
0.0003608554
0.0007360280
-0.0015191088
-0.0021837991
-0.0047678519
-0.0010459318
0.0033618169
-0.0011022447
0.0011588266
0.0001439934
0.0036812865
-0.0010617579
-0.0018386819
0.0006154677
0.0001178651
-0.0006306943
-0.0001283020
-0.0011409873
-0.0003809962
0.0016194965
0.0001436634
0.0009275365
-0.0017079955
0.0017694197
-0.0006351358
0.153772
-0.358809
-0.0024417258
-0.0006706615
0.0004231532
-0.0003250688
0.00
-0.0013493117
-0.0007721806
-0.0004618912
0.0011615764
-0.0002227404
-0.0010842518
0.0013691318
-0.0006736543
-0.0008721193
0.0036790147
0.0002935971
-0.0001545000
-0.0006959312
-0.0006298763
0.0014236639
0.0016909739
0.0015975386
-0.0005625643
0.0039227325
0.0001673279
-0.0031647730
-0.0008280651
0.0013231273
0.0013343643
-0.0028724331
-0.0002304126
0.0014980535
-0.0012062182
-0.0015279076
0.0022489747
0.0025778462
-0.0014449700
-0.0023558165
-0.0009387271
0.0003644465
0.0052782725
-0.0023175981
-0.0001121273
0.0003362951
-0.916910
-0.0014952546
-0.0008391870
0.0016716533
-0.0013695639
0.0004655229
0.0013630021
-0.0025559437
0.922755
0.0014686387
-0.0004293316
0.0004599820
-0.0009204516
-0.0005327070
0.0016216967
-0.0005620481
0.0013425983
-0.0021153235
0.921851
0.0003224940
0.0012161541
-0.0029080728
0.0004518232
-0.0008167053
-0.0008079421
-0.0032780219
-0.0022896000
0.0021286819
-0.0003479945
-0.0004262835
-0.0013439693
-0.0002400599
0.0019219713
0.0008826071
-0.311203
0.0014344017
0.0003049113
-0.0007031687
0.0014052008
-0.0005419102
0.0033541187
-0.0028844242
-0.103175
0.0012312089
0.0003085428
0.0011550870
-0.0003231148
-0.0015316507
-0.0002626703
0.0018456252
-0.0023353370
-0.0004851011
-0.0008528198
0.0003930220
0.0014243068
-0.0028740447
0.0012842983
-0.0001965414
0.0031186304
-0.0001335643
0.513757
0.0002465190
0.0001745330
-0.0007293975
0.0017341634
-0.0003227070
0.0012945009
0.0042097711
-0.0021506299
0.0039128858
-0.0014132766
-0.0012860343
-0.0001825811
0.0042303056
0.0020048020
-0.0016583125
-0.0024867810
-0.0030701626
-0.0010944863
0.0033814397
-0.0011090121
-0.0015187180
0.0023393556
0.0027394008
-0.0004125788
-0.0007557330
-0.0003985487
-0.0019830371
-0.0001369206
0.0018220686
-0.0002980935
-0.0017877958
0.0012264205
0.0014499989
-0.0018550441
0.0022734809
-0.0001663181
0.0010321589
-0.0008708797
-0.0020962515
0.0022171716
0.0017294980
-0.0001254584
-0.0019265679
0.0009970473
-0.0012189246
0.0022237246
0.0062328191

[R] How to use Rattle for Data mining through R?

2007-01-08 Thread Bhanu Kalyan.K
Dear Mr. Bengtsson,

Now i am able to work with R-Matlab interface comfortably. Thanks to you. 
Recently, I came to know that R can be used for data mining as well. I went 
through the following site for this : 

http://rattle.togaware.com/  

As they have suggested, I have also installed the two packages:

 install.packages(RGtk2) 
 install.packages(rattle) 

Now, can you explain how to work on this?
Can this be used to implement the clustering algorithms? If yes, Kindly 
elaborate.




Bhanu Kalyan K
  BTech CSE Final Year
  [EMAIL PROTECTED]
  Tel :+91-9885238228

 __



[[alternative HTML version deleted]]

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


[R] query

2007-01-08 Thread Fluss
Hello!
I found the ccf function gives different estimates than the simple lag 
correlations.
Why is that?
This is my code:

set.seed(20)
x-rnorm(20)
y-x+rnorm(20,sd=0.3)
print(R CCF:)
print(ccf(x,y,lag.max=2,plot=F))
myccf- c( cor(y[-(1:2)],x[-(19:20)]) ,  cor(y[-1],x[-20]),
   cor(y,x),
   cor(x[-1],y[-20]),cor(x[-(1:2)],y[-(19:20)]) )
print(My CCF:)
print(myccf)

Thank You!
Ron

[[alternative HTML version deleted]]

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


Re: [R] scripts with littler

2007-01-08 Thread François Pinard
[John Lawrence Aspden]

I'm trying to write R scripts using littler (under Debian), and was
originally using the shebang line:

#!/usr/bin/env r

However this picks up any .RData file that happens to be lying around, which
I find a little disturbing, because it means that the script may not behave
the same way on successive invocations.

If you drop the /usr/bin/env trick then 

#!/usr/bin/r --vanilla

seems to work, but it also prevents the loading of the libraries in my home
directory, some of which I'd like to use.

#!/usr/bin/r --no-restore

doesn't work at all.

Ideally I'd like #!/usr/bin/env r --no-restore

Has anyone else been round this loop and can offer advice?

I usually do something like:


#!/bin/sh
R --slave --vanilla EOF

   R script goes here...

EOF

# vim: ft=r


If you need to search special places for packages, you may tweak 
exported environment variables between the first and second line.




-- 
François Pinard   http://pinard.progiciels-bpi.ca

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


Re: [R] scripts with littler / subroutines

2007-01-08 Thread François Pinard
[John Lawrence Aspden]

Another difficulty I'm having is creating a common function (foo, say) to
share between two scripts.

In your previous message, you were telling us that you want to load from 
your home directory.  You might put the common functions there, maybe?

-- 
François Pinard   http://pinard.progiciels-bpi.ca

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


Re: [R] garchFit in R

2007-01-08 Thread Gabor Grothendieck
See ?garchFit .  The data argument is supposed to be of class timeSeries or
a data frame, not of class ts.   Furthermore even if it did accept a variable
of class ts the ts function does not take a data frame as its
argument.  See ?ts
Follow the examples of using garchFit here:

https://svn.r-project.org/Rmetrics/trunk/fSeries/test/runit4C.R

and also review all your code doing a ? on each function that you use,
performing a class(x) on each argument, x, ensuring that each function
is called with the variables of the appropriate class.

On 1/6/07, Melina Chen [EMAIL PROTECTED] wrote:
 Dear all,

  I have problem here :
  I'm using garchFit from fSeries package, here is part of the script :
   data - read.table(d:/data.txt)
   a - garchFit(~garch(1,1),ts(data))

  I also attached the file here. In my experience, I got my R not responding.
  I also tried with
   a - garchFit(~garch(1,1),ts(data*10))
  and it's worked.

  I wonder if something wrong with the first

  Thanks

  __




 0.0026668996
 -0.0019157865
 -0.0001120967
 0.0005845345
 0.0003697987
 -0.0010323306
 -0.0023072483
 -0.0005885481
 0.0012301371
 0.0003082133
 -0.0002494891
 -0.0002006737
 -0.0004800350
 -0.0002843525
 0.0027182299
 -0.0004827581
 0.0007702074
 -0.0018742761
 -0.0012589320
 -0.0001864557
 0.0019782314
 0.00
 -0.0016593427
 0.0014883173
 -0.0019642834
 -0.0001129345
 0.0003289013
 0.0047631296
 -0.0003933189
 -0.777348
 -0.0001992589
 -0.0019439182
 -0.0017467015
 -0.0001716240
 -0.0003041862
 0.0028812028
 -0.0006391600
 -0.0004934305
 0.0002638840
 0.0004931309
 0.0002341631
 -0.0007321793
 -0.0021696036
 0.0011669581
 -0.0003526987
 0.0011745500
 -0.0001808695
 -0.0006997451
 0.587632
 0.0011198772
 0.0017887369
 0.0030052082
 0.0012059188
 0.0031819752
 -0.0032446005
 0.0009576615
 -0.0030971545
 -0.0033876838
 0.0007118065
 -0.0008289275
 -0.0001171526
 0.0004440365
 -0.0016515719
 0.0010317472
 -0.0002638158
 -0.0009735958
 0.0011201799
 0.0003223110
 -0.0026539675
 -0.0005848754
 0.0010266956
 0.0004805825
 -0.0005100232
 -0.0012333941
 -0.0046007250
 -0.0037661601
 0.0030195219
 0.0011691642
 -0.0005518513
 0.0012071954
 -0.0009286963
 -0.0013194775
 -0.0010534771
 -0.0018384612
 0.0010729640
 -0.0001352279
 -0.0041928562
 -0.0048981960
 0.0035253602
 -0.0007769906
 -0.0065450379
 0.0003404330
 0.0018162840
 -0.0008223038
 -0.0003036179
 -0.0016866227
 -0.0038151118
 0.0006511983
 -0.0049316481
 -0.0035685861
 0.583904
 0.0037786345
 0.004192
 -0.0019298763
 -0.0030373119
 -0.0006163457
 -0.0058485648
 0.0076319879
 -0.0061118610
 0.0014086934
 0.0020437674
 0.0014607365
 0.0013718807
 -0.0041446062
 0.0010107937
 -0.0025287507
 0.0035741117
 -0.0003428967
 0.0004378049
 -0.0009605837
 -0.0010898236
 0.0020398630
 0.0009532263
 0.0010508613
 -0.0006039345
 -0.0034717995
 0.0027354396
 -0.0039024422
 -0.0002178340
 0.0013848366
 0.0018343314
 -0.0003219009
 -0.0018887114
 0.0018939904
 0.0007963918
 0.0004529223
 0.0008571518
 0.0044218012
 -0.0019126781
 0.0045515451
 0.0092559993
 -0.0009015621
 -0.0020175552
 0.0002240705
 0.0038168506
 -0.0035878071
 -0.0002901422
 -0.0007389559
 0.0051061545
 -0.0021933090
 0.0014213553
 -0.0025780541
 -0.0004574410
 0.0005336344
 -0.0004675298
 0.0003608554
 0.0007360280
 -0.0015191088
 -0.0021837991
 -0.0047678519
 -0.0010459318
 0.0033618169
 -0.0011022447
 0.0011588266
 0.0001439934
 0.0036812865
 -0.0010617579
 -0.0018386819
 0.0006154677
 0.0001178651
 -0.0006306943
 -0.0001283020
 -0.0011409873
 -0.0003809962
 0.0016194965
 0.0001436634
 0.0009275365
 -0.0017079955
 0.0017694197
 -0.0006351358
 0.153772
 -0.358809
 -0.0024417258
 -0.0006706615
 0.0004231532
 -0.0003250688
 0.00
 -0.0013493117
 -0.0007721806
 -0.0004618912
 0.0011615764
 -0.0002227404
 -0.0010842518
 0.0013691318
 -0.0006736543
 -0.0008721193
 0.0036790147
 0.0002935971
 -0.0001545000
 -0.0006959312
 -0.0006298763
 0.0014236639
 0.0016909739
 0.0015975386
 -0.0005625643
 0.0039227325
 0.0001673279
 -0.0031647730
 -0.0008280651
 0.0013231273
 0.0013343643
 -0.0028724331
 -0.0002304126
 0.0014980535
 -0.0012062182
 -0.0015279076
 0.0022489747
 0.0025778462
 -0.0014449700
 -0.0023558165
 -0.0009387271
 0.0003644465
 0.0052782725
 -0.0023175981
 -0.0001121273
 0.0003362951
 -0.916910
 -0.0014952546
 -0.0008391870
 0.0016716533
 -0.0013695639
 0.0004655229
 0.0013630021
 -0.0025559437
 0.922755
 0.0014686387
 -0.0004293316
 0.0004599820
 -0.0009204516
 -0.0005327070
 0.0016216967
 -0.0005620481
 0.0013425983
 -0.0021153235
 0.921851
 0.0003224940
 0.0012161541
 -0.0029080728
 0.0004518232
 -0.0008167053
 -0.0008079421
 -0.0032780219
 -0.0022896000
 0.0021286819
 -0.0003479945
 -0.0004262835
 -0.0013439693
 -0.0002400599
 0.0019219713
 0.0008826071
 -0.311203
 0.0014344017
 0.0003049113
 -0.0007031687
 0.0014052008
 -0.0005419102
 0.0033541187
 -0.0028844242
 -0.103175
 0.0012312089
 0.0003085428
 

Re: [R] scripts with littler

2007-01-08 Thread John Lawrence Aspden
Thanks, that's a really neat mechanism, ( I especially like the note to vim,
which will save all my scripts having to end .R )

Is there any way to get at the command line and stdio though?

With littler I can do things like:

#!/usr/bin/env r

print(argv)
t=read.table(file=stdin())

so that I can write unix-style filters.

Cheers, John.



François Pinard wrote:


 I usually do something like:
 
 
 #!/bin/sh
 R --slave --vanilla EOF
 
R script goes here...
 
 EOF
 
 # vim: ft=r
 
 
 If you need to search special places for packages, you may tweak
 exported environment variables between the first and second line.


-- 
Contractor in Cambridge UK -- http://www.aspden.com

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


Re: [R] scripts with littler / subroutines

2007-01-08 Thread John Lawrence Aspden
François Pinard wrote:

 [John Lawrence Aspden]
 
Another difficulty I'm having is creating a common function (foo, say) to
share between two scripts.
 
 In your previous message, you were telling us that you want to load from
 your home directory.  You might put the common functions there, maybe?
 

I am doing at the moment, and using source to load them in. I'm worried
about what happens when I come to distribute the code though.

After a couple of e-mails off-list (thanks Dirk!) it sounds as though the
solution is to create a library for R with the common subroutines in, and
then load that from the scripts.

Cheers, John.





-- 
Contractor in Cambridge UK -- http://www.aspden.com

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


Re: [R] scripts with littler

2007-01-08 Thread Gabor Grothendieck
Looks like it will be possible to write scripts with R 2.5.0 using the
new -f flag and file(stdin).  From https://svn.r-project.org/R/trunk/NEWS :

o   Command-line R (and Rterm.exe under Windows) accepts the options
'-f filename', '--file=filename' and '-e expression' to follow
other script interpreters.  These imply --no-save unless
--save is specified.

[..]

o   file(stdin) is now recognized, and refers to the process's
'stdin' file stream whereas stdin() refers to the console.
These may differ, for example for a GUI console, an embedded
application of R or if --file= has been used.



On 1/8/07, John Lawrence Aspden [EMAIL PROTECTED] wrote:
 Thanks, that's a really neat mechanism, ( I especially like the note to vim,
 which will save all my scripts having to end .R )

 Is there any way to get at the command line and stdio though?

 With littler I can do things like:

 #!/usr/bin/env r

 print(argv)
 t=read.table(file=stdin())

 so that I can write unix-style filters.

 Cheers, John.



 François Pinard wrote:


  I usually do something like:
 
 
  #!/bin/sh
  R --slave --vanilla EOF
 
 R script goes here...
 
  EOF
 
  # vim: ft=r
 
 
  If you need to search special places for packages, you may tweak
  exported environment variables between the first and second line.


 --
 Contractor in Cambridge UK -- http://www.aspden.com

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


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


[R] Course announcement: STATISTICAL PRACTICE IN EPIDEMIOLOGY USING R

2007-01-08 Thread BXC (Bendix Carstensen)
Course in

STATISTICAL PRACTICE IN EPIDEMIOLOGY USING R 

Tartu, Estonia, 25 to 30 May 2007

The course is aimed at epidemiologists and statisticians who wish to use R for 
statistical modelling and analysis of epidemiological data.
The course requires basic knowledge of epidemiological concepts and study 
types. These will only be briefly reviewed, whereas the more advanced 
epidemiological and statistical concepts will be treated in depth.

Contents:
-
* History of R. Language. Objects. Functions.
* Interface to other dataformats. Dataframes.
* Graphical methods for exploring data.
* Classical methods and tabulation of data.
* Logistic regression for case-control-studies.
* Poisson regression for follow-up studies.
* Parametrization of models.
* Graphics in R.
* Graphical reporting of results.
* Causal inference.
* Time-splitting  SMR.
* Survival analysis in continuous time.
* Interval censoring.
* Nested and matched case-control studies.
* Case-cohort studies.
* Competing risk models.
* Multistage models.
* Bootstrap and simulation

The methods will be illustrated using R in practical exercises.

The Epi package which is under development for epidemiological analysis in R 
will be introduced.

Participants are required to have a fairly good understanding of statistical 
principles and some familiarity with epidemiological concepts. The course will 
be mainly practically oriented with more than half the time at the computer.

Price: 600 EUR. (300 EUR for countries outside EU-2003 and the like).

Application: Deadline 1st April 2007. Send and e-mail which briefly states your 
qualifications in epidemiology and statistics, to the organizers Krista 
Fischer, Esa Läärä  Bendix Carstensen. 

Further information at: www.pubhealth.ku.dk/~bxc/SPE

---
Organizers:
Krista Fischer, University of Tartu, Estonia [EMAIL PROTECTED] 
Esa Läärä, University of Oulu, Finland [EMAIL PROTECTED] 
Bendix Carstensen, Steno Diabetes Center, Denmark [EMAIL PROTECTED]

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


Re: [R] memory problem

2007-01-08 Thread Thomas Lumley
On Sat, 6 Jan 2007, Zoltan Kmetty wrote:

 Hi!

 I had some memory problem with R - hope somebody could tell me a solution.

 I work with very large datasets, but R cannot allocate enough memoty to
 handle these datasets.

You haven't said what you want to do with these datasets.

-thomas

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


[R] limitation in the number of covariates in nlme

2007-01-08 Thread mohammad frarouei
Dear All
   
  I am fitting a nlme model in which I have 7 covariates. Adding one more 
variable to the model, R gives me an error message: 
  “Error in parse(file, n, text, prompt) : syntax error in list(…..“
  This does not depend on which variables are in the model and seems to depend 
strictly on the number of covariates.
   
  Any suggestion would be appreciated.
   
  M.Fararooei
  PhD candidate

 __



[[alternative HTML version deleted]]

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


[R] fSeries Package

2007-01-08 Thread ED
Dear All;

I have used fbmSim to simulate a fbm sequence, however, when I tried to
estimate the Hurst effect, none of the nine procedures gave me an answer
close enough to the real value, which is 0.5 (n=1000). So, would you please
advice,

1. which is the best method to estimate the H among the 9 mehods, R/S,
higuchi or Whittle?

2. how to choose the levels (default=50), minnpts, cutoff values or if there
is any other issues to consider? Would you please send your code if you can
get the right estimate for the attached dataset?

3. I also simulated multiple sequences, but some of the estimated results
have H1, how would you explain this, and how to correct it.

4. if I have a sample size of 30, what are your suggestions for estimating
the hurst effect.

I really appreciate your help, and thanks in advance.

Sincerely;

Ed

[[alternative HTML version deleted]]

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


[R] fSeries Package

2007-01-08 Thread Ed Zhang
Dear All;

I have used fbmSim to simulate a fbm sequence, however, when I tried to
estimate the Hurst effect, none of the nine procedures gave me an answer
close enough to the real value, which is 0.5 (n=1000). So, would you please
advice,

1. which is the best method to estimate the H among the 9 mehods, R/S,
higuchi or Whittle?

2. how to choose the levels (default=50), minnpts, cutoff values or if there
is any other issues to consider? Would you please send your code if you can
get the right estimate for the attached dataset?

3. I also simulated multiple sequences, but some of the estimated results
have H1, how would you explain this, and how to correct it.

4. if I have a sample size of 30, what are your suggestions for estimating
the hurst effect.

I really appreciate your help, and thanks in advance.

Sincerely;

Qing

list(c(0, 0.0602883614054335, 0.0792551804556156, 0.109563140496959,
0.125726475390261, 0.101877497256596, 0.0571926667502657,
0.00262554012667387,
-0.0651825041744684, -0.0696503406796901, -0.0688337926741136,
-0.0361989921035026, -0.0496524166395568, -0.0718218507093852,
-0.109583486993751, -0.0451891749832022, -0.0260755094163026,
-0.0201228029445018, -0.08818052945358, -0.0285680272562049,
-0.032752629105123, -0.00199553309054604, 0.00508312076775159,
-0.0382257524810562, -0.0398084284989033, -0.0502088451482971,
-0.0502183047870017, -0.0174725900800023, -0.031457396692228,
-0.0497298422601627, -0.0499422794745919, -0.0361646489128442,
0.0266653302426084, -0.00219111075589404, 0.0200305010061950,
-0.054431205284715, -0.00789973517059908, -0.0085425214867059,
-0.0541809440614641, -0.110006586793787, -0.127781398474619,
-0.149159749479771, -0.0888724748560444, -0.0768016585462973,
-0.0427333724364433, -0.0562443902614682, -0.062866380084345,
-0.0883889349587378, -0.08412713827269, -0.124694662643563, -
0.0692092347299578,
-0.062046981143375, -0.0853376756560203, -0.0994827776216755,
-0.0599248702862878, -0.086369926350214, -0.0890587510305954,
-0.0599052704934926, -0.0393644348210234, -0.0364342257334110,
-0.0352152731793845, 0.00857219866032972, 0.0180050537574112,
-0.0356947245542089, -0.0615077884110117, -0.0650043906408892,
-0.0357502728853327, 0.00485292461594026, -0.0458490824792766,
-0.0735087346178546, -0.0820482814570969, -0.124917946967105,
-0.102342757999288, -0.154497291254316, -0.181381845540350, -
0.166583783090691,
-0.130709738638527, -0.124693013403996, -0.120174007595549, -
0.204900741024172,
-0.187508161990262, -0.200032164010717, -0.224311714556569, -
0.207979212824500,
-0.232450923263701, -0.198989498760939, -0.215501785889735, -
0.226880158415004,
-0.203545247216445, -0.182379290331033, -0.197038481353429, -
0.183796217531869,
-0.215299419717715, -0.226095790998872, -0.201080854888686, -
0.261516787028393,
-0.228388047078831, -0.233878235687051, -0.250375640774054, -
0.245746001611628,
-0.232938343176222, -0.204702689747725, -0.259350393091606, -
0.266266298423241,
-0.261596784773769, -0.259875864886204, -0.288719457448324, -
0.318140871065267,
-0.304593775001704, -0.263467947228369, -0.323808258544402, -
0.368149351192211,
-0.347335883864181, -0.400024671714471, -0.371544405921674, -
0.34497157633729,
-0.418657437186672, -0.446912741927435, -0.443280747761798, -
0.384739689692638,
-0.408072099289829, -0.44994167683647, -0.495273953054503, -
0.495799924479583,
-0.43697383254148, -0.440650597876129, -0.458929575025839, -
0.464585181026337,
-0.455843249117235, -0.505571057794026, -0.528316203388037, -
0.58236723395483,
-0.519865988395428, -0.555187599676786, -0.532496699903787, -
0.522718022822901,
-0.559598211031558, -0.54708053308, -0.554634133071482, -
0.541090495738355,
-0.558915651522986, -0.541917600099341, -0.578140869146858, -
0.53827826166188,
-0.52995892714492, -0.502706986562639, -0.497002923985933, -
0.488096453915811,
-0.51306171001298, -0.536938942207764, -0.515525690037527, -
0.527192086185579,
-0.511195825348352, -0.531104487863626, -0.521038783472886, -
0.519956505596612,
-0.510535242028159, -0.531234776730198, -0.526733559471536, -
0.583555032968273,
-0.551226199377139, -0.489093347568197, -0.505836247919194, -
0.485420121220644,
-0.511258369655571, -0.505044073824655, -0.496646898991666, -
0.49767793016268,
-0.496864531091594, -0.545965735276333, -0.588151447068976, -
0.594481697088302,
-0.633356216248837, -0.649947987535778, -0.698052359479746, -
0.651147537552288,
-0.678918599568793, -0.707817506128165, -0.69962378236799, -
0.664061266573256,
-0.686809968963275, -0.70940931290113, -0.710042179498104, -
0.700294406700751,
-0.69089796594532, -0.687411073827526, -0.660740247977237, -0.61857834066703,

-0.611492191585365, -0.617870447722936, -0.590305790642949, -
0.616713901938279,
-0.619126236382548, -0.618591413756597, -0.604886044395737, -
0.598434945889939,
-0.481524771809731, -0.424388823122359, -0.490492676413456, -
0.506402791875861,
-0.480172973435785, -0.517922095978117, -0.502318428525046, -
0.496731810144271,
-0.531408048623419, 

[R] Simple spectral analysis

2007-01-08 Thread Georg Hoermann
Hello world,

I am actually trying to transfer a lecture from Statistica to
R and I ran into problems with spectral analysis, I think I
just don't get it 8-(
(The posting from FFT, frequs, magnitudes, phases from 2005
did not enlighten me)

As a starter for the students I have a 10year data set of air 
temperature with daily values  and I try to
get a periodogram where the annual period (365 days) should be clearly
visible (in statistica I can get the frequencies and the period).
I tried the spectrum() and pgram() functions, but
did not find a way through... The final aim would be to
get the periodogram (and the residuals from the reassembled data set...)

Thanks and greetings,
Georg

The data set:

air = read.csv(http://www.hydrology.uni-kiel.de/~schorsch/air_temp.csv;)
airtemp = ts(T_air, start=c(1989,1), freq = 365)
plot(airtemp)


-- 
Georg Hoermann, Dep. of Hydrology, Ecology, Kiel University, Germany
+49/431/23761412, mo: +49/171/4995884, icq:348340729, skype: ghoermann

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


[R] OLS in S+

2007-01-08 Thread Megh Dal
Dear all,

Is there any equivalent of the function OLS in S+ in R?

Thanks and regards,
megh

 __



[[alternative HTML version deleted]]

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


[R] Access, Process and Read Information from Web Sites

2007-01-08 Thread Tudor Bodea
Dear R useRs,

Does any of you know if it is possible to access a web site (e.g.,
www.marriott.com), fill in the requested information (e.g., city, check-in
date, etc), and save the results (e.g., room availability and room rates) in
text files through R? I started with url and url.show but it seems that this
does not do what I would like to do. Any lead would be greatly appreciated.
Thanks.

Tudor

--
Tudor Dan Bodea
Ph.D. Candidate
Georgia Institute of Technology
School of Civil and Environmental Engineering

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


Re: [R] limitation in the number of covariates in nlme

2007-01-08 Thread Prof Brian Ripley
Please check you have the latest version of nlme (3.1-79), as some 
restrictions of this sort were lifted a few weeks ago.


If you have, please note the advice about a minimal reproducible example 
in the footer of every help message as we will need one to be able to 
help you.



On Mon, 8 Jan 2007, mohammad frarouei wrote:


Dear All

 I am fitting a nlme model in which I have 7 covariates. Adding one more 
variable to the model, R gives me an error message:

 “Error in parse(file, n, text, prompt) : syntax error in list(…..“
 This does not depend on which variables are in the model and seems to 
depend strictly on the number of covariates.


 Any suggestion would be appreciated.

 M.Fararooei
 PhD candidate

__



[[alternative HTML version deleted]]




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


Re: [R] OLS in S+

2007-01-08 Thread Frank E Harrell Jr
Megh Dal wrote:
 Dear all,
 
 Is there any equivalent of the function OLS in S+ in R?
 
 Thanks and regards,
 megh
 

If you are asking about the ols function in the Design library, it's in 
the Design package in R.  ols is a wrapper for lm that makes certain 
plots and penalized estimations easier to do.

Frank

 


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

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


[R] Cross-compilation of R and ld bug ?

2007-01-08 Thread Stéphane Dray
Hello list,

I would like to cross-compile R packages using R 2.4.0. I am working on 
Linux Debian and cross-compiled (windows binaries) without problems with 
older R version.
I have used the doc of Yan and Rossini in the contributed section of the 
R documentation (same version of MinGW...).
When I try to cross-compile R (make R), the procedure stopped and returns :

i586-mingw32-windres  --include-dir ../include -i dllversion.rc -o 
dllversion.o
i586-mingw32-gcc  -shared -s -mwindows -o R.dll R.def console.o 
dataentry.o dynl oad.o edit.o editor.o embeddedR.o extra.o opt.o pager.o 
preferences.o psignal.o rhome.o rui.o run.o shext.o sys-win32.o system.o 
e_pow.o malloc.o ../main/libmai n.a ../appl/libappl.a 
../nmath/libnmath.a graphapp/ga.a getline/gl.a ../extra/xd r/libxdr.a 
../extra/zlib/libz.a ../extra/pcre/libpcre.a ../extra/bzip2/libbz2.a 
../extra/intl/libintl.a ../extra/trio/libtrio.a dllversion.o -L. -lg2c 
-lRblas - lcomctl32 -lversion
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1703): 
undefin ed reference to `__pcre_ucp_findprop'
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1740): 
undefin ed reference to `__pcre_ucp_findprop'
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1848): 
undefin ed reference to `__pcre_ucp_findprop'
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x187f): 
undefin ed reference to `__pcre_ucp_findprop'
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1966): 
undefin ed reference to `__pcre_ucp_findprop'
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1f2a): 
more un defined references to `__pcre_ucp_findprop' follow
collect2: ld returned 1 exit status
make[4]: *** [R.dll] Erreur 1
make[3]: *** [../../bin/R.dll] Erreur 2
make[2]: *** [rbuild] Erreur 2
make[1]: *** [all] Erreur 2
make[1]: quittant le répertoire « 
/home/stephane/Rdev/CrossCompileBuild/WinR/R-2 .4.0/src/gnuwin32 »

I have read (http://www.murdoch-sutherland.com/Rtools/) that a bug 
exists for ld version 2.16.91 20050827 and that Prof Ripley produced a 
patched version. It seems that my problem is also related to ld (and I 
have the same version). So I wonder if the same bug could be responsible 
of the error in the cross-compiler.
Two questions:
- Are they other people which have the same problem when cross-compiling 
R on Linux
- Is it possible that the problem is related to ld. If yes, is it 
possible to obtain a patched version ?

Thanks in advance.
Sincerely,

-- 
Stéphane DRAY ([EMAIL PROTECTED] )
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - Lyon I
43, Bd du 11 Novembre 1918, 69622 Villeurbanne Cedex, France
Tel: 33 4 72 43 27 57   Fax: 33 4 72 43 13 88
http://biomserv.univ-lyon1.fr/~dray/

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


[R] Boxplot issue

2007-01-08 Thread antoniababe
Dear R-users,

I have a data frame containing 2 colums: column 1 is
the patient numbers (totally 36 patients), column 2 is
patient's response values (each patient has 100
response values). If I produce a boxplot for each
patient on the same graph in order to compare them
against each other then the boxplots are very small. 

How can I instead of creating one graph containing 36
boxplots, create four different graphs where three of
them have 10 boxplots each representing data of 10
patients and the fourth graph has boxplots of
remaining patients ?

Thanks alot for any suggestion,
Greetings,
Antonia

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


Re: [R] Cross-compilation of R and ld bug ?

2007-01-08 Thread Prof Brian Ripley

There are two problems here:

1) your binutils is not current.
2) your R is not current.

Updating either will solve this, but please update both.
Almost up-to-date cross-compilers are (as ever) available from

http://www.stats.ox.ac.uk/pub/Rtools/

(If you want to compile R-devel you will need to update the mingw, which 
can be done from the i386 distribution.  I will rebuild the 
cross-compilers in due course.)


On Mon, 8 Jan 2007, Stéphane Dray wrote:


Hello list,

I would like to cross-compile R packages using R 2.4.0. I am working on
Linux Debian and cross-compiled (windows binaries) without problems with
older R version.
I have used the doc of Yan and Rossini in the contributed section of the
R documentation (same version of MinGW...).
When I try to cross-compile R (make R), the procedure stopped and returns :

i586-mingw32-windres  --include-dir ../include -i dllversion.rc -o
dllversion.o
i586-mingw32-gcc  -shared -s -mwindows -o R.dll R.def console.o
dataentry.o dynl oad.o edit.o editor.o embeddedR.o extra.o opt.o pager.o
preferences.o psignal.o rhome.o rui.o run.o shext.o sys-win32.o system.o
e_pow.o malloc.o ../main/libmai n.a ../appl/libappl.a
../nmath/libnmath.a graphapp/ga.a getline/gl.a ../extra/xd r/libxdr.a
../extra/zlib/libz.a ../extra/pcre/libpcre.a ../extra/bzip2/libbz2.a
../extra/intl/libintl.a ../extra/trio/libtrio.a dllversion.o -L. -lg2c
-lRblas - lcomctl32 -lversion
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1703):
undefin ed reference to `__pcre_ucp_findprop'
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1740):
undefin ed reference to `__pcre_ucp_findprop'
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1848):
undefin ed reference to `__pcre_ucp_findprop'
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x187f):
undefin ed reference to `__pcre_ucp_findprop'
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1966):
undefin ed reference to `__pcre_ucp_findprop'
../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1f2a):
more un defined references to `__pcre_ucp_findprop' follow
collect2: ld returned 1 exit status
make[4]: *** [R.dll] Erreur 1
make[3]: *** [../../bin/R.dll] Erreur 2
make[2]: *** [rbuild] Erreur 2
make[1]: *** [all] Erreur 2
make[1]: quittant le répertoire «
/home/stephane/Rdev/CrossCompileBuild/WinR/R-2 .4.0/src/gnuwin32 »

I have read (http://www.murdoch-sutherland.com/Rtools/) that a bug
exists for ld version 2.16.91 20050827 and that Prof Ripley produced a
patched version. It seems that my problem is also related to ld (and I
have the same version). So I wonder if the same bug could be responsible
of the error in the cross-compiler.
Two questions:
- Are they other people which have the same problem when cross-compiling
R on Linux
- Is it possible that the problem is related to ld. If yes, is it
possible to obtain a patched version ?

Thanks in advance.
Sincerely,




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


Re: [R] Boxplot issue

2007-01-08 Thread jim holtman
How about 4 plots of 9 each.  You can change the 'cut' for other
distributions of your IDs.


pData - data.frame(id=sample(1:36,1000,T), data=rnorm(1000))  # sample data
partData - split(pData, cut(pData$id, 4))  # split into 4 groups
boxplot(data ~ id, pData)  # original plot
lapply(partData, function(x) boxplot(data ~ id, x)) # 4 plots





On 1/8/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:

 Dear R-users,

 I have a data frame containing 2 colums: column 1 is
 the patient numbers (totally 36 patients), column 2 is
 patient's response values (each patient has 100
 response values). If I produce a boxplot for each
 patient on the same graph in order to compare them
 against each other then the boxplots are very small.

 How can I instead of creating one graph containing 36
 boxplots, create four different graphs where three of
 them have 10 boxplots each representing data of 10
 patients and the fourth graph has boxplots of
 remaining patients ?

 Thanks alot for any suggestion,
 Greetings,
 Antonia

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




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

What is the problem you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] memory problem --- use sparse matrices

2007-01-08 Thread Martin Maechler
 UweL == Uwe Ligges [EMAIL PROTECTED]
 on Sun, 07 Jan 2007 09:42:08 +0100 writes:

UweL Zoltan Kmetty wrote:
 Hi!
 
 I had some memory problem with R - hope somebody could
 tell me a solution.
 
 I work with very large datasets, but R cannot allocate
 enough memoty to handle these datasets.
 
 I want work a matrix with row= 100 000 000 and column=10
 
 A know this is 1 milliard cases, but i thought R could
 handle it (other commercial software like spss could do),
 but R wrote out everytime: not enough memory..
 
 any good idea?

UweL Buy a machine that has at least 8Gb (better 16Gb) of
UweL RAM and proceed ...

Well, I doubt that Zoltan wants to *fill* his matrix with all
non-zeros. If he does, Uwe and Roger are right.

Otherwise, working with a *sparse* matrix, using the 'Matrix'
(my recommendation, but I am biased) or 'SparseM' package, might
well be feasible:

install.packages(Matrix) # if needed; only once for your R

library(Matrix) # each time you need it


TsparseMatrix - function(nrow, ncol, i,j,x) 
{
## Purpose: User friendly construction of sparse Matrix from triple
## --
## Arguments: (i,j,x): 2 integer and 1 numeric vector of the same length:
##
##  The matrix M will have
##   M[i[k], j[k]] == x[k] , for k = 1,2,..., length(i)
##and M[ i', j' ]  ==  0  for `` all other pairs (i',j')
## --
## Author: Martin Maechler, Date:  8 Jan 2007, 18:46
nnz - length(i)
stopifnot(length(j) == nnz, length(x) == nnz,
  is.numeric(x), is.numeric(i), is.numeric(j))
dim - c(as.integer(nrow), as.integer(ncol))
## The conformability of (i,j) with 'dim' will be checked automatically
## by an internal validObject() that is part of new(.):
new(dgTMatrix, x = x, Dim = dim,
## our Tsparse Matrices use  0-based indices :
i = as.integer(i - 1:1),
j = as.integer(j - 1:1))
}

For example :

 TsparseMatrix(10,20, c(1,3:8), c(2,9,6:10), 7 * (1:7))
10 x 20 sparse Matrix of class dgTMatrix
  
 [1,] . 7 . . .  .  .  .  .  . . . . . . . . . . .
 [2,] . . . . .  .  .  .  .  . . . . . . . . . . .
 [3,] . . . . .  .  .  . 14  . . . . . . . . . . .
 [4,] . . . . . 21  .  .  .  . . . . . . . . . . .
 [5,] . . . . .  . 28  .  .  . . . . . . . . . . .
 [6,] . . . . .  .  . 35  .  . . . . . . . . . . .
 [7,] . . . . .  .  .  . 42  . . . . . . . . . . .
 [8,] . . . . .  .  .  .  . 49 . . . . . . . . . .
 [9,] . . . . .  .  .  .  .  . . . . . . . . . . .
[10,] . . . . .  .  .  .  .  . . . . . . . . . . .

But

nr - 1e8
nc - 10
set.seed(1)
i - sample(nr, 1)
j - sample(nc, 1)
x - round(rnorm(1), 2)

M - TsparseMatrix(nr, nc, i=i, j=j, x=x)

works,
e.g. you can

x - 1:10
system.time(y - M %*% x)  # needs around 4 sec on one of our better machines
y - as.vector(y)

## but you can become even more efficient, translating from the
## so-called triplet to the (recommended) Csparse
## representation:
M. - as(M, CsparseMatrix)

object.size(M) / object.size(M.)
## 1.328921; i.e. we saved 33%

## and

system.time(y. - M. %*% x) # much faster (1 sec)

identical(as.vector(y.), y)


--- --- ---

I hope this is useful to you.

Martin Maechler,
ETH Zurich

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


Re: [R] Plot .jpeg image in margins?

2007-01-08 Thread Greg Snow
Here is one example of a way to do it:

library(rimage) # for the read.jpeg function
library(TeachingDemos) # for the subplot function

par(xpd=NA,mar=c(5,4,4,8)+0.1)

plot(1:10,10:1)

x - read.jpeg(system.file(data, cat.jpg, package=rimage))

subplot( plot(x), 12, 5 )


Hope this helps,

-- 
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 Kari
 Sent: Sunday, January 07, 2007 10:10 PM
 To: r-help@stat.math.ethz.ch
 Subject: [R] Plot .jpeg image in margins?
 
 Is it possible to plot an image (currently a jpeg) in the margins?
 
 
 Thanks,
 Kari
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


[R] odfWeave and figures in MS Word Format

2007-01-08 Thread Laurent Rhelp
I answer to myself.
I understood my error : first of all, we have to save the file in the 
.rtf format !
Then, from the rtf file, we can generate the file in the .doc format.

I am sorry for my question.

Thanks

Laurent

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


Re: [R] query

2007-01-08 Thread Greg Snow
Look at :

 myccf * c(17,18,19,18,17)/19

Do those numbers match with the result of ccf?

-- 
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 Fluss
 Sent: Monday, January 08, 2007 6:18 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] query
 
 Hello!
 I found the ccf function gives different estimates than the 
 simple lag correlations.
 Why is that?
 This is my code:
 
 set.seed(20)
 x-rnorm(20)
 y-x+rnorm(20,sd=0.3)
 print(R CCF:)
 print(ccf(x,y,lag.max=2,plot=F))
 myccf- c( cor(y[-(1:2)],x[-(19:20)]) ,  cor(y[-1],x[-20]),
cor(y,x),

 cor(x[-1],y[-20]),cor(x[-(1:2)],y[-(19:20)]) ) print(My CCF:)
 print(myccf)
 
 Thank You!
 Ron
 
   [[alternative HTML version deleted]]
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


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


[R] coefficients of each local polynomial from loess() or locfit()

2007-01-08 Thread Liu, Delong \(NIH/CIT\) [C]
Dieter,

Thanks for your suggestions and help.  I am not an expert with R
programming. In my current application, I am not interested in point
prediction from loess().  Instead, I am more interested in obtaining the
coefficient estimates of local polynomial from loess().  Is it
straightforward to modify loess() so that the coefficient estimates can
be put into the return list of loess()?  

Delong

--

Message: 8
Date: Fri, 5 Jan 2007 14:01:46 + (UTC)
From: Dieter Menne [EMAIL PROTECTED]
Subject: Re: [R] coefficients of each local polynomial from loess() or
locfit()
To: r-help@stat.math.ethz.ch
Message-ID: [EMAIL PROTECTED]
Content-Type: text/plain; charset=us-ascii

Liu, Delong (NIH/CIT) [C] liud2 at mail.nih.gov writes:

 
I want to extract estimated coeffiicents of each local polynomial at 
given x from loess(),  locfit(), or KernSmooth().  Can some experts 
provide me with suggestions?  Thanks.


Try 

cars.lo - loess(dist ~ speed, cars)
str(cars.lo)

List of 17
 $ n: int 50
 $ fitted   : num [1:50]  5.89  5.89 12.57 12.57 15.37 ...
 $ residuals: Named num [1:50] -3.894  4.106 -8.568  9.432  0.631 ...
... omitted
  ..$ cell   : num 0.2
  ..$ family : chr gaussian
  ..$ iterations : num 1
 $ kd   :List of 5
  ..$ parameter: Named int [1:7] 1 50 2 19 11 1049 849
  .. ..- attr(*, names)= chr [1:7] d n vc nc ...
  ..$ a: int [1:19] 1 1 1 1 1 1 1 0 0 0 ...
  ..$ xi   : num [1:19] 15 12 19 9 13 17 20 0 0 0 ...
  ..$ vert : num [1:2]  3.90 25.11
  ..$ vval : num [1:22]  5.71  1.72 96.46 10.88 41.21 ...
 $ call : language loess(formula = dist ~ speed, data = cars)

Looks like kd holds information about the polynomials. Then, try

getAnywhere(predict.loess)

which will show you that the real work is done in function predLoess. 
Trying again

getAnywhere(predLoess)

you get an idea how the parameters are used for prediction.

fit[inside] - .C(R_loess_ifit, as.integer(kd$parameter), 
 as.integer(kd$a), as.double(kd$xi), as.double(kd$vert), 
as.double(kd$vval), as.integer(M1), as.double(x.evaluate[inside,

  ]), fit = double(M1))$fit

Dieter

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


[R] Ecartis command results: -- Binary/unsupported file stripped by Ecartis --

2007-01-08 Thread Ecartis
Request received for list 'unicode' via request address.

 The original message was received at Mon, 8 Jan 2007 21:05:47 +0200
 from 2.178.6.230
Unknown command.

 - The following addresses had permanent fatal errors -
Unknown command.

 [EMAIL PROTECTED]
Unknown command.

---
Ecartis v1.0.0 - job execution complete.

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


[R] spatio temporal plot

2007-01-08 Thread Michela Cameletti
Dear R-users,
I have a matrix of data (air pollution) with n rows and T columns, where n
is the number of spatial locations and T is the number of time points
(days of the year).
I would like to use a 3d plot for plotting the n time series I have: so
x-axis and y-axis are for the spatial coordinates and the z-axis is for
the T air pollution data. But the final result should be like this: see
the attached figure. It's like doing n vertical plots of the n time series
and put them nearby using the spatial coordinates.
Can you help me please?
Thanks in advance,
best regards
Michela

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


Re: [R] coefficients of each local polynomial from loess() or locfit()

2007-01-08 Thread Dieter Menne
Liu, Delong (NIH/CIT) [C] liud2 at mail.nih.gov writes:

 Instead, I am more interested in obtaining the
 coefficient estimates of local polynomial from loess().  Is it
 straightforward to modify loess() so that the coefficient estimates can
 be put into the return list of loess()?  

No need to change loess.
 
 cars.lo - loess(dist ~ speed, cars)
 str(cars.lo)
 
 List of 17
...
  $ kd   :List of 5
   ..$ parameter: Named int [1:7] 1 50 2 19 11 1049 849
   .. ..- attr(*, names)= chr [1:7] d n vc nc ...
   ..$ a: int [1:19] 1 1 1 1 1 1 1 0 0 0 ...
   ..$ xi   : num [1:19] 15 12 19 9 13 17 20 0 0 0 ...
   ..$ vert : num [1:2]  3.90 25.11
   ..$ vval : num [1:22]  5.71  1.72 96.46 10.88 41.21 ...

As I showed you, they are in cars.lo$kd, but you must dig into the source code
to find out how they are used. And after reading Brian Ripley's warning, I would
recommend that you don't try it if you are not sure how extract these.

Dieter

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


[R] finer control of scales in xyplot

2007-01-08 Thread Benjamin Tyner
When plotting over multiple pages in lattice, I'd like to be able to 
have same scales within a page, but free scales between pages. In 
other words, something like:

z-data.frame(x=1:100,
  y=runif(100),
  d=rep(1:2,50),
  p=rep(1:2,each=50))

plot-xyplot(y~x|d*p,
 data=z,
 scales=list(x=list(relation=free)),
 layout=c(1,2))

but within a page, to have common x-axes. As long as 'x' is sorted, I 
can get the desired effect by transforming x to a relative scale:

plot-xyplot(y~unlist(with(z,tapply(x,p,function(x) 
(x-min(x))/diff(range(x)|d*p,
 data=z,
 layout=c(1,2))

except that I'd like the tickmark labels to be in the original units of 
'x'. I've started looking at xscale.components.default to see whether it 
can work on a per-page (instead of per-panel) basis, but I get the 
nagging suspicion that I'm making this harder than it needs to be. Any 
assistance greatly appreciated.

Thanks,
Ben

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


Re: [R] spatio temporal plot

2007-01-08 Thread Scionforbai
Altough I didn't test it, I think rgl package should do this.

Regards,

Scionforbai

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


Re: [R] listing all functions in R

2007-01-08 Thread Earl F. Glynn
Prof Brian Ripley [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Here is a reasonable shot:

 findfuns - function(x) {
 if(require(x, character.only=TRUE)) {
env - paste(package, x, sep=:)
nm - ls(env, all=TRUE)
nm[unlist(lapply(nm, function(n) exists(n, where=env,
   mode=function,
   inherits=FALSE)))]
 } else character(0)
 }
 pkgs - dir(.Library)
 z -  lapply(pkgs, findfuns)
 names(z) - pkgs

Any recommendations on how to trap problems with require when using 
findfuns?  One bad package and the lapply above doesn't return anything.

For example:

 findfuns(bcp)
Loading required package: bcp
Loading required package: DNAcopy
Error: package 'DNAcopy' could not be loaded
In addition: Warning message:
there is no package called 'DNAcopy' in: library(pkg, character.only = TRUE, 
logical = TRUE, lib.loc = lib.loc)

 require(bcp, character.only=TRUE)
Loading required package: bcp
Loading required package: DNAcopy
Error: package 'DNAcopy' could not be loaded
In addition: Warning message:
there is no package called 'DNAcopy' in: library(pkg, character.only = TRUE, 
logical = TRUE, lib.loc = lib.loc)


I used try around the require call with options(error=recover) with 
recover defined to be a do nothing function to avoid the stop, but then 
there were other problems (e.g., unable to load shared library ... 
LoadLibrary Failure: The specified module could not be found and Maximal 
number of DLLs reached)

Besides bcp I saw problems with other packages, e.g., cairoDevice, 
caMassClass, ... several others.

I'm using R 2.4.1with all CRAN packages installed that existed last week and 
at least several Bioconductor packages installed by the biocLite procedure.

FWIW:
 length(pkgs)
[1] 957


Thanks for any suggestions.

efg

Earl F. Glynn
Scientific Programmer
Stower Institute

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


Re: [R] Simple spectral analysis

2007-01-08 Thread Earl F. Glynn
Georg Hoermann [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 The data set:

 air = read.csv(http://www.hydrology.uni-kiel.de/~schorsch/air_temp.csv;)
 airtemp = ts(T_air, start=c(1989,1), freq = 365)
 plot(airtemp)

Maybe this will get you started using fft or spectrum -- I'm not sure why 
the spectrum answer is only close:

air = read.csv(http://www.hydrology.uni-kiel.de/~schorsch/air_temp.csv;)

TempAirC - air$T_air
Time - as.Date(air$Date, %d.%m.%Y)
N - length(Time)

oldpar - par(mfrow=c(4,1))
plot(TempAirC ~ Time)

# Using fft
transform - fft(TempAirC)

# Extract DC component from transform
dc - Mod(transform[1])/N

periodogram - round( Mod(transform)^2/N, 3)

# Drop first element, which is the mean
periodogram - periodogram[-1]

# keep first half up to Nyquist limit
periodogram - periodogram[1:(N/2)]

# Approximate number of data points in single cycle:
print( N / which(max(periodogram) == periodogram) )

# plot spectrum against Fourier Frequency index
plot(periodogram, col=red, type=o,
 xlab=Fourier Frequency Index, xlim=c(0,25),
 ylab=Periodogram,
 main=Periodogram derived from 'fft')

# Using spectrum
s - spectrum(TempAirC, taper=0, detrend=FALSE, col=red,
  main=Spectral Density)

plot(log(s$spec) ~ s$freq, col=red, type=o,
 xlab=Fourier Frequency, xlim=c(0.0, 0.005),
 ylab=Log(Periodogram),
 main=Periodogram from 'spectrum')

cat(Max frequency\n)
maxfreq - s$freq[ which(max(s$spec) == s$spec) ]

# Period will be 1/frequency:
cat(Corresponding period\n)
print(1/maxfreq)

par(oldpar)



efg

Earl F. Glynn
Scientific Programmer
Stowers Institute

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


[R] Does strptime(...,tz=GMT) do anything?

2007-01-08 Thread David Forrest
Hi All

In trying to correlate some tide gauge data I need to deal with varying 
timezones.  From the documentation on strptime, it seemed that the tz 
variable might have some effect on the conversion, but I'm not seeing an 
effect.

 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=PST)+0
[1] 2006-12-01 01:02:00 EST
 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=)+0
[1] 2006-12-01 01:02:00 EST
 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=GMT)+0
[1] 2006-12-01 01:02:00 EST
 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=UTC)+0
[1] 2006-12-01 01:02:00 EST
 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=EST)+0
[1] 2006-12-01 01:02:00 EST

What is the recommended way of handling this?  Computing and adding 
offsets manually?

 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=UTC)+3600*3
[1] 2006-12-01 04:02:00 EST

Or am I doing something wrong with the strptime(..., tz=EST) function?

Thanks for your time,
Dave
-- 
  Dr. David Forrest
  [EMAIL PROTECTED](804)684-7900w
  [EMAIL PROTECTED] (804)642-0662h
http://maplepark.com/~drf5n/

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


Re: [R] Simple spectral analysis

2007-01-08 Thread Peter Dalgaard
Earl F. Glynn wrote:
 Georg Hoermann [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
   
 The data set:

 air = read.csv(http://www.hydrology.uni-kiel.de/~schorsch/air_temp.csv;)
 airtemp = ts(T_air, start=c(1989,1), freq = 365)
 plot(airtemp)
 

 Maybe this will get you started using fft or spectrum -- I'm not sure why 
 the spectrum answer is only close:
   
The defaults for detrending and tapering could be involved. Putting, 
e.g., detrend=F gives me a spectrum with substantially higher 
low-frequency components.

But what was the problem in the first place?

spec.pgram(airtemp,xlim=c(0,10))

abline(v=1:10,col=red)


shows a strong peak at 1 and maybe a weak peak at 2, and the other 
integer frequencies less pronounced. This seems reasonably in tune with

 x - (1:3652)/365

 summary(lm(air$T_air ~ sin(2*pi*x)+cos(2*pi*x)+  sin(4*pi*x)+cos(4*pi*x) +  
 sin(6*pi*x)+cos(6*pi*x)+x))

Call:

lm(formula = air$T_air ~ sin(2 * pi * x) + cos(2 * pi * x) + 

sin(4 * pi * x) + cos(4 * pi * x) + sin(6 * pi * x) + cos(6 * 

pi * x) + x)

Residuals:

 Min   1Q   Median   3Q  Max 

-16.3109  -2.3317  -0.1080   2.2063  10.6249 

Coefficients:

Estimate Std. Error t value Pr(|t|)

(Intercept)  9.679040.11267  85.909   2e-16 ***

sin(2 * pi * x) -2.645540.07967 -33.208   2e-16 ***

cos(2 * pi * x) -7.735200.07938 -97.443   2e-16 ***

sin(4 * pi * x)  0.929670.07948  11.696   2e-16 ***

cos(4 * pi * x)  0.139820.07938   1.761   0.0783 .  

sin(6 * pi * x)  0.133200.07945   1.676   0.0937 .  

cos(6 * pi * x)  0.144800.07938   1.824   0.0682 .  

x   -0.237730.01952 -12.179   2e-16 ***

---

Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 


Residual standard error: 3.393 on 3644 degrees of freedom

Multiple R-Squared: 0.7486, Adjusted R-squared: 0.7482 

F-statistic:  1550 on 7 and 3644 DF,  p-value:  2.2e-16 





 air = read.csv(http://www.hydrology.uni-kiel.de/~schorsch/air_temp.csv;)

 TempAirC - air$T_air
 Time - as.Date(air$Date, %d.%m.%Y)
 N - length(Time)

 oldpar - par(mfrow=c(4,1))
 plot(TempAirC ~ Time)

 # Using fft
 transform - fft(TempAirC)

 # Extract DC component from transform
 dc - Mod(transform[1])/N

 periodogram - round( Mod(transform)^2/N, 3)

 # Drop first element, which is the mean
 periodogram - periodogram[-1]

 # keep first half up to Nyquist limit
 periodogram - periodogram[1:(N/2)]

 # Approximate number of data points in single cycle:
 print( N / which(max(periodogram) == periodogram) )

 # plot spectrum against Fourier Frequency index
 plot(periodogram, col=red, type=o,
  xlab=Fourier Frequency Index, xlim=c(0,25),
  ylab=Periodogram,
  main=Periodogram derived from 'fft')

 # Using spectrum
 s - spectrum(TempAirC, taper=0, detrend=FALSE, col=red,
   main=Spectral Density)

 plot(log(s$spec) ~ s$freq, col=red, type=o,
  xlab=Fourier Frequency, xlim=c(0.0, 0.005),
  ylab=Log(Periodogram),
  main=Periodogram from 'spectrum')

 cat(Max frequency\n)
 maxfreq - s$freq[ which(max(s$spec) == s$spec) ]

 # Period will be 1/frequency:
 cat(Corresponding period\n)
 print(1/maxfreq)

 par(oldpar)



 efg

 Earl F. Glynn
 Scientific Programmer
 Stowers Institute

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


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


Re: [R] Does strptime(...,tz=GMT) do anything?

2007-01-08 Thread Prof Brian Ripley
Is EST a timezone on your system?  You have not told us your system, but 
on most the timezone in the Eastern US is EST5EDT, not EST.  Similarly 
with PST.  (See ?as.POSIXct.)

Remember that strptime returns an object of class POSIXlt and that has a 
'isdst' field.  The timezone controls that, but none of your examples are 
in a timezone that is on DST, nor would they be in EST5EDT or PST8PDT.

Rather than add 0, I think you want to convert to POSIXct, specifying the 
timezone (a valid one).

as.POSIXct(strptime(20061201 1:02,format=%Y%m%d %H:%M, tz=PST8PDT),
tz=PST8PDT)
[1] 2006-12-01 01:02:00 PST


On Mon, 8 Jan 2007, David Forrest wrote:

 Hi All

 In trying to correlate some tide gauge data I need to deal with varying
 timezones.  From the documentation on strptime, it seemed that the tz
 variable might have some effect on the conversion, but I'm not seeing an
 effect.

 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=PST)+0
 [1] 2006-12-01 01:02:00 EST
 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=)+0
 [1] 2006-12-01 01:02:00 EST
 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=GMT)+0
 [1] 2006-12-01 01:02:00 EST
 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=UTC)+0
 [1] 2006-12-01 01:02:00 EST
 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=EST)+0
 [1] 2006-12-01 01:02:00 EST

 What is the recommended way of handling this?  Computing and adding
 offsets manually?

 strptime(20061201 1:02 PST,format=%Y%m%d %H:%M,tz=UTC)+3600*3
 [1] 2006-12-01 04:02:00 EST

 Or am I doing something wrong with the strptime(..., tz=EST) function?

 Thanks for your time,
 Dave


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

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


Re: [R] scripts with littler

2007-01-08 Thread Prof Brian Ripley

He missed

o   There is a new front-end Rscript which can be used for #!
scripts and similar tasks.  See help(Rscript) and 'An
Introduction to R' for further details.

and that is needed for #! scripts.  (You cannot write #!/path/to/R -f as R 
is a shell script and so disallowed on most OSes.)


As I understand the earlier question, if you have

#! /usr/env cmd arg1 arg2

/usr/env is passed 'cmd arg1 arg2' as the name of the utility, at least 
under bash which says


   If  the program is a file beginning with #!, the remainder of the first
   line specifies an interpreter for the program.  The shell executes  the
   specified interpreter on operating systems that do not handle this exe-
   cutable format themselves.  The arguments to the interpreter consist of
   a  single optional argument following the interpreter name ...

Note the 'single'.  This is detailed as part of the description of Rscript 
referred to in the NEWS item.  I don't know how universal this is, but the 
Solaris Bourne shell does the same thing.


François Pinard's idea of here documents is nice until you want to read 
from the script's stdin rather than the script itself.




On Mon, 8 Jan 2007, Gabor Grothendieck wrote:


Looks like it will be possible to write scripts with R 2.5.0 using the
new -f flag and file(stdin).  From https://svn.r-project.org/R/trunk/NEWS :

   oCommand-line R (and Rterm.exe under Windows) accepts the options
'-f filename', '--file=filename' and '-e expression' to follow
other script interpreters.  These imply --no-save unless
--save is specified.

[..]

   ofile(stdin) is now recognized, and refers to the process's
'stdin' file stream whereas stdin() refers to the console.
These may differ, for example for a GUI console, an embedded
application of R or if --file= has been used.



On 1/8/07, John Lawrence Aspden [EMAIL PROTECTED] wrote:

Thanks, that's a really neat mechanism, ( I especially like the note to vim,
which will save all my scripts having to end .R )

Is there any way to get at the command line and stdio though?

With littler I can do things like:

#!/usr/bin/env r

print(argv)
t=read.table(file=stdin())

so that I can write unix-style filters.

Cheers, John.



François Pinard wrote:



I usually do something like:


#!/bin/sh
R --slave --vanilla EOF

   R script goes here...

EOF

# vim: ft=r


If you need to search special places for packages, you may tweak
exported environment variables between the first and second line.



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


Re: [R] finer control of scales in xyplot

2007-01-08 Thread Deepayan Sarkar
On 1/8/07, Benjamin Tyner [EMAIL PROTECTED] wrote:
 When plotting over multiple pages in lattice, I'd like to be able to
 have same scales within a page, but free scales between pages. In
 other words, something like:

 z-data.frame(x=1:100,
   y=runif(100),
   d=rep(1:2,50),
   p=rep(1:2,each=50))

 plot-xyplot(y~x|d*p,
  data=z,
  scales=list(x=list(relation=free)),
  layout=c(1,2))

 but within a page, to have common x-axes. As long as 'x' is sorted, I
 can get the desired effect by transforming x to a relative scale:

 plot-xyplot(y~unlist(with(z,tapply(x,p,function(x)
 (x-min(x))/diff(range(x)|d*p,
  data=z,
  layout=c(1,2))

 except that I'd like the tickmark labels to be in the original units of
 'x'. I've started looking at xscale.components.default to see whether it
 can work on a per-page (instead of per-panel) basis, but I get the
 nagging suspicion that I'm making this harder than it needs to be. Any
 assistance greatly appreciated.

A nice solution is unlikely. As a general rule, the trellis object
doesn't know anything about what layout it's going to be plotted with,
and unfortunately the panel-specific scales are determined when the
object is created, not when it is plotted (I don't remember all the
reasons for this choice, but changing it would require a major
overhaul). A similar task, row-specific or column-specific free
scales, is difficult for the same reason.

If I need to do this, I usually have in scales

1. relation=free

2. limits = list(lim1, lim2, ...) where lim1, lim2, etc are
packet-specific limits (they have to be supplied explicitly). You can
omit this if you can make sure your prepanel function gives you the
right things.

This will almost do what you want, but will repeat the ticks/labels
for every panel. To suppress that you can additionally have

3. at = list(TRUE, NULL, ...) etc where NULL means ticks/labels won't be drawn.

This doesn't really help, because the space will still be wasted, so finally,

4. add par.settings = list(layout.heights = list(axis.panel = c(1, 0, ...)))

-Deepayan

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


[R] A question about R environment

2007-01-08 Thread Tong Wang
Hi  all,
 
I created environment  mytoolbox by :   mytoolbox - new.env(parent=baseenv())
Is there anyway I put it in the search path ?

If you need some background :
  In a project, I often write some small functions,  and load them into my 
workspace directly,   so when I list the objects 
  with ls(), it looks pretty messy.  So I am wondering if it is possible to 
creat an environment,  and put these tools into 
  this environment.  For example,  I have functionsfun1(), fun2() ..
and creat an environment  mytoolbox  which 
  contains all these functions.  And it should be somewhere in the search path: 
  .GlobalEnvmytoolboxpackage:methods  


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


Re: [R] A question about R environment

2007-01-08 Thread Gabor Grothendieck
Try this:

 e - new.env()
 e$f - function(x)x
 attach(e)
 search()
 [1] .GlobalEnve package:stats
 [4] package:graphics  package:grDevices package:utils
 [7] package:datasets  package:methods   Autoloads
[10] package:base
 f
function(x)x

On 1/8/07, Tong Wang [EMAIL PROTECTED] wrote:
 Hi  all,

 I created environment  mytoolbox by :   mytoolbox - 
 new.env(parent=baseenv())
 Is there anyway I put it in the search path ?

 If you need some background :
  In a project, I often write some small functions,  and load them into my 
 workspace directly,   so when I list the objects
  with ls(), it looks pretty messy.  So I am wondering if it is possible to 
 creat an environment,  and put these tools into
  this environment.  For example,  I have functionsfun1(), fun2() ..   
  and creat an environment  mytoolbox  which
  contains all these functions.  And it should be somewhere in the search 
 path:   .GlobalEnvmytoolbox
 package:methods  

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


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


[R] Partial proportional odds logistic regression

2007-01-08 Thread Inman, Brant A. M.D.

Just a follow-up note on my last posting.  I still have not had any
replies from the R-experts our there that use partial proportional odds
regression (and I have to hope that there are some of you!) but I do
think that I have figured out how to perform the unconstrained partial
proportional odds model using vglm.  I show this code below for the
benefit of others that may want to try it (or point out my errors) using
one of the datasets in Petersen and Harrell's paper (Appl Stat 1990).
However, I remain open for suggestions on how to implement the
unconstrained partial proportional odds model.

--

library(VGAM)
library(MASS)
library(Design)

###
# Nausea dataset
# Peterson and Harrell. Applied Statistics 1990, 39(2): 205-217

nausea.short - data.frame(matrix(nrow=12, ncol=3)) #Table 2
colnames(nausea.short) - c('nausea', 'cisplatin', 'freq')
nausea.short[,1] - ordered(rep(seq(0,5,1),2),
labels=seq(0,5,1))
nausea.short[,2] - c(rep(0,6), rep(1,6))
nausea.short[,3] - c(43,39,13,22,15,29,7,7,3,12,15,14)

# Proportional odds ordinal logistic regression: 3 options
polr(nausea ~ cisplatin, weights=freq, data=nausea.short,
method='logistic')
lrm(nausea ~ cisplatin, weights=freq, data=nausea.short)
vglm(nausea ~ cisplatin, weights=freq, data=nausea.short,
family=cumulative(parallel=T, reverse=T))


# Unconstrained partial proportional odds ordinal logistic regression
vglm(nausea ~ cisplatin, weights=freq, data=nausea.short,
family=cumulative(parallel=F, reverse=T))

--

The results obtained with this approach appear consistent with those
presented in Table 3 of the paper.  However, the code for the
unconstrained partial proportional odds model is so simple (just one
letter is different than in the proportional odds model!) that I wonder
if there is not room for error here that I am too inexperienced to
identify.

Again, help with the constrained model would be greatly appreciated.

Brant Inman

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


Re: [R] A question about R environment

2007-01-08 Thread François Pinard
[Tong Wang]

I created environment mytoolbox by : mytoolbox - 
new.env(parent=baseenv()).  Is there anyway I put it in the search 
path?  In a project, I often write some small functions, and load them 
into my workspace directly, so when I list the objects with ls(), it 
looks pretty messy.  So I am wondering if it is possible to creat an 
environment, and put these tools into this environment.  For example, 
I have functions fun1(), fun2() ... and creat an environment mytoolbox 
which contains all these functions.  And it should be somewhere in the 
search path:  .GlobalEnv mytoolbox package:methods.

Here is a trick, shown as a fairly simplified copy of my ~/.Rprofile.  
It allows for a few simple functions always available, yet without 
having to create a package, and leaving ls() and any later .RData file 
unencumbered.

The idea is to use local() to prevent any unwanted clutter to leak out 
(my real ~/.Rprofile holds more than shown below and use temporary 
variables), to initialise a list meant to hold a bunch of functions or 
other R things, and to save that list on the search path.

This example also demonstrate a few useful functions for when I read the 
R mailing list.  I often need to transfer part of emails containing
code excerpts within the window where R executes, while removing 
quotation marks, white lines and other noise.  I merely highlight-select 
part of the message with the mouse, and then, within R, do things like:

   xs()   source the highlighted region
   xd()   read in a data.frame
   xm()   read in a matrix
   xe()   evaluate and print an expression
   xv()   read a list of values as a vector

The list above in decreasing order of usefulness (for me).  Except for 
xs(), which has no automatic printout, you may either let the others 
print what they got, or assign their value to some variable.  Arguments 
are also possible, for example like this:

   xd(T)  read in a data.frame when the first line holds column names



if (interactive()) {
local({

fp.etc - list()

fp.etc$xsel.vector - function (...) {
connexion - textConnection(xselection())
on.exit(close(connexion))
scan(connexion, ...)
}
fp.etc$xsel.dataframe - function (...) {
connexion - textConnection(xselection())
on.exit(close(connexion))
read.table(connexion, ...)
}
fp.etc$xsel.matrix - function (...) {
connexion - textConnection(xselection())
on.exit(close(connexion))
data.matrix(read.table(connexion, ...))
}
fp.etc$xsel.eval - function (...) {
connexion - textConnection(xselection())
on.exit(close(connexion))
eval(parse(connexion, ...))
}
fp.etc$xsel.source - function (...) {
connexion - textConnection(xselection())
on.exit(close(connexion))
source(connexion, ...)
}

fp.etc$xselection - function ()
{
lignes - suppressWarnings(readLines('clipboard'))
lignes - lignes[lignes != '']
stopifnot(length(lignes) != 0)
marge - substr(lignes, 1, 1)
while (all(marge %in% c('', '+', ':', '|'))
  || all(marge == ' ')) {
lignes - substring(lignes, 2)
marge - substr(lignes, 1, 1)
}
lignes
}

fp.etc$xv - fp.etc$xsel.vector
fp.etc$xd - fp.etc$xsel.dataframe
fp.etc$xm - fp.etc$xsel.matrix
fp.etc$xe - fp.etc$xsel.eval
fp.etc$xs - fp.etc$xsel.source

attach(fp.etc, warn=FALSE)

})
}

# vim: ft=r


-- 
François Pinard   http://pinard.progiciels-bpi.ca

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


Re: [R] A question about R environment

2007-01-08 Thread Philippe Grosjean
Please, don't reinvent the wheel: putting functions in a dedicated 
environment is one of the things done by R packages (together with a 
good documentation of the function, and making them easily installable 
on any R implementation). So, this is probably the time for you to read 
the Writing R extensions manual, and to start implementing your own R 
package!
Best,

Philippe Grosjean

François Pinard wrote:
 [Tong Wang]
 
 I created environment mytoolbox by : mytoolbox - 
 new.env(parent=baseenv()).  Is there anyway I put it in the search 
 path?  In a project, I often write some small functions, and load them 
 into my workspace directly, so when I list the objects with ls(), it 
 looks pretty messy.  So I am wondering if it is possible to creat an 
 environment, and put these tools into this environment.  For example, 
 I have functions fun1(), fun2() ... and creat an environment mytoolbox 
 which contains all these functions.  And it should be somewhere in the 
 search path:  .GlobalEnv mytoolbox package:methods.
 
 Here is a trick, shown as a fairly simplified copy of my ~/.Rprofile.  
 It allows for a few simple functions always available, yet without 
 having to create a package, and leaving ls() and any later .RData file 
 unencumbered.
 
 The idea is to use local() to prevent any unwanted clutter to leak out 
 (my real ~/.Rprofile holds more than shown below and use temporary 
 variables), to initialise a list meant to hold a bunch of functions or 
 other R things, and to save that list on the search path.
 
 This example also demonstrate a few useful functions for when I read the 
 R mailing list.  I often need to transfer part of emails containing
 code excerpts within the window where R executes, while removing 
 quotation marks, white lines and other noise.  I merely highlight-select 
 part of the message with the mouse, and then, within R, do things like:
 
xs()   source the highlighted region
xd()   read in a data.frame
xm()   read in a matrix
xe()   evaluate and print an expression
xv()   read a list of values as a vector
 
 The list above in decreasing order of usefulness (for me).  Except for 
 xs(), which has no automatic printout, you may either let the others 
 print what they got, or assign their value to some variable.  Arguments 
 are also possible, for example like this:
 
xd(T)  read in a data.frame when the first line holds column names
 
 
 
 if (interactive()) {
 local({
 
 fp.etc - list()
 
 fp.etc$xsel.vector - function (...) {
 connexion - textConnection(xselection())
 on.exit(close(connexion))
 scan(connexion, ...)
 }
 fp.etc$xsel.dataframe - function (...) {
 connexion - textConnection(xselection())
 on.exit(close(connexion))
 read.table(connexion, ...)
 }
 fp.etc$xsel.matrix - function (...) {
 connexion - textConnection(xselection())
 on.exit(close(connexion))
 data.matrix(read.table(connexion, ...))
 }
 fp.etc$xsel.eval - function (...) {
 connexion - textConnection(xselection())
 on.exit(close(connexion))
 eval(parse(connexion, ...))
 }
 fp.etc$xsel.source - function (...) {
 connexion - textConnection(xselection())
 on.exit(close(connexion))
 source(connexion, ...)
 }
 
 fp.etc$xselection - function ()
 {
 lignes - suppressWarnings(readLines('clipboard'))
 lignes - lignes[lignes != '']
 stopifnot(length(lignes) != 0)
 marge - substr(lignes, 1, 1)
 while (all(marge %in% c('', '+', ':', '|'))
   || all(marge == ' ')) {
 lignes - substring(lignes, 2)
 marge - substr(lignes, 1, 1)
 }
 lignes
 }
 
 fp.etc$xv - fp.etc$xsel.vector
 fp.etc$xd - fp.etc$xsel.dataframe
 fp.etc$xm - fp.etc$xsel.matrix
 fp.etc$xe - fp.etc$xsel.eval
 fp.etc$xs - fp.etc$xsel.source
 
 attach(fp.etc, warn=FALSE)
 
 })
 }
 
 # vim: ft=r
 


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


Re: [R] A question about R environment

2007-01-08 Thread Henrik Bengtsson
sourceTo() in R.utils will allow you to source() a file into an environment.

/Henrik

On 1/9/07, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 Try this:

  e - new.env()
  e$f - function(x)x
  attach(e)
  search()
  [1] .GlobalEnve package:stats
  [4] package:graphics  package:grDevices package:utils
  [7] package:datasets  package:methods   Autoloads
 [10] package:base
  f
 function(x)x

 On 1/8/07, Tong Wang [EMAIL PROTECTED] wrote:
  Hi  all,
 
  I created environment  mytoolbox by :   mytoolbox - 
  new.env(parent=baseenv())
  Is there anyway I put it in the search path ?
 
  If you need some background :
   In a project, I often write some small functions,  and load them into my 
  workspace directly,   so when I list the objects
   with ls(), it looks pretty messy.  So I am wondering if it is possible to 
  creat an environment,  and put these tools into
   this environment.  For example,  I have functionsfun1(), fun2() .. 
 and creat an environment  mytoolbox  which
   contains all these functions.  And it should be somewhere in the search 
  path:   .GlobalEnvmytoolbox
  package:methods  
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
  and provide commented, minimal, self-contained, reproducible code.
 

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


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


Re: [R] Simple spectral analysis

2007-01-08 Thread Georg Hoermann
Peter Dalgaard wrote:
 Earl F. Glynn wrote:
   
 The defaults for detrending and tapering could be involved. Putting, 
 e.g., detrend=F gives me a spectrum with substantially higher 
 low-frequency components.
 
 But what was the problem in the first place?
 
understanding how this things work in R compared to other packages 8-)

Thanks a lot for the help. I will post the script when its ready
(an introduction for our biology students to time series, just 8 hours)

Georg



-- 
Georg Hoermann, Dep. of Hydrology, Ecology, Kiel University, Germany
+49/431/23761412, mo: +49/171/4995884, icq:348340729, skype: ghoermann

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


[R] no linear model with many objects

2007-01-08 Thread Zaphiris Abas
Hi  all,

Is any way to estimate the parameters of a curve, not manualy,  from many 
subsets of my dataset



[[alternative HTML version deleted]]

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


Re: [R] ACCESS/Office : connecting

2007-01-08 Thread Prof Brian Ripley
It is easy with package RODBC.

Connecting to databases is discussed in the 'R Data Import/Export' manual.

On Mon, 8 Jan 2007, Milton Cezar Ribeiro wrote:

  How can I connect to a ACCESS (.mdb) file? In fact, I would like to 
 connect to a blank file, write a data.frame as table and after that 
 INSERT records using some insert command.

  Kind regards,

  Miltinho
  Brazil

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

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


Re: [R] Simple spectral analysis

2007-01-08 Thread Petr Pikal
Hi

without beeing specific in spectrum analysis you will get frequencies 
and spectral densities fro spectrum()

From help page

An object of class spec, which is a list containing at least the 
following components: 

freq vector of frequencies at which the spectral density is 
estimated. (Possibly approximate Fourier frequencies.) The units are 
the reciprocal of cycles per unit time (and not per observation 
spacing): see Details below. 
spec Vector (for univariate series) or matrix (for multivariate 
series) of estimates of the spectral density at frequencies 
corresponding to freq. 

snip

This is the important part:

**The result is returned invisibly if plot is true.**

So if you call

spectrum(data) you will get plot but in case

sp - spectrum(data)

you will get also object sp which has above mentioned components. 
Actual periods are obtainable by

n/sp$freq

HTH
Petr

On 8 Jan 2007 at 17:12, Georg Hoermann wrote:

Date sent:  Mon, 08 Jan 2007 17:12:34 +0100
From:   Georg Hoermann [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Subject:[R] Simple spectral analysis

 Hello world,
 
 I am actually trying to transfer a lecture from Statistica to
 R and I ran into problems with spectral analysis, I think I
 just don't get it 8-(
 (The posting from FFT, frequs, magnitudes, phases from 2005
 did not enlighten me)
 
 As a starter for the students I have a 10year data set of air 
 temperature with daily values  and I try to
 get a periodogram where the annual period (365 days) should be clearly
 visible (in statistica I can get the frequencies and the period). I
 tried the spectrum() and pgram() functions, but did not find a way
 through... The final aim would be to get the periodogram (and the
 residuals from the reassembled data set...)
 
 Thanks and greetings,
 Georg
 
 The data set:
 
 air =
 read.csv(http://www.hydrology.uni-kiel.de/~schorsch/air_temp.csv;)
 airtemp = ts(T_air, start=c(1989,1), freq = 365) plot(airtemp)
 
 
 -- 
 Georg Hoermann, Dep. of Hydrology, Ecology, Kiel University, Germany
 +49/431/23761412, mo: +49/171/4995884, icq:348340729, skype: ghoermann
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.

Petr Pikal
[EMAIL PROTECTED]

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


Re: [R] no linear model with many objects

2007-01-08 Thread Petr Pikal
Hi

On 9 Jan 2007 at 9:17, Zaphiris Abas wrote:

From:   Zaphiris Abas [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Date sent:  Tue, 9 Jan 2007 09:17:50 +0200
Subject:[R] no linear model with many objects

 Hi  all,
 
 Is any way to estimate the parameters of a curve, not manualy,  from
 many subsets of my dataset

Most probably yes. But you probably meant *how*.
To continue questioning see.

 PLEASE do read the posting guide
 http://www.R-project.org/posting-guide.html and provide commented,
 minimal, self-contained, reproducible code.

Maybe you are looking for nlme.

HTH
Petr
Petr Pikal
[EMAIL PROTECTED]

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