Re: [R] several plots on several pages - bug in par(mfg())?

2007-08-17 Thread Rainer M. Krug
Greg Snow wrote:
 Oops, I read further down in your original post and see that you already
 knew about par(mfg=c(2,1)).  To get it to advance to page 2 for the 4th
 plot try calling plot.new() which should move you to the next page, then
 doing par(mfg=c(1,1)) should cause the next graph to be at the top.
 
 Hope this helps,
 

Thanks - I found plot.new() and it is working.

But: If the first plot command fails, par(mfg=c(2,1)) does NOT move to 
the second one - if you try the code below, you will see.

Is this a bug or am I doing something wrong?

## Set layout to three rows and only oine column
par( mfcol=c(3,1), oma=c(0,0,0,0), mar=c(4, 4, 2, 2) )

## First row
par(mfg=c(1,1))
try( plot(runif(ff)) ) ## plot fails due to something.

## Second row
par(mfg=c(2,1))
try( plot(runif(100)) ) ##actually is plotted in first row

## Third row
par(mfg=c(3,1))
plot(runif(1000))   ## plotted in third row


-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Plant Conservation Unit
Department of Botany
University of Cape Town
Rondebosch 7701
South Africa

Tel:+27 - (0)21 650 5776 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] several plots on several pages

2007-08-16 Thread Rainer M. Krug
Hi

  version
_
platform   i686-pc-linux-gnu
arch   i686
os linux-gnu
system i686, linux-gnu
status
major  2
minor  5.1
year   2007
month  06
day27
svn rev42083
language   R
version.string R version 2.5.1 (2007-06-27)



I want to create a pdf withe three graphs on a page and with two pages:

-
| 1 |
-
| 2 |
-
| 3 |
-

NEW PAGE

-
| 4 |
-
| 5 |
-
| 6 |
-

Graph 1 should ALWAYS be at that spot, graph two also, even if graph one 
produces an error when plotting (the area can be empty, but doesn't have 
to.)

I produced the foolowing code below, but I have a few problems:

1) how can I create a new page in the pdf?

2) how can I make sure that the second graph is in position 2 when graph 
one produces an error when plotting I(as in the example)? Everything 
works OK (for the firsat page) when graph one is plotted.

I have the feeling, that I am thinking to complicated.

Any help welcome,

Rainer


pdf(test.pdf)
try(
 {
 ## Set layout to three rows and only oine column
 par( mfcol=c(3,1), oma=c(0,0,0,0), mar=c(4, 4, 2, 2) )

 ## First row
 par(mfg=c(1,1))
 try( plot(runif(ff)) )

 ## Second row
 par(mfg=c(2,1))
 try( plot(runif(100)) )

 ## Third row
 par(mfg=c(3,1))
 plot(runif(1000))


 ## THE NEXT THREE SHOULD BE ON A NEW PAGE IN THE PDF

 ## Set layout to three rows and only oine column
 par( mfcol=c(3,1), oma=c(0,0,0,0), mar=c(4, 4, 2, 2) )

 ## First row
 par(mfg=c(1,1))
 try( plot(runif(ff)) )

 ## Second row
 par(mfg=c(2,1))
 try( plot(runif(100)) )

 ## Third row
 par(mfg=c(3,1))
 plot(runif(1000))

 }
 )
dev.off()


-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Plant Conservation Unit
Department of Botany
University of Cape Town
Rondebosch 7701
South Africa

Tel:+27 - (0)21 650 5776 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] several plots on several pages

2007-08-16 Thread Rainer M. Krug
Hi Thierry

ONKELINX, Thierry wrote:
 Dear Rainer,
 
 Have you considered using Sweave?

No - and I am sure it will do what I want, but I guess it might be an 
overkill. These arew just draft outputs for myself for different 
datasets which should be easy to compare. SO I guess that Sweave might 
be an overkill (especially as I found plot.new() which jumpd to a new page).

Thanks and I will keep it in mind for the future,

Rainer


 
 HTH,
 
 Thierry
 
 
 
 ir. Thierry Onkelinx
 Instituut voor natuur- en bosonderzoek / Research Institute for Nature
 and Forest
 Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
 methodology and quality assurance
 Gaverstraat 4
 9500 Geraardsbergen
 Belgium
 tel. + 32 54/436 185
 [EMAIL PROTECTED]
 www.inbo.be 
 
 Do not put your faith in what statistics say until you have carefully
 considered what they do not say.  ~William W. Watt
 A statistical analysis, properly conducted, is a delicate dissection of
 uncertainties, a surgery of suppositions. ~M.J.Moroney
 
  
 
 -Oorspronkelijk bericht-
 Van: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] Namens Rainer M. Krug
 Verzonden: donderdag 16 augustus 2007 14:58
 Aan: r-help
 Onderwerp: [R] several plots on several pages

 Hi

   version
 _
 platform   i686-pc-linux-gnu
 arch   i686
 os linux-gnu
 system i686, linux-gnu
 status
 major  2
 minor  5.1
 year   2007
 month  06
 day27
 svn rev42083
 language   R
 version.string R version 2.5.1 (2007-06-27)



 I want to create a pdf withe three graphs on a page and with 
 two pages:

 -
 | 1 |
 -
 | 2 |
 -
 | 3 |
 -

 NEW PAGE

 -
 | 4 |
 -
 | 5 |
 -
 | 6 |
 -

 Graph 1 should ALWAYS be at that spot, graph two also, even 
 if graph one produces an error when plotting (the area can be 
 empty, but doesn't have
 to.)

 I produced the foolowing code below, but I have a few problems:

 1) how can I create a new page in the pdf?

 2) how can I make sure that the second graph is in position 2 
 when graph one produces an error when plotting I(as in the 
 example)? Everything works OK (for the firsat page) when 
 graph one is plotted.

 I have the feeling, that I am thinking to complicated.

 Any help welcome,

 Rainer


 pdf(test.pdf)
 try(
  {
  ## Set layout to three rows and only oine column
  par( mfcol=c(3,1), oma=c(0,0,0,0), mar=c(4, 4, 2, 2) )

  ## First row
  par(mfg=c(1,1))
  try( plot(runif(ff)) )

  ## Second row
  par(mfg=c(2,1))
  try( plot(runif(100)) )

  ## Third row
  par(mfg=c(3,1))
  plot(runif(1000))


  ## THE NEXT THREE SHOULD BE ON A NEW PAGE IN THE PDF

  ## Set layout to three rows and only oine column
  par( mfcol=c(3,1), oma=c(0,0,0,0), mar=c(4, 4, 2, 2) )

  ## First row
  par(mfg=c(1,1))
  try( plot(runif(ff)) )

  ## Second row
  par(mfg=c(2,1))
  try( plot(runif(100)) )

  ## Third row
  par(mfg=c(3,1))
  plot(runif(1000))

  }
  )
 dev.off()


 --
 NEW EMAIL ADDRESS AND ADDRESS:

 [EMAIL PROTECTED]

 [EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

 Plant Conservation Unit
 Department of Botany
 University of Cape Town
 Rondebosch 7701
 South Africa

 Tel: +27 - (0)21 650 5776 (w)
 Fax: +27 - (0)86 516 2782
 Fax: +27 - (0)21 650 2440 (w)
 Cell:+27 - (0)83 9479 042

 Skype:   RMkrug

 email:   [EMAIL PROTECTED]
  [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.



-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Plant Conservation Unit
Department of Botany
University of Cape Town
Rondebosch 7701
South Africa

Tel:+27 - (0)21 650 5776 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] Generating vetor (shapefiles) from AscGrid raster in R

2007-06-22 Thread Rainer M. Krug
What about using grass 6, combined with spgrass6 and the command r.to.vect?

Rainer

Milton Cezar Ribeiro wrote:
 Hi there,
 
 I need to convert a raster (ascGrid) format to Shape files.
 Is there a way of to do that on R?
 
 Kind regards
 
 miltinho
 
 

 
 
 http://yahoo.com.br/oqueeuganhocomisso 
   [[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] make sample() faster

2007-06-14 Thread Rainer M. Krug
Hi

I have a simulation which is relatively slow. I used Rprofile() and 
identified the calls to sample() as the culprit is sample():

  summaryRprof(Documents/PostDoc/Aloe_Pillansii/R/create.out)
$by.self
   self.time self.pct total.time total.pct
sample   1.30 44.2   1.52  51.7
ifelse   0.46 15.6   2.44  83.0
.
.
.

I am using sample() as follow:
result - sample(
  x=d.growth.seedling$growth,
  size=1,
  prob=d.growth.seedling$p,
  replace
  )

d.growth.seedling$p and d.growth.seedling$growth have a length of 1024 
and are calculated initially by using density().

My question: is there any way to make this faster, i.e. replace sample() 
as I use it with another faster algorithm (if necessary implemented in C)?

Thanks in advance,

Rainer

-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] make sample() faster

2007-06-14 Thread Rainer M. Krug
Thanks for the info - so the solution would (likely) be to draw several 
samples and use these whenever I need a new one.

tHANKS, i'LL TRY IT OUT,

rAINER

P.S: somebody said once that the caps-lock key is the most useless key 
on the keyboard and he is right...


Prof Brian Ripley wrote:
 I think the problem is not sample (which is written in C), but that you 
 are calling it with size=1.  Taking one sample with probabilities from a 
 large discrete distribution is necessarily slow, but you can take a large 
 sample for little more cost.
 
 On Thu, 14 Jun 2007, Rainer M. Krug wrote:
 
 Hi

 I have a simulation which is relatively slow. I used Rprofile() and
 identified the calls to sample() as the culprit is sample():

 summaryRprof(Documents/PostDoc/Aloe_Pillansii/R/create.out)
 $by.self
   self.time self.pct total.time total.pct
 sample   1.30 44.2   1.52  51.7
 ifelse   0.46 15.6   2.44  83.0
 .
 .
 .

 I am using sample() as follow:
 result - sample(
  x=d.growth.seedling$growth,
  size=1,
  prob=d.growth.seedling$p,
  replace
  )

 d.growth.seedling$p and d.growth.seedling$growth have a length of 1024
 and are calculated initially by using density().

 My question: is there any way to make this faster, i.e. replace sample()
 as I use it with another faster algorithm (if necessary implemented in C)?

 Thanks in advance,

 Rainer


 


-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] Where to find nprq?

2007-05-29 Thread Rainer M. Krug
roger koenker wrote:
 It has been folded into my quantreg package.
Thanks a lot - it is working now

Rainer


 
 url:www.econ.uiuc.edu/~rogerRoger Koenker
 email[EMAIL PROTECTED]Department of Economics
 vox: 217-333-4558University of Illinois
 fax:   217-244-6678Champaign, IL 61820
 
 
 On May 28, 2007, at 4:32 AM, Rainer M. Krug wrote:
 
 Hi

 I am trying to install the package pheno, but it needs the package
 nprq by Roger Koenker et al. which I can I find this package? It does
 not seem to be on CRAN and googling also doesn't give me an URL - is it
 still somewhere available?

 Thanks,

 Rainer


 -- 
 NEW EMAIL ADDRESS AND ADDRESS:

 [EMAIL PROTECTED]

 [EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
 Biology (UCT)

 Leslie Hill Institute for Plant Conservation
 University of Cape Town
 Rondebosch 7701
 South Africa

 Fax:+27 - (0)86 516 2782
 Fax:+27 - (0)21 650 2440 (w)
 Cell:+27 - (0)83 9479 042

 Skype:RMkrug

 email:[EMAIL PROTECTED]
[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.
 


-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] Where to find nprq?

2007-05-28 Thread Rainer M. Krug
Hi

I am trying to install the package pheno, but it needs the package 
nprq by Roger Koenker et al. which I can I find this package? It does 
not seem to be on CRAN and googling also doesn't give me an URL - is it 
still somewhere available?

Thanks,

Rainer


-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] Question concerning pastecs package

2007-05-25 Thread Rainer M. Krug
Dear Philippe

Thanks a lot for your information - it is extremely usefull

Rainer


Philippe Grosjean wrote:
 Hello,
 
 I already answered privately to your question. No, there is no 
 translation of pastecs.pdf. The English documentation is accessible, as 
 usual, by:
 
 ?turnpoints
 
 Regarding your specific question, 'info' is the quantity of information 
 I associated with the turning points:
 
 I = -log2 P(t)
 
 where P is the probability to observe a turning point at time t under 
 the null hypothesis that the time series is purely random, and thus, the 
 distribution of turning points follows a normal distribution with:
 
 E(p) = 2/3*(n-2)
 var(p) = (16*n - 29)/90
 
 with p, the number of observed turning points and n the number of 
 observations. Ibanez (1982, in French, sorry... not my fault!) 
 demonstrated that P(t) is:
 
 P(t) = 2*(1/n(t-1)! * (n-1)!)
 
 As you can easily imagine, from this point on, it is straightforward to 
 construct a test to determine if the series is random (regarding the 
 distribution of the turning points), more or less monotonic (more or 
 less turning points than expected), See also the ref cited in the online 
 help (Kendall 1976).
 
 References:
 ---
 Ibanez, F., 1982. Sur une nouvelle application de la théorie de 
 l'information à la description des séries chronologiques planctoniques. 
 J. Exp. Mar. Biol. Ecol., 4:619-632
 
 Kendall, M.G., 1976. Time-series, 2nd ed. Charles Griffin  Co, London
 
 Best,
 
 Philippe Grosjean
 
 ..°}))
  ) ) ) ) )
 ( ( ( ( (Prof. Philippe Grosjean
  ) ) ) ) )
 ( ( ( ( (Numerical Ecology of Aquatic Systems
  ) ) ) ) )   Mons-Hainaut University, Belgium
 ( ( ( ( (
 ..
 
 Rainer M. Krug wrote:
 Hi

 I just installed the pastecs package and I am wondering: is there an 
 english (or german) translation of the file pastecs.pdf? If not, is 
 there an explanation somewhere of the object of type 'turnpoints' as a 
 result of turnpoints(), especially the info field?

 Thanks,

 Rainer



-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] Question concerning pastecs package

2007-05-24 Thread Rainer M. Krug
Hi

I just installed the pastecs package and I am wondering: is there an 
english (or german) translation of the file pastecs.pdf? If not, is 
there an explanation somewhere of the object of type 'turnpoints' as a 
result of turnpoints(), especially the info field?

Thanks,

Rainer

-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] Identifying last record in individual growth data over different time intervalls

2007-03-05 Thread Rainer M. Krug
Hi

I have a plist t which contains size measurements of individual plants, 
identified by the field plate. It contains, among other, a field 
year indicating the year in which the individual was measured and the 
height. The number of measurements range from 1 to 4 measurements in 
different years.
My problem is that I would need the LAST measurement. I only came up 
with the solution below which is probably way to complicated, but I 
can't think of another solution.

Does anybody has an idea how to do this more effectively?

Finally I would like to have a data.frame t2 which only contains the 
entries of the last measurements.

Thanks in advance,

Rainer



  unlist(
sapply(
split(t, t$plate),
function(i)
{
i[i$year==max(i$year),]$id
}
)
)

  15  20  33  43  44  47  64 D72S200 
S201
2006001 2006003 2006005 2006007 2006008 2006009 2006014 2006015 2006016 
2006017
S202S203S204S205S206S207S208S209S210 
S211
2004095 2006019 2006020 2006021 2006022 2006023 2006024 2006025 2006026 
2006027
S212S213S214S215S216S217S218S219S220 
S222
2006028 2006029 2006030 2006031 2006032 2006033 2006034 2006035 2006036 
2006037
S223S224S225S226S227S228S229S230S231 
S232
2006038 2006039 2006040 2006041 2006042 2006043 2006044 2006045 2006046 
2006047
 
  t
  id plate year height
2004007 200400715 2004   0.40
2005024 200502415 2005   0.43
2006001 200600115 2006   0.44
2004012 200401220 2004   0.90
2005026 200502620 2005   0.94
2006003 200600320 2006   0.98
2004025 200402533 2004   0.15
2005027 200502733 2005   0.15
2006005 200600533 2006   0.16
2004035 200403543 2004   0.26
2005038 200503843 2005   0.30
2006007 200600743 2006   0.38
2004036 200403644 2004   0.32
2005030 200503044 2005   0.39
2006008 200600844 2006   0.46
2004039 200403947 2004   0.50
2005025 200502547 2005   0.55
2006009 200600947 2006   0.63
2004055 200405564 2004   0.45
2005029 200502964 2005   0.58
2006014 200601464 2006   0.67
2006015 2006015   D72 2006   0.30
2004093 2004093  S200 2004   0.68
2005040 2005040  S200 2005   0.74
2006016 2006016  S200 2006   0.84
2004094 2004094  S201 2004   0.46
2005041 2005041  S201 2005   0.49
2006017 2006017  S201 2006   0.53
2004095 2004095  S202 2004   0.17
2004096 2004096  S203 2004   0.23
2005032 2005032  S203 2005   0.23
2006019 2006019  S203 2006   0.23
2004097 2004097  S204 2004   0.25
2005031 2005031  S204 2005   0.29
2006020 2006020  S204 2006   0.41
2004098 2004098  S205 2004   0.22
2005039 2005039  S205 2005   0.26
2006021 2006021  S205 2006   0.37
2004099 2004099  S206 2004   0.19
2005035 2005035  S206 2005   0.25
2006022 2006022  S206 2006   0.37
2004100 2004100  S207 2004   0.29
2005003 2005003  S207 2005   0.36
2006023 2006023  S207 2006   0.41
2004101 2004101  S208 2004   0.17
2005005 2005005  S208 2005   0.20
2006024 2006024  S208 2006   0.16
2004102 2004102  S209 2004   0.16
2005008 2005008  S209 2005   0.19
2006025 2006025  S209 2006   0.24
2004103 2004103  S210 2004   0.09
2005007 2005007  S210 2005   0.14
2006026 2006026  S210 2006   0.15
2004104 2004104  S211 2004   0.12
2005006 2005006  S211 2005   0.12
2006027 2006027  S211 2006   0.22
2004105 2004105  S212 2004   0.61
2005011 2005011  S212 2005   0.71
2006028 2006028  S212 2006   0.81
2004106 2004106  S213 2004   0.28
2005010 2005010  S213 2005   0.37
2006029 2006029  S213 2006   0.44
2004107 2004107  S214 2004   0.47
2005009 2005009  S214 2005   0.59
2006030 2006030  S214 2006   0.67
2004108 2004108  S215 2004   0.43
2005004 2005004  S215 2005   0.53
2006031 2006031  S215 2006   0.66
2004109 2004109  S216 2004   0.35
2005019 2005019  S216 2005   0.38
2006032 2006032  S216 2006   0.41
2004110 2004110  S217 2004   0.20
2005018 2005018  S217 2005   0.21
2006033 2006033  S217 2006   0.32
2004111 2004111  S218 2004   0.19
2005014 2005014  S218 2005   0.21
2006034 2006034  S218 2006   0.27
2004112 2004112  S219 2004   0.21
2005034 2005034  S219 2005   0.24
2006035 2006035  S219 2006   0.24
2004113 2004113  S220 2004   0.19
2005021 2005021  S220 2005   0.19
2006036 2006036  S220 2006   0.25
2004114 2004114  S222 2004   0.34
2005020 2005020  S222 2005   0.35
2006037 2006037  S222 2006   0.46
2005013 2005013  S223 2005   0.04
2006038 2006038  S223 2006   0.04
2005012 2005012  S224 2005   0.13
2006039 2006039  S224 2006   0.14
-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell

Re: [R] Identifying last record in individual growth data over different time intervalls

2007-03-05 Thread Rainer M. Krug
Hi

jim holtman wrote:
 What is wrong with the method that you have?  It looks reasonable

Actually there is nothing wrong with the approach I am using - it just
seemed to be quite complicated and I assumed that there is an easier
approach around.

The dataset is not that large that I really have to worry about efficiency.

Thanks a lot ,

Rainer


 efficient.  As with other languages, there are always other ways of doing
 it.  Here is another to consider, but it is basically the same:
 
 sapply(split(t, t$plate), function(x) x$id[which.max(x$year)])
  15  20  33  43  44  47  64 D72S200
 S201S202S203S204
 2006001 2006003 2006005 2006007 2006008 2006009 2006014 2006015 2006016
 2006017 2004095 2006019 2006020
S205S206S207S208S209S210S211S212S213
 S214S215S216S217
 2006021 2006022 2006023 2006024 2006025 2006026 2006027 2006028 2006029
 2006030 2006031 2006032 2006033
S218S219S220S222S223S224
 2006034 2006035 2006036 2006037 2006038 2006039
 
 
 
 On 3/5/07, Rainer M. Krug [EMAIL PROTECTED] wrote:
 Hi

 I have a plist t which contains size measurements of individual plants,
 identified by the field plate. It contains, among other, a field
 year indicating the year in which the individual was measured and the
 height. The number of measurements range from 1 to 4 measurements in
 different years.
 My problem is that I would need the LAST measurement. I only came up
 with the solution below which is probably way to complicated, but I
 can't think of another solution.

 Does anybody has an idea how to do this more effectively?

 Finally I would like to have a data.frame t2 which only contains the
 entries of the last measurements.

 Thanks in advance,

 Rainer



-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] Identifying last record in individual growth data over different time intervalls

2007-03-05 Thread Rainer M. Krug
Hi Chris

Chris Stubben wrote:
 Finally I would like to have a data.frame t2 which only contains the 
 entries of the last measurements.

 
 You could also use aggregate to get the max year per plate then join that back
 to the original dataframe using merge on year and plate (common columns in 
 both
 dataframes).
 

Thanks for the idea to use aggregate and merge - as I like SQL, this 
seems to be a nice approach.

Rainer

 
 
 x-data.frame(id=(1:8), plate=c(15,15,15,20,20,33,43,43),
 year=c(2004,2005,2006,2004,2005,2004,2005,2006), 
 height=c(0.40,0.43,0.44,0.90,0.94,0.15,0.30,0.38))
 
 merge(x, aggregate(list(year=x$year), list(plate=x$plate), max))
 
 
   plate year id height
 115 2006  3   0.44
 220 2005  5   0.94
 333 2004  6   0.15
 443 2006  8   0.38
 
 __
 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.


-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] Question concerning survival analysis

2007-02-23 Thread Rainer M. Krug
Hi

I have a data set consisting of pictures on which individual plants were
identified and categorized into alive, dead and unknown if it was
not clear. The time of these pictures ranges from 1937 to today and the
intervals range between 13 and 1 year.

I am trying to get an understanding of the mortality rate which I can
then use in an individual based model.

Therefore I thought of using survival analysis. I have ordered my data
in the required format, and classified the events as interval censored
(event=3) for the cases where the plant died and right censored
(event=0) but I have still a problem

I managed to obtain a Surv() object by calling

 surv - with(survival, Surv(time, time2, event, type=interval))

where survival is my dataset

 surv
  [1] [13, 16] 68+  16+  68+  68+  68+  [26, 34] 68+

  [9] 68+  16+  [54, 58] [64, 67] 68+  [34, 54] [34, 54]
[58, 63]
[17] [48, 58] [48, 63] [34, 54]

And it looks correct (I set the year 1937 to 0)

But where to from here? I understand that most of the analysis can not
be done with interval censored data? As far as I understand it, I have
to use interval censored as the observation intervals are not equal and
in addition quite large.

The data is from one site, no interference.

As I said, I would like to have an estimate of the hazard function (I
guess) to get information about the mortality rate of the individuals.

Any help welcome,

Rainer




-- 
NEW EMAIL ADDRESS AND ADDRESS:

[EMAIL PROTECTED]

[EMAIL PROTECTED] WILL BE DISCONTINUED END OF MARCH

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 650 2440 (w)
Cell:   +27 - (0)83 9479 042

Skype:  RMkrug

email:  [EMAIL PROTECTED]
[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] R Mailing list in Cape Town - South Africa

2007-02-23 Thread Rainer M. Krug
Hi

I hope that I don't break any rules -

I just want to announce that we started a mailing list for R in Cape 
Town. The address is:

https://cbio.uct.ac.za/mailman/listinfo/sabior

The basic idea of the mailing list is to bring R users in the region 
around Cape Town and in South Africa closer together and probably 
arrange informal gettogethers.

We also try to provide a forum to discuss issues concerning R in Biology 
and distribute announcements of R courses and similar events in the Cape 
Town area.

We definitely do not want to establish an alternative forum to the 
official R lists and do not want to draw subscribers away from them - it 
is a huge advantage that one large list provides the main forum to get help.

I hope that the new mailing list will be a useful medium to spread the 
word and information about R in South Africa,

Rainer

-- 
[EMAIL PROTECTED]
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Leslie Hill Institute for Plant Conservation
University of Cape Town
Rondebosch 7701
South Africa

__
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] Start and Restart R over SSH

2007-02-19 Thread Rainer M Krug
Douglas Bates wrote:
 On 2/19/07, Nils Höller [EMAIL PROTECTED] wrote:
 Hi,

 I have some big calculations in R to be done.
 Since I can use R on a server with ssh, i was wondering if I can reopen
 a R Shell after exiting ssh.

 I don't want to use the batch mode and nohup doesn't work.

 I want to use something like
 ssh [EMAIL PROTECTED]
 R
 ---do something in R and start calculation ---
 close ssh but let R remain on the server, doing the calculation

 ssh [EMAIL PROTECTED]
 open the existing R Shell / Process

 Has anyone done something similiar?
 Can you help me or suggest an other solution ?
 
 I don't think it is possible to reattach to a process started in one
 ssh session from another ssh session.  However, you can put a session

No, it is. Check out the screen command - it is backgrounding your 
session, you can have several running at the same time and reattach and 
they persist between logouts (obviously, if you switch the computer of, 
it is gone...)

Rainer

 into the background with the -f flag to ssh.  You haven't told us what
 operating system you are starting the ssh connection on and what
 system will run the R process.  If I had an X server running on the
 local system and the remote system provided X clients like xterm I
 would do this by
 
 ssh -X -f [EMAIL PROTECTED] xterm
 
 This should spring up an autonomous xterm window on the local machine
 after which you can run R in it.
 
 I hope this helps.
 
 __
 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.


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] How do I create an object in the Global environment from a function

2006-12-14 Thread Rainer M Krug
[EMAIL PROTECTED] wrote:
 Hi all, 
 
 Say I have created an object b in my function 
 
 myfunc - function() b - 34

myfunc - function() b - 34
  -

Rainer

 
 How can I make b an object in the Global environment and not just in the 
 environment of myfunc? 
 
 Thanks, 
 
 Tim
 
 __
 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.


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] loop is going to take 26 hours - needs to be quicker!

2006-12-14 Thread Rainer M Krug
Jenny Barnes wrote:
 Dear R-help,
 
 I have a loop, which is set to take about 26 hours to run at the rate it's 
 going 
 - this is ridiculous and I really need your help to find a more efficient way 
 of 
 loading up my array gpcc.array:
 
 #My data is stored in a table format with all the data in one long column 
 #running though every longitute, for every latitude, for every year. The 
 #original data is sotred as gpcc.data2 where dim(gpcc.data2) = [476928,5] 
 where 
 #the 5th column is the data:
 
 #make the array in the format I need [longitude,latitude,years]
 
 gpcc.array - array(NA, c(144,72,46)) 
 
 n=0
 for(k in 1:46){
 for(j in 1:72){
 for(i in 1:144){
 n - n+1
 gpcc.array[i,j,k] - gpcc.data2[n,5]
 print(j)
 }
 }
 }

I don't know if it is faster - but adding three columns to qpcc.data, 
one for longitude, one for lattitude and one for year (using rep() as 
they are in sequence) and the using reshape() might be faster?


 
 So it runs through all the longs for every lat for every year - which is the 
 order the data is running down the column in gpcc.data2 so n increses by 1 
 each 
 time and each data point is pulled off
 
 It needs to be a lot quicker, I'd appreciate any ideas!
 
 Many thanks for taking time to read this,
 
 Jenny Barnes
 
 ~~
 Jennifer Barnes
 PhD student - long range drought prediction
 Climate Extremes
 Department of Space and Climate Physics
 University College London
 Holmbury St Mary, Dorking
 Surrey
 RH5 6NT
 01483 204149
 07916 139187
 Web: http://climate.mssl.ucl.ac.uk
 
 __
 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.


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] loop is going to take 26 hours - needs to be quicker!

2006-12-14 Thread Rainer M Krug
David Barron wrote:
 What about
 
 gpcc.array - array(gpcc.data2[,5], dim=c(144,72,46))

I guess this will be slightly faster then my suggestion :-) ?

 
 On 14/12/06, Rainer M Krug [EMAIL PROTECTED] wrote:
 Jenny Barnes wrote:
  Dear R-help,
 
  I have a loop, which is set to take about 26 hours to run at the 
 rate it's going
  - this is ridiculous and I really need your help to find a more 
 efficient way of
  loading up my array gpcc.array:
 
  #My data is stored in a table format with all the data in one long 
 column
  #running though every longitute, for every latitude, for every year. 
 The
  #original data is sotred as gpcc.data2 where dim(gpcc.data2) = 
 [476928,5] where
  #the 5th column is the data:
 
  #make the array in the format I need [longitude,latitude,years]
 
  gpcc.array - array(NA, c(144,72,46))
 
  n=0
  for(k in 1:46){
  for(j in 1:72){
  for(i in 1:144){
  n - n+1
  gpcc.array[i,j,k] - gpcc.data2[n,5]
  print(j)
  }
  }
  }

 I don't know if it is faster - but adding three columns to qpcc.data,
 one for longitude, one for lattitude and one for year (using rep() as
 they are in sequence) and the using reshape() might be faster?


 
  So it runs through all the longs for every lat for every year - 
 which is the
  order the data is running down the column in gpcc.data2 so n 
 increses by 1 each
  time and each data point is pulled off
 
  It needs to be a lot quicker, I'd appreciate any ideas!
 
  Many thanks for taking time to read this,
 
  Jenny Barnes
 


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] exporting a table to latex

2006-12-13 Thread Rainer M Krug
Dieter Menne wrote:
 Rainer M Krug RKrug at sun.ac.za writes:
 
 I am using the latex() command from the Hmisc package to export  table 
 to latex. For formating of the values, I use the format() function. But 
 I don't manage to get the format of the values right: I don't want 
 scientific notation, but if I say scientific=FALSE, I get many digits 
 after the decimal point which I can not control with digits=... and 
 nsmall=... in the format command.

 Is there another way of formating the values to three decimal digits?

 Or another way of exporting them to LaTeX?
 
 There were a few bugs in the current versions of format.df (called by latex),
 and the scientific problem could have been among them.
 
 Try to download latex.s from 
 
 http://biostat.mc.vanderbilt.edu/svn/R/Hmisc/branches/release_3.2-1/R/latex.s
 
 do 
 
 library(Hmisc)
 source(latex.s)
Thanks - I did it but it still doesn't work.

I should have mentioned that I am using the function format() from the 
base package to create a data.frame which I then give to latex() to 
export - without formating from latex(). I am not using the format 
functions of the Hmisc package as I read that there are problems with them.

Rainer



 
 and check if the problem disappears. If it does, write a mail to 
 [charles.dupont
 at vanderbilt.edu] and ask him to make the version public as soon as possible.
 
 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.


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] exporting a table to latex

2006-12-13 Thread Rainer M Krug
Rau, Roland wrote:
 Hi, 
 
 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of Rainer M Krug
 Sent: Wednesday, December 13, 2006 8:47 AM
 To: r-help@stat.math.ethz.ch
 Subject: [R] exporting a table to latex
 
 Is there another way of formating the values to three decimal digits?

 Or another way of exporting them to LaTeX?

 I hope I did not oversee any emails concerning your question. Typically,

No, you didn't.

 I use the xtable-package. Please let me know if the following code is
 not doing what you hope for.

It's perfect. Doing exactly what I wanted it to do - Thanks a lot

Raienr
 
 Best,
 Roland
 
 
 mydata - data.frame(Category=LETTERS[1:10], Percentage=runif(10))
 
 library(xtable)
 
 xtable(mydata, digits=c(0,0,3)) ### LaTeX format = default
  you can even create an HTML table
 print(xtable(mydata, digits=c(0,0,5)), type=HTML)
 
 
 --
 This mail has been sent through the MPI for Demographic Research.  Should you 
 receive a mail that is apparently from a MPI user without this text 
 displayed, then the address has most likely been faked. If you are uncertain 
 about the validity of this message, please check the mail header or ask your 
 system administrator for assistance.
 


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] exporting a table to latex

2006-12-12 Thread Rainer M Krug
Hi

I am using the latex() command from the Hmisc package to export  table 
to latex. For formating of the values, I use the format() function. But 
I don't manage to get the format of the values right: I don't want 
scientific notation, but if I say scientific=FALSE, I get many digits 
after the decimal point which I can not control with digits=... and 
nsmall=... in the format command.

Is there another way of formating the values to three decimal digits?

Or another way of exporting them to LaTeX?

Thanks

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] two ggplot and colour=x question

2006-12-11 Thread Rainer M Krug
Hi

I am using ggplot with the aesthetic=list(..., colour=x, ...)

ggplot()
ggline()

I have four different values in x (ren, cyn, mixed, bare) and I 
have two questions

1) I would like to assign specific colours to the values, i.e. green, 
red, blue and brown. How can I do this? I did not understand 
map_colour_brewer.

2) I don't want the legend top be plot. How can I disable the legend to 
be plotted?

Thanks

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] two ggplot and colour=x question

2006-12-11 Thread Rainer M Krug
Thanks a lot for your help - I'll try it out and let you know if I still 
have problems.

Rainer

hadley wickham wrote:
 I am using ggplot with the aesthetic=list(..., colour=x, ...)

 ggplot()
 ggline()

 I have four different values in x (ren, cyn, mixed, bare) and I
 have two questions

 1) I would like to assign specific colours to the values, i.e. green,
 red, blue and brown. How can I do this? I did not understand
 map_colour_brewer.
 
 There's not really an easy way to do this at the moment.  However, you
 can create a new variable containing the colours you want to use and
 then use a manual scale so they aren't converted automatically:
 
 df$colour - c(red,blue,yellow,orange)[df$myvar]
 p - ggplot(data=df, aes=list(x=x,y=y,colour=colour)
 scmanual(p, colour)
 
 2) I don't want the legend top be plot. How can I disable the legend to
 be plotted?
 
 If you use a manual scale (as above) there won't be a legend, or more
 generally you can do:
 
 p$legend.position - none
 to turn of the legend (see ?ggopt for other options)
 
 Hadley


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Calling R functions in Delphi

2006-12-04 Thread Rainer M Krug
Anna Belova wrote:
 Hello All,
 
 We would like to call quantile() function from the R-package STATS in a
 Delphi program. If this is possible, could anyone provide us with an
 example?

Hi Anna

There was a translation of the header files from C to Delphi, so that 
you could used R directly without using DCom - Hans-Peter Suter 
translated / made them.

I'll mail you the version which he send me off list.

Rainer

 
 Thanks in advance.
 
 --Anna
 -
 Anna Belova
 Abt Associates Inc.
 4800 Montgomery Ln, St 600
 Bethesda, MD-20814
 phone: 301-347-5304
 fax: 301-652-7530
 http://www.abtassociates.com/environment
 
 -
 This message may contain privileged and confidential informa...{{dropped}}
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] specify point shape for ggplot (equivalent to pch)?

2006-12-01 Thread Rainer M Krug
Hi

is it possible to specify the shape of the point to be used in ggplot 
(as with pch in plot)? I couldn't find anything in the help.

Thanks

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)86 516 2782
Fax:+27 - (0)21 808 3304 (w)
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Combining factors

2006-11-10 Thread Rainer M Krug
Hi

I know this is a basic question and I know I have done it before but I 
can't find the answer any more.

I have a data set, say:

F1, F2, Value

F1 and F2 are Factors.

I would like to plot

plot(TheCombinationOf(F1, F2), Value)

I remember there was a function for TheCombinationOf() but I don't 
remember the name.

I could create a new factor based on F1 and F2, but I would prefer the 
other soluytion.

Any help welcome,

Rainer


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Combining factors

2006-11-10 Thread Rainer M Krug
Peter Dalgaard wrote:
 Rainer M Krug [EMAIL PROTECTED] writes:
 
 Hi

 I know this is a basic question and I know I have done it before but I 
 can't find the answer any more.

 I have a data set, say:

 F1, F2, Value

 F1 and F2 are Factors.

 I would like to plot

 plot(TheCombinationOf(F1, F2), Value)

 I remember there was a function for TheCombinationOf() but I don't 
 remember the name.

 I could create a new factor based on F1 and F2, but I would prefer the 
 other soluytion.

 Any help welcome,
 
 F1:F2
 interaction(F1,F2)
 
 There are some differences so lookup the help page for the latter.
 

Thanks a lot

Rainer


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] error in format.df when using dec

2006-11-07 Thread Rainer M Krug
When using format.df with dec, the formating does not work (see code 
below).

Any help appreciated how I could do the formating (I want to export to 
LaTeX),

Rainer

I am using the newest version of Hmisc from CRAN, R version:

  version
_
platform   i686-pc-linux-gnu
arch   i686
os linux-gnu
system i686, linux-gnu
status
major  2
minor  4.0
year   2006
month  10
day03
svn rev39566
language   R
version.string R version 2.4.0 (2006-10-03)


  x - data.frame(a=c(1.12345812,2.225415478547775566), b=3:4)
  x$m - matrix(5:8,nrow=2)
  dim(x)
[1] 2 3
  x
  a b m.1 m.2
1 1.123458 3   5   7
2 2.225415 4   6   8
  format.df(x)
   a  b   m 1 m 2
1 1.123458 3 5 7
2 2.225415 4 6 8
attr(,col.just)
[1] r r r r
  format.df(x, dec=2)
   a   b   m 1 m 2
1 1.120 3 5 7
2 2.230 4 6 8
attr(,col.just)
[1] r r r r
 



-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Compare linear regressios for significant differences of the slopes

2006-11-03 Thread Rainer M Krug
Dieter Menne wrote:
 Rainer M Krug wrote:
 I have (8 measures * 96 groups) = 768 datasets for which I did linear
 regressions using lm().

Sorry for my (probably incorrect) usage of group and measure.

Here a (probably better) description of my design:

I ran 96 different simulations (spread of a species along a transect) 
over four generations, based on different parameter sets. These resulted 
in 96 results (groups). Now I have 8 different ways to describe the 
result of one simulation based on x individuals further away then 
distance d, where x is replaced by 1, 5, 10, 50, 100, 500, 1000 and 5000 
(measures). For each group / simulation, I did linear regressions for 
each measure

  lm.measure_1 - lm(distance ~ generation)
...

resulting in lm.measure_1 to lm.measure_8

Within each group (based on one simulation), I get a different slope for 
each measure.

What I want to know is if these resulting slopes differ within one group 
/ simulation.


 Now I want to compare the slopes for each of the 8 measures in each of 
 the 96 groups. As I understand , I can not use
 anova(lm1, ..., lm8)
 as the lm1 ... lm8 are based on different datasets.

 
 Instead of doing this in two steps, you would better use lme in package nlme 
 to
 test the hypothesis in one run. I don't understand the details of you design,
 but is looks like the oxboys example in Pinheiro/Bates (the book of nlme) 
 could
 give you a first starter.
 
 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.


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Compare linear regressios for significant differences of the slopes

2006-11-02 Thread Rainer M Krug
Hi

I haven't received any ideas yet - I just wanted to confirm if this is a 
simple question? Should I follow the idea of checking if slope +- stddev 
slope overlap?

Thanks,

Rainer

Rainer M Krug wrote:
 Hi
 
 I have (8 measures * 96 groups) = 768 datasets for which I did linear
 regressions using lm().
 
 Now I want to compare the slopes for each of the 8 measures in each of 
 the 96 groups. As I understand , I can not use
 anova(lm1, ..., lm8)
 as the lm1 ... lm8 are based on different datasets.
 
 I also read in previous discussions in this list, that I can see if the 
 slope +- stddev(slope) overlap, but this seems a long process for the 
 huge number of comparisons.
 
 Therefore my question: is there a way to compare the slopes of lm() 
 which are based on different datasets and what is the easiest way to do
 it for this large number of datasets?
 
 Thanks in advance for your help,
 
 Rainer
 


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Compare linear regressios for significant differences of the slopes

2006-11-01 Thread Rainer M Krug
Hi

I have (8 measures * 96 groups) = 768 datasets for which I did linear
regressions using lm().

Now I want to compare the slopes for each of the 8 measures in each of 
the 96 groups. As I understand , I can not use
 anova(lm1, ..., lm8)
as the lm1 ... lm8 are based on different datasets.

I also read in previous discussions in this list, that I can see if the 
slope +- stddev(slope) overlap, but this seems a long process for the 
huge number of comparisons.

Therefore my question: is there a way to compare the slopes of lm() 
which are based on different datasets and what is the easiest way to do
it for this large number of datasets?

Thanks in advance for your help,

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] simplification of code using stamp?

2006-10-26 Thread Rainer M Krug
hadley wickham wrote:
 I get the following, which is not what I am looking for.

   test[1:10,]
 expertxx seeds runvalue
 1  BW x001025   1 rsqs, slope, d.slope, intercept, d.intercept
 2  BW x001025   2 rsqs, slope, d.slope, intercept, d.intercept
 3  BW x001025   3 rsqs, slope, d.slope, intercept, d.intercept
 4  BW x001025   4 rsqs, slope, d.slope, intercept, d.intercept
 5  BW x001025   5 rsqs, slope, d.slope, intercept, d.intercept
 6  BW x001028   1 rsqs, slope, d.slope, intercept, d.intercept
 7  BW x001028   2 rsqs, slope, d.slope, intercept, d.intercept
 8  BW x001028   3 rsqs, slope, d.slope, intercept, d.intercept
 9  BW x001028   4 rsqs, slope, d.slope, intercept, d.intercept
 10 BW x001028   5 rsqs, slope, d.slope, intercept, d.intercept
 
 That's because stamp doesn't produce great output at the moment (have
 a look at the str(test) to see that you have a data frame containing a
 list of vectors)
 
 The following code should put it a more reasonable form:
 
 tidy - function(x) {
  bind - function(i) data.frame(x[i, -ncol(x),drop=FALSE], t(a$value[[i]]))
  l - lapply(1:nrow(x), bind)
  do.call(rbind.fill, l)
 }
 
 tidy(test)
Thanks Hadley - I'll look at the code.


 
 (but unless you provide a reproducible example I can't be sure that it
 works with your data)
 
 Regards,
 
 Hadley


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Error bars in ggplot?

2006-10-26 Thread Rainer M Krug
Hi

Is it possible to put error bars in ggplot? I couldn't find anything so far.

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Installation of RGrace

2006-10-26 Thread Rainer M Krug
Hi

I try to install RGrace, but always get the following error below.

Might it have to do that RGtk is not installed and where can I find it 
to install it?

I have GTK 1.2.10 installed.

My R version and platform:

  version
_
platform   i686-pc-linux-gnu
arch   i686
os linux-gnu
system i686, linux-gnu
status
major  2
minor  4.0
year   2006
month  10
day03
svn rev39566
language   R
version.string R version 2.4.0 (2006-10-03)


09:26:46 (1.32 MB/s) - 
`/tmp/RtmpDCW8km/downloaded_packages/RGrace_0.5-5.tar.gz' saved 
[164119/164119]

* Installing *source* package 'RGrace' ...
** libs
gcc -I/usr/lib/R/include -I/usr/lib/R/include -I/usr/include/gtk-1.2 
-I/usr/include/glib-1.2  -I/usr/lib/glib/include -I/usr/local/include 
  -fpic   -c gdk_draw.c -o gdk_draw.o
gdk_draw.c:3:21: error: gdk/gdk.h: No such file or directory
gdk_draw.c:4:21: error: gtk/gtk.h: No such file or directory
gdk_draw.c: In function ‘draw_rubber_box’:
gdk_draw.c:9: error: ‘GtkWidget’ undeclared (first use in this function)
gdk_draw.c:9: error: (Each undeclared identifier is reported only once
gdk_draw.c:9: error: for each function it appears in.)
gdk_draw.c:9: error: ‘drawing_widget’ undeclared (first use in this 
function)
gdk_draw.c:9: error: syntax error before ‘)’ token
gdk_draw.c:10: error: ‘GdkColor’ undeclared (first use in this function)
gdk_draw.c:11: error: ‘GdkGC’ undeclared (first use in this function)
gdk_draw.c:11: error: ‘gc1’ undeclared (first use in this function)
gdk_draw.c:12: error: ‘Color’ undeclared (first use in this function)
gdk_draw.c:17: error: ‘GDK_XOR’ undeclared (first use in this function)
gdk_draw.c:19: error: ‘GDK_LINE_SOLID’ undeclared (first use in this 
function)
gdk_draw.c:19: error: ‘GDK_CAP_PROJECTING’ undeclared (first use in this 
function)
gdk_draw.c:19: error: ‘GDK_JOIN_MITER’ undeclared (first use in this 
function)
gdk_draw.c:20: error: ‘GDK_SOLID’ undeclared (first use in this function)
make: *** [gdk_draw.o] Error 1
ERROR: compilation failed for package 'RGrace'
** Removing '/usr/lib/R/library/RGrace'





-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Error bars in ggplot?

2006-10-26 Thread Rainer M Krug
hadley wickham wrote:
 Is it possible to put error bars in ggplot? I couldn't find anything so far.
 
 Have a look at ggerrorbar.
Thanks - exactly what I was looking for. By the way - ggerrorbar is not 
mentioned in ?ggplot.

Rainer

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


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] simplification of code using stamp?

2006-10-25 Thread Rainer M Krug
Hi

I have the following code which I would like to simplify. Id does linear 
regressions and returns the r-squares, and the coefficients.
It runs slow, as it is doing the regressions for each - is it possible 
to get the values in a dataframe which looks as follow:

expert | xx | seeds | r.squared | slope | intercept

Thanks in advance,

Rainer


library(reshape)
rsqs - as.data.frame(
   stamp(
 tc.long,
 expert * xx * seeds ~ .,
 function(df) try( summary( lm(distance ~ 
generation, data=df))$r.squared, silent=TRUE )
 )
   )

slope - as.data.frame(
stamp(
  tc.long,
  expert * xx * seeds ~ .,
  function(df) try( summary( lm(distance ~ 
generation, data=df))$coefficients[2], silent=TRUE )
  )
)

d.slope - as.data.frame(
  stamp(
tc.long,
expert * xx * seeds ~ .,
function(df) try( summary( lm(distance ~ 
generation, data=df))$coefficients[4], silent=TRUE )
)
  )

intercept - as.data.frame(
stamp(
  tc.long,
  expert * xx * seeds ~ .,
  function(df) try( summary( lm(distance 
~ generation, data=df))$coefficients[1], silent=TRUE )
  )
)

d.intercept - as.data.frame(
  stamp(
tc.long,
expert * xx * seeds ~ .,
function(df) try( summary( 
lm(distance ~ generation, data=df))$coefficients[3], silent=TRUE )
)
  )

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] simplification of code using stamp?

2006-10-25 Thread Rainer M Krug
ONKELINX, Thierry wrote:
 Resending the function because of a typo in the result vector.
 
 function(df){
   fit - summary(lm(distance ~ generation, data=df))
   result - c(fit$r.squared, fit$coefficients[2],
 fit$coefficients[4],
 fit$coefficients[1], fit$coefficients[3])
   names(result) - c(rsqs, slope, d.slope, intercept,
 d.intercept),
 }

You are right - the problem is that it isd calculating the regressions 
five time. I implemented your code, and when I print the resulting 
data.frame from

test - as.data.frame(
   stamp(
 tc.long,
 expert * xx * seeds * run ~ .,
 function(df)
 {
   try(
   {
 fit - summary( lm(distance ~ 
generation, data=df) )
 result - c(fit$r.squared, 
fit$coefficients[2], fit$coefficients[4], fit$coefficients[1], 
fit$coefficients[3])
 names(result) - c(rsqs, slope, 
d.slope, intercept, d.intercept)
   },
   silent=TRUE
   )
 }
 )
   )

I get the following, which is not what I am looking for.

  test[1:10,]
expertxx seeds runvalue
1  BW x001025   1 rsqs, slope, d.slope, intercept, d.intercept
2  BW x001025   2 rsqs, slope, d.slope, intercept, d.intercept
3  BW x001025   3 rsqs, slope, d.slope, intercept, d.intercept
4  BW x001025   4 rsqs, slope, d.slope, intercept, d.intercept
5  BW x001025   5 rsqs, slope, d.slope, intercept, d.intercept
6  BW x001028   1 rsqs, slope, d.slope, intercept, d.intercept
7  BW x001028   2 rsqs, slope, d.slope, intercept, d.intercept
8  BW x001028   3 rsqs, slope, d.slope, intercept, d.intercept
9  BW x001028   4 rsqs, slope, d.slope, intercept, d.intercept
10 BW x001028   5 rsqs, slope, d.slope, intercept, d.intercept
 

 
 Cheers,
 
 Thierry
 
 -
 
 ir. Thierry Onkelinx
 
 Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature
 and Forest
 
 Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
 methodology and quality assurance
 
 Gaverstraat 4
 
 9500 Geraardsbergen
 
 Belgium
 
 tel. + 32 54/436 185
 
 [EMAIL PROTECTED]
 
 www.inbo.be 
 
  
 
 Do not put your faith in what statistics say until you have carefully
 considered what they do not say.  ~William W. Watt
 
 A statistical analysis, properly conducted, is a delicate dissection of
 uncertainties, a surgery of suppositions. ~M.J.Moroney
 
 
-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Question concerning ggplot

2006-10-24 Thread Rainer M Krug
Hi

I am using ggplot under R 2.4 / Linux.

When using
ggsmooth(method=lm)
is there a way to show the results of the separate linear regressions?

Thanks

Rainer



-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Question concerning ggplot

2006-10-24 Thread Rainer M Krug
hadley wickham wrote:
 When using
 ggsmooth(method=lm)
 is there a way to show the results of the separate linear regressions?
 
 Do you mean doing a seperate linear regression for each group in your
 data?  If so, have a look at ?gggroup for some examples of exactly
 that.

No.

I do the following:

  p - ggplot(cc, . ~ expert, aesthetic=list(y=x0050, x=generation))
  ggjitter(p)
  ggsmooth(method=lm)

And I get six columns in the graph, one for each expert and 
ggsmooth(method=lm) draws the linear regression lines into the graphs.
I would like to have the coefficients and the R-square values of the 
linear regressions to analyse them further and to print them in the graphs.



 
 Hadley


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Question concerning ggplot

2006-10-24 Thread Rainer M Krug
hadley wickham wrote:
  Do you mean doing a seperate linear regression for each group in your
  data?  If so, have a look at ?gggroup for some examples of exactly
  that.

 No.

 I do the following:

   p - ggplot(cc, . ~ expert, aesthetic=list(y=x0050, x=generation))
   ggjitter(p)
   ggsmooth(method=lm)

 And I get six columns in the graph, one for each expert and
 ggsmooth(method=lm) draws the linear regression lines into the graphs.
 I would like to have the coefficients and the R-square values of the
 linear regressions to analyse them further and to print them in the 
 graphs.
 
 Ok - In that case you have to do the regressions yourself and add the
 lines etc.  Maybe something along these lines:

Thanks a lot - I thought so. I'll take a look at your suggestions below 
and come back to you if I don't get it to work.

Rainer


 
 p - ggpoint(ggplot(mtcars, aes=list(x=wt, y=mpg), formula= . ~ cyl))
 
 models - stamp(mtcars, . ~ . | cyl, function(df) lm(mpg ~ wt, data=df))
 lapply(models, coef)
 sapply(models, function(x) summary(x)$r.squared)
 
 or
 rsqs - as.data.frame(stamp(mtcars, cyl ~ ., function(df)
 summary(lm(mpg ~ wt, data=df))$r.squared))
 rsqs$wt - 4
 rsqs$mpg - 32
 ggtext(p, data=rsqs, aes=list(label=value))
 
 But that doesn't work for some reason I don't understand yet (but I'm
 working on it)
 
 Hadley


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Question concerning ggplot

2006-10-24 Thread Rainer M Krug
hadley wickham wrote:
  rsqs - as.data.frame(stamp(mtcars, cyl ~ ., function(df)
  summary(lm(mpg ~ wt, data=df))$r.squared))
  rsqs$wt - 4
  rsqs$mpg - 32
  ggtext(p, data=rsqs, aes=list(label=value))
 
  But that doesn't work for some reason I don't understand yet (but I'm
  working on it)
 
 Ooops - I just had the wrong version of reshape installed.  It should
 work with the version available on cran.

Thanks again for the example - but I don't seem to be able to get it to 
work in my context:


  p - ggplot(tc, . ~ expert, aesthetic=list(y=x0050, x=generation))
  ggjitter(p)
  ggsmooth(method=lm)
  rsqs - as.data.frame( stamp( tc, expert ~ ., function(df) 
summary(lm(x0050 ~ generation, data=df))$r.squared))
  rsqs
   expert value
1 BW 0.9056925
2 DM 0.9280401
3 DR 0.8044774
4 JH 0.7531401
5   Mean 0.9452478
6 TG 0.8816820

  ggtext(data=rsqs,  aesthetics=list(label=value, x=1, y=8000))
Error in data.frame(data[, c(variables), drop = FALSE], result = 
data$value) :
arguments imply differing number of rows: 6, 0
 

Can you give me a hint what I am doing wrong?

Rainer

 
 Hadley


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Latex editor recommendations

2006-10-18 Thread Rainer M Krug
I use LyX ( http://www.lyx.org/ ) and I am happy with it - it's 
advantage is that one does not need to know LaTeX in detail to use it.

I only know it from Linux, but it is also available for Windows

Rainer



Stefan Grosse wrote:
 For LaTeX I use the winedt editor: http://www.winedt.com which is
 extremely powerful and there exists an add-on for the use with R (but I
 prefer using Tinn-R for R). Winedt is shareware, you have a trial period
 of 30 days. It has an affordable price and discount for academics if I
 remember correctly.
 
 A very good freeware is TeXnicCenter: http://www.texniccenter.org/
 
 There are many other editors being capable of LaTeX editing like Jedit
 (which has a LaTeX plugin), xemacs plus auctex and so on but the two
 mentioned are the LaTeX specialists and in my opinion easier to use.
 
 (PS if you look for a nice reference-library for the use with LaTeX
 Jabref is very good http://jabref.sourceforge.net/ free and works
 excellent together with winedt (inserts citation into winedt by
 mouse-click), has a connection to citeseer and medline for receiving
 citations, can import endnote libraries and so on and so forth)
 
 Tom Backer Johnsen schrieb:
 This question is not oriented towards R, but is posted here because I 
 have the impression that there are at least some Latex users among the 
 contributors.  The question is:  What editors for Latex are to be 
 recommended?  I have located one:

 http://www.latexeditor.org/

 What other alternatives are there?  I am (for the most part) using 
 Windows XP.

 Tom

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


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Piping commands from Kate to R in xterm (Linux)

2006-10-11 Thread Rainer M Krug
Hi

I don't know if this quaifies as an R question, but it relates to using R.

I use R under Linux and use Kate as my script editor. I would like to be 
able to pipe the selected block to an R instance which is in an xterm 
session (not the console in Kate!).

Is it possible to configure Kate that it sends the selection to a pipe 
which can be read from R (like in vim and eclipse)?

Has anybody done something like this with Kate?

Thanks a lot for your help,

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Update to Dillo browser question

2006-09-23 Thread Rainer M Krug

I start the html help with

  help.start(browser=dillo)

and all subsequent requests with ? open in dillo


Rainer

Dylan Beaudette wrote:
 hi,
 
 how exactly do you get R to open the page in dillo ... ?
 
 thanks!
 
 On Thursday 21 September 2006 23:54, Rainer M Krug wrote:
 Hi

 I asked about if there is any way of opening URLs from the help browser
 in the same window of the same dillo browser - here is the answer.

 Just to reiterate: dillo is for me the perfect browser for the help of R
 when you use ?...

 Rainer

  Original Message 
 Subject: Re: [Dillo-dev] Opening new URL in same instance and -s option
 Date: Thu, 21 Sep 2006 21:31:57 -0400
 From: Jorge Arellano Cid [EMAIL PROTECTED]
 To: Rainer M Krug [EMAIL PROTECTED]
 References: [EMAIL PROTECTED]

 On Thu, Sep 21, 2006 at 02:10:28PM +0200, Rainer M Krug wrote:
 Hi
Hi.

 I have two questions

 first: I would like to be able to have only one instance of dillo open
 and when I try to open a new url (from outside dillo), that this url is
 opened in the old instance. Is this possible, and if yes, how?
Not now.

The idea is to implement this with dpip (dillo plugin protocol)
 but it has not being done yet, becuase of lack of manpower.

 second: I have seen emails concerning running dillo in server mode
 (dillo -s server). I tried it, but dillo didn't know -s. Is this feature
 imp[lemented, and if yes, how can I access it?
Not in the official dillo.

 Thanks a lot for a brilliant lightning fast browser,

:-)

 --
Cheers
Jorge.-
 


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Update to Dillo browser question

2006-09-22 Thread Rainer M Krug
Hi

I asked about if there is any way of opening URLs from the help browser 
in the same window of the same dillo browser - here is the answer.

Just to reiterate: dillo is for me the perfect browser for the help of R 
when you use ?...

Rainer

 Original Message 
Subject: Re: [Dillo-dev] Opening new URL in same instance and -s option
Date: Thu, 21 Sep 2006 21:31:57 -0400
From: Jorge Arellano Cid [EMAIL PROTECTED]
To: Rainer M Krug [EMAIL PROTECTED]
References: [EMAIL PROTECTED]

On Thu, Sep 21, 2006 at 02:10:28PM +0200, Rainer M Krug wrote:
 Hi

   Hi.

 
 I have two questions
 
 first: I would like to be able to have only one instance of dillo open 
 and when I try to open a new url (from outside dillo), that this url is 
 opened in the old instance. Is this possible, and if yes, how?

   Not now.

   The idea is to implement this with dpip (dillo plugin protocol)
but it has not being done yet, becuase of lack of manpower.


 second: I have seen emails concerning running dillo in server mode 
 (dillo -s server). I tried it, but dillo didn't know -s. Is this feature 
 imp[lemented, and if yes, how can I access it?

   Not in the official dillo.

 
 Thanks a lot for a brilliant lightning fast browser,

   :-)


-- 
   Cheers
   Jorge.-

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Beginners manual for emacs and ess

2006-09-21 Thread Rainer M Krug
Thanks for all of your information.

I will look into all of them

Rainer


Gavin Simpson wrote:
 On Wed, 2006-09-20 at 17:03 +0200, Rainer M Krug wrote:
 Hi

 I heard so much about Emacs and ESS that I decided to try it out - but I 
   am stuck at the beginning.

 Is there anywhere a beginners manual for Emacs  ESS to be used with R? 
 even M-x S tells me it can't start S-Plus - obviously - but I want it to 
 start R...
 
 Er, M-x R starts R (after you've chosen a working directory) unless I
 misunderstood your question? Have you tried:
 
 http://ess.r-project.org/
 
 And the ESS manual contained there? If not, that would be my first port
 of call.
 
 Any help welcome (otherwise I will be stuck with Eclipse and R)

 Rainer
 
 G
 

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] transforming factor back to numbers

2006-09-21 Thread Rainer M Krug
Hi

I generate a new dataframe by doing:

npl.agg - aggregate(npl$DensPlants, list(year=npl$year, sim=npl$sim), 
mean, na.rm=TRUE )

Now I want to plot it by using

coplot(npl.agg$x ~ npl.agg$year | npl.agg$sim, type=l)

but, as npl.agg$year is seen as a factor, the order of the points on the 
x-axis (time axis) does not follow the numerical sorting 1...100, but 
rather the text sorting of the factor npl.agg$year

Is there any way that I can 'defactor' npl.agg$year so that I have again 
the numerical values for year?

Thanks

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] transforming factor back to numbers

2006-09-21 Thread Rainer M Krug
Thanks a lot David.

Just a suggestion - it might help if this is added to the help of factor()

Rainer

David Barron wrote:
 That's an FAQ:
 
 7.10 How do I convert factors to numeric?
 
 It may happen that when reading numeric data into R (usually, when
 reading in a file), they come in as factors. If f is such a factor
 object, you can use
 
 as.numeric(as.character(f))
 
 to get the numbers back. More efficient, but harder to remember, is
 
 as.numeric(levels(f))[as.integer(f)]
 
 In any case, do not call as.numeric() or their likes directly for the
 task at hand (as as.numeric() or unclass() give the internal codes).
 
 On 21/09/06, Rainer M Krug [EMAIL PROTECTED] wrote:
 Hi

 I generate a new dataframe by doing:

 npl.agg - aggregate(npl$DensPlants, list(year=npl$year, sim=npl$sim),
 mean, na.rm=TRUE )

 Now I want to plot it by using

 coplot(npl.agg$x ~ npl.agg$year | npl.agg$sim, type=l)

 but, as npl.agg$year is seen as a factor, the order of the points on the
 x-axis (time axis) does not follow the numerical sorting 1...100, but
 rather the text sorting of the factor npl.agg$year

 Is there any way that I can 'defactor' npl.agg$year so that I have again
 the numerical values for year?

 Thanks

 Rainer

 -- 
 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
 Biology (UCT)

 Department of Conservation Ecology and Entomology
 University of Stellenbosch
 Matieland 7602
 South Africa

 Tel:+27 - (0)72 808 2975 (w)
 Fax:+27 - (0)21 808 3304
 Cell:   +27 - (0)83 9479 042

 email:  [EMAIL PROTECTED]
 [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.

 
 

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Other editor with completion apart from emacs?

2006-09-21 Thread Rainer M Krug
Hi

is there any other editor for Linux, apart from emacs, which has the 
completion feature (i.e. I enter libTAB and it offers me among other 
options library)

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Other editor with completion apart from emacs?

2006-09-21 Thread Rainer M Krug
Hi

Thanks for the tip - sounds interesting.

I installed JGR, but I can't get it to work.

I installed it as mentioned on via install.packages() and if I try to
load it, I get the following:


 library(JGR)
Loading required package: rJava
Loading required package: JavaGD
Loading required package: iplots

 *** caught segfault ***
address 0xc, cause 'memory not mapped'

Traceback:
 1: .External(RinitJVM, classpath, parameters, PACKAGE = rJava)
 2: .jinit(cp, parameters = -Xmx512m, silent = TRUE)
 3: f(libname, pkgname)
 4: firstlib(which.lib.loc, package)
 5: try(firstlib(which.lib.loc, package))
 6: library(pkg, character.only = TRUE, logical = TRUE, lib.loc = lib.loc)
 7: .getRequiredPackages2(pkgInfo)
 8: library(JGR)

Possible actions:
1: abort (with core dump)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:


I updated the packages to the versions on http://www.rosuda.org/R , but
still the same.

Any ideas?

Rainer

ronggui wrote:
 JGR support completion. It can runs under Linux,though JGR is more
 than a editor.
 
 On 9/21/06, Rainer M Krug [EMAIL PROTECTED] wrote:
 Hi

 is there any other editor for Linux, apart from emacs, which has the
 completion feature (i.e. I enter libTAB and it offers me among other
 options library)

 Rainer

 -- 
 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
 Biology (UCT)

 Department of Conservation Ecology and Entomology
 University of Stellenbosch
 Matieland 7602
 South Africa

 Tel:+27 - (0)72 808 2975 (w)
 Fax:+27 - (0)21 808 3304
 Cell:   +27 - (0)83 9479 042

 email:  [EMAIL PROTECTED]
 [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.

 
 

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Linux configuration (Ubuntu)

2006-09-20 Thread Rainer M Krug


Frank E Harrell Jr wrote:
SNIP

 After R starts you can manage help files nicely using help.start() to 
 use a browser.  I often use dillo, the world's fastest graphical 
 browser, by specifying options(browser='dillo') before help.start().

WOW - dillo is BRILLIANT for this purpose.
Thanks for the tip!
Do you have any idea on how to convince dillo to reuse the same browser 
window again instead of using a new one when using ? ?

 
 Frank
 


 Thanks in advance,
 Brian
 
 

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Calculating mean together with split

2006-09-20 Thread Rainer M Krug
Hi

I have a table called npl containing results of simulations.

It contains about 19000 entries and the structure looks like this:

  NoPlants  sim run year DensPlants
16 lng_cs99_renosterbos   140.00192
.
.
.


it has 43 different entries for sim and year goes from 1 to 100, and run 
from 1 to 5.

I would like to calculate the mean of DensPlants for each simulation and 
each year seperately, i.e. calculating the mean for all combinations of 
sim and year over run.

I can use

split(npl, npl$sim)

to split npl into different groups each containing the entries for one 
parameterset - but where to go from there?

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Calculating mean together with split

2006-09-20 Thread Rainer M Krug
Hi David

aggregate is what I was looking for, as I wanted to have it in the 
tabular format to plot it.

Thanks

Rainer

David Barron wrote:
 Of course, aggregate will work too, depends on how you want the output
 to be formatted.  You could also look at summarize in the Hmisc
 package.
 
 On 20/09/06, David Barron [EMAIL PROTECTED] wrote:
 Sorry, that should have been package gdata, not gtools...they're both
 in the same bundle, though.

 On 20/09/06, Rainer M Krug [EMAIL PROTECTED] wrote:
  Hi
 
  I have a table called npl containing results of simulations.
 
  It contains about 19000 entries and the structure looks like this:
 
NoPlants  sim run year DensPlants
  16 lng_cs99_renosterbos   140.00192
  .
  .
  .
 
 
  it has 43 different entries for sim and year goes from 1 to 100, and 
 run
  from 1 to 5.
 
  I would like to calculate the mean of DensPlants for each simulation 
 and
  each year seperately, i.e. calculating the mean for all combinations of
  sim and year over run.
 
  I can use
 
  split(npl, npl$sim)
 
  to split npl into different groups each containing the entries for one
  parameterset - but where to go from there?
 
  Rainer
 
  --
  Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
  Biology (UCT)
 
  Department of Conservation Ecology and Entomology
  University of Stellenbosch
  Matieland 7602
  South Africa
 
  Tel:+27 - (0)72 808 2975 (w)
  Fax:+27 - (0)21 808 3304
  Cell:   +27 - (0)83 9479 042
 
  email:  [EMAIL PROTECTED]
  [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.
 


 -- 
 =
 David Barron
 Said Business School
 University of Oxford
 Park End Street
 Oxford OX1 1HP

 
 

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] Beginners manual for emacs and ess

2006-09-20 Thread Rainer M Krug
Hi

I heard so much about Emacs and ESS that I decided to try it out - but I 
  am stuck at the beginning.

Is there anywhere a beginners manual for Emacs  ESS to be used with R? 
even M-x S tells me it can't start S-Plus - obviously - but I want it to 
start R...

Any help welcome (otherwise I will be stuck with Eclipse and R)

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] execution of source() command

2006-09-15 Thread Rainer M Krug
Hi

Linux SuSE 10

platform   i686-pc-linux-gnu
arch   i686
os linux-gnu
system i686, linux-gnu
status
major  2
minor  3.1
year   2006
month  06
day01
svn rev38247
language   R
version.string Version 2.3.1 (2006-06-01)

I have two questions concerning the source(test.R) command.
1) Is there any command which I can put into the test.R script file
which aborts the execution of the script? At the moment I use

CodeToBeExecutedInScript
if (FALSE)
{
CodeNotToBeExecutedInScript
}

which is not elegant, but it works. I would prefer something like:

CodeToBeExecutedInScript
CommandToAbotrExecutionOfScriptFile
CodeNotToBeExecutedInScript

2) When I call source(test.R) and it is running for some time. Does
changing the file test.R while it is executed change the execution, i.e.
 does the call of source() load the script file into memory and parses
and executes it from there or does it parse and execute the file on the
disk?

Thanks in advance,

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] execution of source() command

2006-09-15 Thread Rainer M Krug
Prof Brian Ripley wrote:
 On Fri, 15 Sep 2006, Rainer M Krug wrote:
 
 Hi
 I have two questions concerning the source(test.R) command.
 1) Is there any command which I can put into the test.R script file
 which aborts the execution of the script? At the moment I use

 CodeToBeExecutedInScript
 if (FALSE)
 {
 CodeNotToBeExecutedInScript
 }

 which is not elegant, but it works. I would prefer something like:

 CodeToBeExecutedInScript
 CommandToAbotrExecutionOfScriptFile
 CodeNotToBeExecutedInScript
 
 ?stop or ?q, depending on what you mean by 'aborts the execution'.

Thanks - I would have expected to find it together with the other
flowcontrol commands like if, while, ...

 
 2) When I call source(test.R) and it is running for some time. Does
 changing the file test.R while it is executed change the execution, i.e.
 does the call of source() load the script file into memory and parses
 and executes it from there or does it parse and execute the file on
 the disk.
 
 The help file says:
 
  'source' causes R to accept its input from the named file or URL
  (the name must be quoted) or connection.  Input is read and
  'parse'd by from that file until the end of the file is reached,
  then the parsed expressions are evaluated sequentially in the
  chosen environment.
 
 library(fortunes); fortune(WTFM)
 
 

Again - thanks a lot for the clarification

Rainer
-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] problem with putting objects in list

2006-09-08 Thread Rainer M Krug
Well - it must be that the whole concept of lists, vectors / matrices,
objects, data frames is not that clear to me. From my background
(Delphi, Basic), I am used to that, when referencing dr[i] I get the
object which is stored in the list.

Is there any manual / technical manual / reference available which
explains all this? The normal manual (Introduction into R) didn't made
it clear to me.

Rainer

jim holtman wrote:
 What is the problem with referencing it with 'dr[[i]]', the way a list
 is supposed to be referenced?
 
 On 9/6/06, Rainer M Krug [EMAIL PROTECTED] wrote:
 Antonio, Fabio Di Narzo wrote:
  Use 'sapply' instead of 'lapply'. Type
 If I use sapply it seems to simplify / collapse to much.

  ?lapply
  for details


 
  Antonio, Fabio Di Narzo.
  University of Bologna, Italy
 
  2006/9/6, Rainer M Krug [EMAIL PROTECTED]:
  Hi
 
  I use the following code and it stores the results of density() in the
  list dr:
 
  dens - function(run) { density( positions$X[positions$run==run],
 bw=3,
  cut=-2 ) }
  dr - lapply(1:5, dens)
 
  but the results are stored in dr[[i]] and not dr[i], i.e.
 plot(dr[[1]])
  works, but plot([1]) doesn't.
 
  Is there any way that I can store them in dr[i]?
 
  Thanks a lot,
 
  Rainer
 
 
 
  --
  Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
  Biology (UCT)
 
  Department of Conservation Ecology and Entomology
  University of Stellenbosch
  Matieland 7602
  South Africa
 
  Tel:+27 - (0)72 808 2975 (w)
  Fax:+27 - (0)21 808 3304
  Cell:   +27 - (0)83 9479 042
 
  email:  [EMAIL PROTECTED]
  [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.
 


 -- 
 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
 Biology (UCT)

 Department of Conservation Ecology and Entomology
 University of Stellenbosch
 Matieland 7602
 South Africa

 Tel:+27 - (0)72 808 2975 (w)
 Fax:+27 - (0)21 808 3304
 Cell:   +27 - (0)83 9479 042

 email:  [EMAIL PROTECTED]
[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.

 
 


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] problem with putting objects in list

2006-09-08 Thread Rainer M Krug
Thanks a lot - it looks like the sort of manual I was looking for -
Could I suggest of including it into the list of manuals for R? (If it
is already there, my apologies)

Rainer

Patrick Burns wrote:
 S Poetry should help you understand this.  See
 especially the section of chapter 1 on subscripting.
 
 Patrick Burns
 [EMAIL PROTECTED]
 +44 (0)20 8525 0696
 http://www.burns-stat.com
 (home of S Poetry and A Guide for the Unwilling S User)
 
 Rainer M Krug wrote:
 
 Hi

 I use the following code and it stores the results of density() in the
 list dr:

 dens - function(run) { density( positions$X[positions$run==run], bw=3,
 cut=-2 ) }
 dr - lapply(1:5, dens)

 but the results are stored in dr[[i]] and not dr[i], i.e. plot(dr[[1]])
 works, but plot([1]) doesn't.

 Is there any way that I can store them in dr[i]?

 Thanks a lot,

 Rainer



  



-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] problem with putting objects in list

2006-09-08 Thread Rainer M Krug
Thanks a lot Tony

this explains a lot.
I am not aware to have read such a good explanation about this issue
before. I would suggest to add it to the FAQs.

Rainer

Tony Plate wrote:
 I suspect you are not thinking about the list and the
 subsetting/extraction operators in the right way.
 
 A list contains a number of components.
 
 To get a subset of the list, use the '[' operator.  The subset can
 contain zero or more components of the list, and it is a list itself.
 So, if x is a list, then x[2] is a list containing a single component.
 
 To extract a component from the list, use the '[[' operator.  You can
 only extract one component at a time.  If you supply a vector index with
 more than one element, it will index recursively.
 
 x - list(1,2:3,letters[1:3])
 x
 [[1]]
 [1] 1
 
 [[2]]
 [1] 2 3
 
 [[3]]
 [1] a b c
 
 # a subset of the list
 x[2:3]
 [[1]]
 [1] 2 3
 
 [[2]]
 [1] a b c
 
 # a list with one component:
 x[2]
 [[1]]
 [1] 2 3
 
 # the second component itself
 x[[2]]
 [1] 2 3
 # recursive indexing
 x[[c(2,1)]]
 [1] 2
 x[[c(3,2)]]
 [1] b

 
 Rainer M Krug wrote:
 Hi

 I use the following code and it stores the results of density() in the
 list dr:

 dens - function(run) { density( positions$X[positions$run==run], bw=3,
 cut=-2 ) }
 dr - lapply(1:5, dens)

 but the results are stored in dr[[i]] and not dr[i], i.e. plot(dr[[1]])
 works, but plot([1]) doesn't.

 Is there any way that I can store them in dr[i]?

 Thanks a lot,

 Rainer



 


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] problem with putting objects in list

2006-09-06 Thread Rainer M Krug
Hi

I use the following code and it stores the results of density() in the
list dr:

dens - function(run) { density( positions$X[positions$run==run], bw=3,
cut=-2 ) }
dr - lapply(1:5, dens)

but the results are stored in dr[[i]] and not dr[i], i.e. plot(dr[[1]])
works, but plot([1]) doesn't.

Is there any way that I can store them in dr[i]?

Thanks a lot,

Rainer



-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] problem with putting objects in list

2006-09-06 Thread Rainer M Krug
Antonio, Fabio Di Narzo wrote:
 Use 'sapply' instead of 'lapply'. Type
If I use sapply it seems to simplify / collapse to much.

 ?lapply
 for details


 
 Antonio, Fabio Di Narzo.
 University of Bologna, Italy
 
 2006/9/6, Rainer M Krug [EMAIL PROTECTED]:
 Hi

 I use the following code and it stores the results of density() in the
 list dr:

 dens - function(run) { density( positions$X[positions$run==run], bw=3,
 cut=-2 ) }
 dr - lapply(1:5, dens)

 but the results are stored in dr[[i]] and not dr[i], i.e. plot(dr[[1]])
 works, but plot([1]) doesn't.

 Is there any way that I can store them in dr[i]?

 Thanks a lot,

 Rainer



 -- 
 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
 Biology (UCT)

 Department of Conservation Ecology and Entomology
 University of Stellenbosch
 Matieland 7602
 South Africa

 Tel:+27 - (0)72 808 2975 (w)
 Fax:+27 - (0)21 808 3304
 Cell:   +27 - (0)83 9479 042

 email:  [EMAIL PROTECTED]
 [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.



-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] density() with from, to or cut and comparrison of density()

2006-08-30 Thread Rainer M Krug
Hi

the function density() does normally integrate to one - I've checked it
and it works and I also read the previous threads.
But I realised that it does not integrate to one if I use from, to or cut.

My scenario: I simulated densities of a plants originating from an sseed
source at distance zero. Therefore the density of the plants will be
highest close to zero. Is there anything I can do to have this pattern?
If I use 'from' or 'cut', the resulting densities do not integrate to
one which I need as I want to compare different density curves.

Ny second question is concerning the bandwidth. An I correct in saying
that if I want to compare different density estimates that the bandwidth
should be the same for all of them?

Thanks in advance for your help,

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] some EPS rotated in journal preview

2006-07-25 Thread Rainer M Krug
This is a very late rply to this topic, but I had a similar problem and
I got different results with using ps.options() then using
postscript(...) and the one with ps.options produced the results
expected. The problem were the size of the graph and the paper and the
rotation.

If you want to know details, I have to dig them out.

Rainer


Knut Krueger wrote:
 
 Prof. Brian Ripley schrieb:
 CoverLetter.pdf
 The problem is a well-known one in viewers looking at whole pages,
 especially PS - PDF converters.  R figures are particularly 
 vulnerable as they have text running both horizontally and vertically 
 (with normal axes).

 Please do follow exactly the advice on the postscript help page.

  The postscript produced for a single R plot is EPS (_Encapsulated
  PostScript_) compatible, and can be included into other documents,
  e.g., into LaTeX, using '\includegraphics{filename}'.  For use
  in this way you will probably want to set 'horizontal = FALSE,
  onefile = FALSE, paper = special'.

 If you have done that, suggest to your publisher that they turn auto 
 rotation off. 
 
 
 
 There are the reproducible codes (from the help file). The first one 
 with the long text is rotated the second is not rotated.
 Seems that they rotate the page, if the text of the y-axes is longer 
 than the text of the x-axes.
 Are you able to see any other reason for the rotation.
 I will contact the journal again, if there is no other reason especially 
 of the R-code.
 
 Regards
 Knut Krueger.
 
 postscript(c:/r/test/regline2.eps,horizontal = FALSE,onefile=FALSE, 
 paper = special ,pointsize=20,
 height=8,width=8,family = Helvetica, font = Helvetica)
  data(Davis)
  attach(Davis)
  mod.M-lm(repwt~weight, subset=sex==M)
  mod.F-lm(repwt~weight, subset=sex==F)
  plot(weight, repwt, pch=c(1,2)[sex],ylab=     
 ,xlab= )
 
  reg.line(mod.M)
  reg.line(mod.F, lty=2)
 
 dev.off()
 
 postscript(c:/r/test/regline3.eps,horizontal = FALSE,onefile=FALSE, 
 paper = special ,pointsize=20,
 height=8,width=8,family = Helvetica, font = Helvetica)
  data(Davis)
  attach(Davis)
  mod.M-lm(repwt~weight, subset=sex==M)
  mod.F-lm(repwt~weight, subset=sex==F)
  plot(weight, repwt, pch=c(1,2)[sex])
 
  reg.line(mod.M)
  reg.line(mod.F, lty=2)
 
 dev.off()
 
 __
 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
 


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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] RMySQL...Can't initialize driver???

2006-06-28 Thread Rainer M Krug
Stephane Cruveiller wrote:
 Rainer M Krug wrote:
 I followed your instruction. Here is my .my.cnf:
 ---
 [client]
 user=steff
 password=XX
 database=justforfun
 ---
 with it, I can connect to my MYSQL server without problem
 and then I try to connect through R:
 
 ---
 library(RMySQL)
 Loading required package: DBI
 m - dbDriver(MySQL)
 Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...)
 ---
 
 It still produces the error. I really  do not  know what is going on
 here...

Sorry - no idea. I guess you are using Linux? And all packages are up to
date?

Rainer




 
 
 Then you do:


 library(RMySQL)
 m - dbDriver(MySQL)
 con - dbConnect(m, group = renpatch)
 q - TheSQLQuery
 rs - dbSendQuery(con, q)
 TheResults - fetch(rs, n = -1)
 dbDisconnect(con)
 rm(con)


 and it should work - at least that is what it is doing for me.

 Rainer

   
 
 Stephane.


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


Re: [R] RMySQL...Can't initialize driver???

2006-06-27 Thread Rainer M Krug
Stephane Cruveiller wrote:
 Duncan Murdoch wrote:
 On 6/27/2006 8:51 AM, Stephane Cruveiller wrote:
 Dear R users,

 I would like to query a MySQL database through R. I have installed
 the latest required packages (RMySQL and DBI) in R (v2.3.1). A MySQL
 server (v5.0.22) is running on my local machine but I can't
 initialize MYSQL
 driver:
 

   library(RMySQL)
 Loading required package: DBI
   MySQL(max.con = 10, fetch.default.rec = 500, force.reload = F)
 Error in new(MySQLDriver, Id = drvId) : unused argument(s) (Id ...)
 -


 Could somebody tell me what I have missed?

I am running R 2.3.0 under Linux and connect to a MySQl 4.1 server.

You have to create a file in your home directory which has the
connection infos. It should look like that:


[renpatch]
user = UserName
password = PassWord
database = ...
host = ...

[renpatch_renosterbos]
user = UserName
password = PassWord
database = ...
host = ..

and be called .my.conf

Then you do:


library(RMySQL)
m - dbDriver(MySQL)
con - dbConnect(m, group = renpatch)
q - TheSQLQuery
rs - dbSendQuery(con, q)
TheResults - fetch(rs, n = -1)
dbDisconnect(con)
rm(con)


and it should work - at least that is what it is doing for me.

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


[R] How to use mle or similar with integrate?

2006-06-23 Thread Rainer M Krug
Hi

I have the following formula (I hope it is clear - if no, I can try to
do better the next time)

h(x, a, b) =
integral(0 to pi/2)
(
  (
integral(D/sin(alpha) to Inf)
(
  (
f(x, a, b)
  )
  dx
)
  dalpha
)

and I want to do an mle with it.
I know how to use mle() and I also know about integrate(). My problem is
to give the parameter values a and b to the integrate function.

In other words, how can I write

h - function...

so that I can estimate a and b?

Thanks,

Rainer


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

__
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


[R] problem with integrate() - correction

2006-06-22 Thread Rainer M Krug
Sorry

should read:

ip - function(x) 1240 * x^(-0.88)


Rainer M Krug wrote:
 Hi
 
 System:
 Linux, SuSE 10
 R 2.3.0
 
 I try to do the following
 
 ip - function(x) 1240*dip(x, 0.88)
 iip - function(x) integrate(ip, x - 0.045, x + 0.045)$value
 f - integrate(iip, 10, 100)
 Error in integrate(iip, 10, 100) : evaluation of function gave a result
 of wrong length
 
 How can I solve this?
 
 Thanks
 
 Rainer
 
 
 


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


Re: [R] problem with integrate() - correction

2006-06-22 Thread Rainer M Krug
Thanks a lot - the symbolic solution will work and I understand what is
wrong with my function

Rainer


Frede Aakmann Tøgersen wrote:
 Well why not do it symbolically, e.g.
 
 int(a*x^b,x) = \frac{a}{b+1}x^{b+1}
 
 and integrating this again gives
 
 \frac{a}{(b+1)(b+2)}x^{b+2},
 
 of course for resonable values of a and b such that things are well defined.
 
 But if you follow the link
 
 https://stat.ethz.ch/pipermail/r-help/2005-January/064026.html
 
 you may come to this solution:
 
 
 ip - function(x) 1240 * x^(-0.88)
 
 iip - function(x){
   res - rep(NA,length(x))
   for (i in seq(along=x))
 res[i] - integrate(ip, x[i] - 0.045, x[i] + 0.045)$value
   return(res)
 }
 
 f - integrate(iip, 10, 100)
 
 which may not be an effective way to do it.
 
 
 Med venlig hilsen
 Frede Aakmann Tøgersen
  
 
  
 
 -Oprindelig meddelelse-
 Fra: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] På vegne af Rainer M Krug
 Sendt: 22. juni 2006 14:03
 Til: [EMAIL PROTECTED]
 Cc: R help list
 Emne: [R] problem with integrate() - correction

 Sorry

 should read:

 ip - function(x) 1240 * x^(-0.88)


 Rainer M Krug wrote:
 Hi

 System:
 Linux, SuSE 10
 R 2.3.0

 I try to do the following

 ip - function(x) 1240*dip(x, 0.88)
 iip - function(x) integrate(ip, x - 0.045, x + 0.045)$value f - 
 integrate(iip, 10, 100)
 Error in integrate(iip, 10, 100) : evaluation of function gave a 
 result of wrong length

 How can I solve this?

 Thanks

 Rainer




 --
 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

 Department of Conservation Ecology and Entomology University 
 of Stellenbosch Matieland 7602 South Africa

 Tel: +27 - (0)72 808 2975 (w)
 Fax: +27 - (0)21 808 3304
 Cell:+27 - (0)83 9479 042

 email:   [EMAIL PROTECTED]
  [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



-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


Re: [R] hello Excel... (native/Package/BETA)

2006-06-21 Thread Rainer M Krug
Hans-Peter wrote:
 Dear list members
 
 I am pleased to annonce that I have just finished a native Excel
 reader/writer. It's wrapped up in two packages: either xlsReadWrite (open
 source) or the slightly beefed-up xlsReadWritePro (shareware). Working
 with Excel data is now as easy as writing read.xls and write.xls.
 
 Some more details:
 
 - Infos and download: http://treetron.googlepages.com
 - for detailed documentation pls. download and see: help files, DESCRIPTION
 and README.
 - I set up a newsgroup for technical questions and feedback:
 http://groups.google.ch/group/supportR
 
 - while it could be ported to other platforms, currently it is WINDOWS only
 (see technical below)
SNIP

If I understand it right, the the flexcel library includes the
components for kylix as well - therefore I would try to compile it for
Linux, I would suggest to use CrossKylix to compile it.


Rainer

SNIP



-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


Re: [R] Question concerning mle

2006-06-19 Thread Rainer M Krug
Thanks a lot Spencer for your tips - I'll look into all of them.

Rainer

Spencer Graves wrote:
   It's difficult to say much at this level of generality, but I have
 four suggestions:
 
   1.  Have you tried creating a reasonable grid of starting values
 using expand.grid and then plotting the resulting likelihood surface?
  If you have more than 2 parameters, you may want to use 'lattice'
 graphics.  This should tell you if the functions seems unimodal, convex,
 etc., in the region you covered and at the resolution of your grid.
 
   2.  Have you tried method=SANN = simulated annealing?  I might
 try one pass with SANN, then refine the solution found by SANN using BFGS.
 
   3.  After you have a solution, you can then try profile likelihod.
 Unfortunately, my experience with profile.mle has been mixed.  I
 actually made local copies of mle and profile.mle and found and fixed
 some of the deficiencies of each.  I didn't test them enough to offer
 the results to the R Core Team, however.
 
   4.  Have you looked at Venables and Ripley (2002) Modern Applied
 Statistics with S, 4th ed. (Springer)?  It's a great book for many
 things, including the use of expand.grid and 'optim'.
 
   hope this helps.
   Spencer Graves
 
 Rainer M Krug wrote:
 Hi

 I hope this is the right forum - if not, point me please to a better one.

 I am using R 2.3.0 on Linux, SuSE 10.


 I have a question concerning mle (method=BFGS).

 I have a few models which I am fitting to existing data points. I
 realised, that the likelihood is quite sensitive to the start values for
 one parameter.

 I am wondering: what is the best approach to identify the right initial
 values? Do I have to do it recursively, and if yes, how can I automate
 it? Or do I have to play with the system?

 I am quite confident that the resulting parameters are the optimal for
 my problem - but can I verify it?

 Thanks,

 Rainer




-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

__
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


[R] Question concerning mle

2006-06-15 Thread Rainer M Krug
Hi

I hope this is the right forum - if not, point me please to a better one.

I am using R 2.3.0 on Linux, SuSE 10.


I have a question concerning mle (method=BFGS).

I have a few models which I am fitting to existing data points. I
realised, that the likelihood is quite sensitive to the start values for
one parameter.

I am wondering: what is the best approach to identify the right initial
values? Do I have to do it recursively, and if yes, how can I automate
it? Or do I have to play with the system?

I am quite confident that the resulting parameters are the optimal for
my problem - but can I verify it?

Thanks,

Rainer


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

__
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


Re: [R] How to create list of objects?

2006-06-07 Thread Rainer M Krug
Thanks everybody - it's working

Rainer

Dimitris Rizopoulos wrote:
 try something like:
 
 lapply(f, summary)
 sapply(f, function(x) AIC(logLik(x)))
 
 
 Best,
 Dimitris
 
 
 Dimitris Rizopoulos
 Ph.D. Student
 Biostatistical Centre
 School of Public Health
 Catholic University of Leuven
 
 Address: Kapucijnenvoer 35, Leuven, Belgium
 Tel: +32/(0)16/336899
 Fax: +32/(0)16/337015
 Web: http://med.kuleuven.be/biostat/
  http://www.student.kuleuven.be/~m0390867/dimitris.htm
 
 
 - Original Message - 
 From: Rainer M Krug [EMAIL PROTECTED]
 To: R help list r-help@stat.math.ethz.ch
 Sent: Tuesday, June 06, 2006 4:38 PM
 Subject: [R] How to create list of objects?
 
 
 Hi

 I am doing several mle and want to store them in a list (or whatever 
 is
 the right construct) to be able to analyse them later.

 at the moment I am doing:

 f - list()
 f$IP - mle(...)
 f$NE - mle(...)

 but when I say:
 summary(f)
 I get:

 Length Class Mode
 IP   0  mle   list
 NE   0  mle   list

 I don't get the output I would have, i.e. the one from
 summary(f$IP)
 summary(f$IP)
 Maximum likelihood estimation

 Call:
 mle(minuslogl = IPNeglogPoisL, method = L-BFGS-B, fixed = list(),
control = list(maxit = 1e+08, factr = 1e-20))

 Coefficients:
  Estimate  Std. Error
 a 1242.0185506 44.92341097
 b0.8802538  0.01685811

 -2 log L: 145.3509


 What I want to do is something like:

 AICs - AIC(logLik(f))

 and then have all the AICs in the vector AICs.

 It must be possible or is this again a namespace issue?

 Rainer

 -- 
 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
 Biology (UCT)

 Department of Conservation Ecology and Entomology
 University of Stellenbosch
 Matieland 7602
 South Africa

 __
 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

 
 
 Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


[R] How to create list of objects?

2006-06-06 Thread Rainer M Krug
Hi

I am doing several mle and want to store them in a list (or whatever is
the right construct) to be able to analyse them later.

at the moment I am doing:

f - list()
f$IP - mle(...)
f$NE - mle(...)

but when I say:
 summary(f)
I get:

 Length Class Mode
IP   0  mle   list
NE   0  mle   list

I don't get the output I would have, i.e. the one from
 summary(f$IP)
summary(f$IP)
Maximum likelihood estimation

Call:
mle(minuslogl = IPNeglogPoisL, method = L-BFGS-B, fixed = list(),
control = list(maxit = 1e+08, factr = 1e-20))

Coefficients:
  Estimate  Std. Error
a 1242.0185506 44.92341097
b0.8802538  0.01685811

-2 log L: 145.3509


What I want to do is something like:

AICs - AIC(logLik(f))

and then have all the AICs in the vector AICs.

It must be possible or is this again a namespace issue?

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

__
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


Re: [R] Problem with mle

2006-06-05 Thread Rainer M Krug
Hi Ben

Thanks a lot for your help - it solved my problem and I understand a
little bit more.

Just one more question along this line:
If I want to use another likelihood estimator, e.g. negative binominal,
I guess I have to use
-sum(dpois(SumSeeds,size=???, prob=???,log=TRUE))
instead of
-sum(dnbinom(SumSeeds,lambda=est,log=TRUE))

But what do I use for size and prob?

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


[R] Calculation of AIC BIC from mle

2006-06-05 Thread Rainer M KRug
R 2.3.0, all packages up to date
Linux, SuSE 10.0

Hi

I want to calculate AIC or BIC from several results from mle calculation.

I found the AIC function, but it does not seem to work with objects of
class mle -
If I execute the following:
ml1 - mle(...)
AIC(ml1)

I get the following error messale:
Error in logLik(object) : no applicable method for logLik

Therefore I am using the following to calculate the AIC:

#AICmle calculate AIC from mle object
AICmle - function( m, k=2)
{
lL - logLik(m)
edf - attr(lL, df)
LL - lL[1]
- 2 * LL + k * edf
}

1) Why is AIC not working with objects of class mle - am I doing
something wrong, is it a bug or by design?

2) Just for confirmation - is my calculation of AIC correct?

Thanks

Rainer

__
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


Re: [R] Calculation of AIC BIC from mle

2006-06-05 Thread Rainer M Krug
Thanks a lot for your and Martin's help - I understand now why it is not
working and am using AIC(logLik(ml1)).

Thanks

Rainer


Prof Brian Ripley wrote:
 You are mixing S3 and S4 classes and generics here.  AIC(logLik(ml1))
 will work.
 
 This a namespace issue: stats4 contains a version of logLik, but the
 default method for AIC is from stats, and so dispatches on stats::logLik
 and not stats4::logLik.  There is something fundamentally unsatisfactory
 about converting S3 generics to S4 generics where namespaces are involved.
 
 I have put a workaround in R-devel.
 
 On Mon, 5 Jun 2006, Rainer M KRug wrote:
 
 R 2.3.0, all packages up to date
 Linux, SuSE 10.0

 Hi

 I want to calculate AIC or BIC from several results from mle calculation.

 I found the AIC function, but it does not seem to work with objects of
 class mle -
 If I execute the following:
 ml1 - mle(...)
 AIC(ml1)

 I get the following error messale:
 Error in logLik(object) : no applicable method for logLik

 Therefore I am using the following to calculate the AIC:

 #AICmle calculate AIC from mle object
 AICmle - function( m, k=2)
 {
 lL - logLik(m)
 edf - attr(lL, df)
 LL - lL[1]
 - 2 * LL + k * edf
 }

 1) Why is AIC not working with objects of class mle - am I doing
 something wrong, is it a bug or by design?

 2) Just for confirmation - is my calculation of AIC correct?
 
 Not quite.  The correct function is
 
 stats:::AIC.logLik
 function (object, ..., k = 2)
 -2 * c(object) + k * attr(object, df)
 environment: namespace:stats
 


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


[R] Problem with mle

2006-06-02 Thread Rainer M KRug
R 2.3.0
Linux, SuSE 10.0

Hi

I have two problems with mle - probably I am using it the wrong way so
please let me know.

I want to fit different distributions to an observed count of seeds and
in the next step use AIC or BIC to identify the best distribution.

But when I run the script below (which is part of my original script), I
get one error message for the first call of mle:

Error in solve.default(oout$hessian) : Lapack routine dgesv: system is
exactly singular
In addition: Warning messages:
1: NaNs produced in: dweibull(x, shape, scale, log)
2: NaNs produced in: dweibull(x, shape, scale, log)
3: NaNs produced in: dweibull(x, shape, scale, log)
4: NaNs produced in: dweibull(x, shape, scale, log)

What can I do to avoid this problem?

The second one is following the second call of mle:
summary(fit.NE) gives me the summary of the fit, but

profile(fit.NE) gives me the following error message:
Error in onestep(step) : profiling has found a better solution, so
original fit had not converged
In addition: Warning messages:
1: NaNs produced in: dexp(x, 1/rate, log)
2: NaNs produced in: dexp(x, 1/rate, log)
3: NaNs produced in: dexp(x, 1/rate, log)
4: NaNs produced in: dexp(x, 1/rate, log)
5: NaNs produced in: dexp(x, 1/rate, log)
6: NaNs produced in: dexp(x, 1/rate, log)

What can I do in this case - which parameters do I have to change that
it converges?

Rainer


##
library(stats4)

SumSeeds - c(762, 406, 288, 260, 153, 116,  57,  33,  40,  44,  36,
24,  35,  23,  36,  25,  35,  30)
X - c(1.74924, 3.49848, 5.24772, 6.99696, 8.74620, 17.49240, 26.23860,
34.98480, 43.73100, 52.47720, 61.22340, 69.96960, 71.71880, 73.46810,
75.21730, 76.96650, 78.71580, 80.46500 )

#Sum of log of values in vector
SumLog - function (x)
{
sum(log(x)) 
}

#-ln(L) with Poisson Likelihood estimator
NeglogPoisL - function (obs, est)
{
sel - est != 0
SumLogObs - SumLog(obs[sel])
-sum( obs[sel] * log(est[sel]) - est[sel]- SumLogObs )
}


#-ln(L) for Negative Exponential
NENeglogPoisL - function(a=0.2, rate=0.04)
{
NeglogPoisL( SumSeeds, a * dexp( X, rate) ) 

}

#-ln(L) for Weibull
WBNeglogPoisL - function(a=100, shape=0.12, scale=1e+37)
{
NeglogPoisL( SumSeeds, a * dweibull(X, shape, scale) )
}



fit.WB - mle(  
WBNeglogPoisL
, start=list(a=1, shape=0.1, scale=1)
, fixed=list()
, control=list(maxit=1)
 )

fit.NE - mle(  
NENeglogPoisL
, start=list(a=1, rate=1)
, fixed=list()
, control=list(maxit=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


Re: [R] pattern instead of colors in bargraph

2006-05-15 Thread Rainer M KRug
Uwe Ligges wrote:
 Rainer M KRug wrote:
 
 Hi

 I am using R 2.2.0 under SuSE 10.

 I am creating a graph by using the following script:


 DietF - read.csv (DietFem.csv, header = TRUE, as.is=TRUE)
 attach (DietF)
 PP - array(c(bud,flower,shoot,melon,seed.pod,detritus,other), c(16,7))
 M - paste (Month)
 detach (DietF)
 png(filename=DietF.png, width=960)
 barplot (t(PP), ylim=c(0,1), names.arg=M, space=0.3, ylab=proportion of
 diet)
 dev.off()

 The problem is that I would need the bars to be filled with pattern
 (striped, diagonal striped, dotted, ...) instead of the colors as it is
 extremely difficult to see which is which.

 I didn't find anything in the help which showed me how to do it.
 
 Then please re-read it and look at the arguments desnity and angle.
 
 Uwe Ligges


Thanks a lot (I mean it!) - it must have been to late on Saturday
evening when I looked at it.

Rainer

__
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


[R] Title for secondary y-axis (axis(4)) in barplot?

2006-05-15 Thread Rainer M KRug
Hi

I am using the following script to plot a barplot with a secondary axis
in a bargplot for the line.
It works, but I would like to have a title for the secondary y-axis on
the right hand side of the axis - is this possible?

Rainer


RainFog - read.csv (Climate.csv, header = TRUE, as.is=TRUE)
PP - array(c(RainFog$Rain, RainFog$Fog), c(16,2))
M - paste (RainFog$Month)
png(filename=RainFog.png, width=960)
barplot (t(PP), ylim=c(0,8),names.arg=M, space=0.3, ylab=precipitation
in mm)
lines (seq(0.8,20.3, by=1.3), RainFog$Rel.Hum./10, type=o)
axis (4, at=seq(0, 8, by=2), labels=seq (0, 80, by=20))
dev.off()

__
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


[R] More elegant way to do this?

2006-05-15 Thread Rainer M KRug
Hi

I am using R 2.2.0 under SuSE 10.

I am creating a matrix MT to be used by barplot.


DietF - read.csv (DietFem.csv, header = TRUE, as.is=TRUE)
attach (DietF)

PP - array(c(bud,flower,shoot,melon,seed.pod,detritus,other), c(16,7))
M - paste (Month)
MT - t(PP)

It works, but I have the feeling, there is a more elegant way of doing
it, but I can't think of it.

Thanks a lot,

Rainer

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
South Africa

__
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


Re: [R] Title for secondary y-axis (axis(4)) in barplot?

2006-05-15 Thread Rainer M KRug
Uwe Ligges wrote:
 Rainer M KRug wrote:
 
 Hi

 I am using the following script to plot a barplot with a secondary axis
 in a bargplot for the line.
 It works, but I would like to have a title for the secondary y-axis on
 the right hand side of the axis - is this possible?

 Rainer


 RainFog - read.csv (Climate.csv, header = TRUE, as.is=TRUE)
 PP - array(c(RainFog$Rain, RainFog$Fog), c(16,2))
 M - paste (RainFog$Month)
 png(filename=RainFog.png, width=960)
 barplot (t(PP), ylim=c(0,8),names.arg=M, space=0.3, ylab=precipitation
 in mm)
 lines (seq(0.8,20.3, by=1.3), RainFog$Rel.Hum./10, type=o)
 axis (4, at=seq(0, 8, by=2), labels=seq (0, 80, by=20))
 dev.off()
 
 
 See ?mtext

Thanks - exactly what I was looking for

Rainer

__
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


[R] pattern instead of colors in bargraph

2006-05-15 Thread Rainer M KRug
Hi

I am using R 2.2.0 under SuSE 10.

I am creating a graph by using the following script:


DietF - read.csv (DietFem.csv, header = TRUE, as.is=TRUE)
attach (DietF)
PP - array(c(bud,flower,shoot,melon,seed.pod,detritus,other), c(16,7))
M - paste (Month)
detach (DietF)
png(filename=DietF.png, width=960)
barplot (t(PP), ylim=c(0,1), names.arg=M, space=0.3, ylab=proportion of
diet)
dev.off()

The problem is that I would need the bars to be filled with pattern
(striped, diagonal striped, dotted, ...) instead of the colors as it is
extremely difficult to see which is which.

I didn't find anything in the help which showed me how to do it.
Is it possible, and if yes how?

Thanks a lot,

Rainer


-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology and Entomology
University of Stellenbosch
South Africa

__
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


[R] Create graphs from text console

2006-03-23 Thread Rainer M Krug
Hi

I am using R 2.2.1 under Linux (SuSE 10) and would like to know if it is 
possible to create graphs, i.e.

jpeg(filename=fn)
try( coplot( mor$I_Morisita ~ mor$Year | mor$RunStr, show.given=FALSE) )
dev.off()

from a text console?
It gives me an error message on the jpeg() command:

Error in X11(..snip..) unable to start device jpeg
In addition: warning message:
unable to open connection to X11 display.

Are there any ways to create the plot and save it into a jpeg file from 
a text console?

Thanks,

Rainer



-- 
--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:+27 - (0)83 9479 042

email:[EMAIL PROTECTED]
   [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


Re: [R] Create graphs from text console

2006-03-23 Thread Rainer M Krug
Thanks a lot for all your help and tips. As I don't need publishhable 
quality, I will go with the bitmap option.

Rainer

--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:+27 - (0)83 9479 042

email:[EMAIL PROTECTED]
   [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


[R] R, Eclipse and StatEt plugin under Linux

2006-03-16 Thread Rainer M Krug
Hi

I try to use the R plugin StatET 3.1-M2 (0.2.1) under eclipse 3.1.1 in 
Linux. Everything works fine, except of the integration of the R console 
into eclipse.

On the StatET website (http://www.walware.de/goto/statet) it states:
***
Do you know, how to start R inside Eclipse on Unix/Linux preventing the 
batch-modus, which parameters are useful? Let me know.
***

and this is exactly the problem. I managed to convince R not to start in 
batch mobe by using the parameter --save, --no-save or --vanilla, but it 
  is stuck before reaching the input prompt. The last thing it says is:
[Previously saved workspace restored]

and that is it - and eclipse's progress bar is stuck. I can cancel it by 
pressing the cancel button, but the console closes.

Any ides on how to solve the problem?

Thanks,

Rainer


-- 
--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:+27 - (0)83 9479 042

email:[EMAIL PROTECTED]
   [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


[R] How to get the intercept from lm?

2006-03-10 Thread Rainer M Krug
Hi

I am using R 2.2.0 under SuSE 10

I want to use lm() to get the slope and intercept for several daatasets 
and store them in a database. So far so good - but how do I extract the 
slope and the intercept from the result from lm()?

my code looks like this:

lmNNDens - lm(log(DensNN$MeanNN) ~ log(DensNN$MeanDensity))
anovaLM - anova(lmNNDens)

Results$slope[No] - ???lmNNDens???
Results$intercept[No] - ???lmNNDens???

any help welcome,


Rainer


-- 
--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:+27 - (0)83 9479 042

email:[EMAIL PROTECTED]
   [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


[R] Problems installing R 2.1.1. from rpm (R-base-2.2.0-1.i586.rpm) on SuSE 10

2005-12-20 Thread Rainer M Krug
Hi

I have problems installing R 2.1.1. from rpm (R-base-2.2.0-1.i586.rpm) 
on SuSE 10. It installs fine, all dependances are OK (at least Yast does 
not complain) but when I try to run R, it gives the following error message:

symbol lookup error: /usr/lib/libblas.so.3: undefined symbol: 
_gfortran_filename

and R quits.

blas version: 3.0-926

Any help appreciated,

Rainer

-- 
--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:+27 - (0)83 9479 042

email:[EMAIL PROTECTED]
   [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


Re: [R] Problems installing R 2.1.1. from rpm (R-base-2.2.0-1.i586.rpm) on SuSE 10

2005-12-20 Thread Rainer M Krug
Nope - If I enter

  rpm -qf `which gfortran`

I get

gcc-fortran-4.0.2_20050901-3

Rainer


Peter Dalgaard wrote:
 Rainer M Krug [EMAIL PROTECTED] writes:
 
 Hi

 I have problems installing R 2.1.1. from rpm (R-base-2.2.0-1.i586.rpm) 
 on SuSE 10. It installs fine, all dependances are OK (at least Yast does 
 not complain) but when I try to run R, it gives the following error message:

 symbol lookup error: /usr/lib/libblas.so.3: undefined symbol: 
 _gfortran_filename

 and R quits.

 blas version: 3.0-926

 Any help appreciated,

 Rainer
 
 I suspect you're missing
 
 turmalin:~/rpm -qf `which gfortran`
 gcc-fortran-4.0.2_20050901-3
 
  
 -- 
 --
 Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

 Department of Conservation Ecology
 University of Stellenbosch
 Matieland 7602
 South Africa

 Tel:+27 - (0)72 808 2975 (w)
 Fax:+27 - (0)21 808 3304
 Cell:+27 - (0)83 9479 042

 email:[EMAIL PROTECTED]
[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

 

-- 
--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:+27 - (0)83 9479 042

email:[EMAIL PROTECTED]
   [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


Re: [R] Problems installing R 2.1.1. from rpm (R-base-2.2.0-1.i586.rpm) on SuSE 10

2005-12-20 Thread Rainer M Krug
I used the SuSE 10 CDs as installation sources and added afterwards 
OpenSuse sources and extra CDs for Suse 10 and OpenSuse.

By the way, I decided to compile it from source and it worked without 
problems - no errors.

I guess that one of the versions used in the compilation for the rpms is 
not compatible with a newer version.

Thanks for your help,

Rainer



Peter Dalgaard wrote:
 Rainer M Krug [EMAIL PROTECTED] writes:
 
 Nope - If I enter

   rpm -qf `which gfortran`

 I get

 gcc-fortran-4.0.2_20050901-3

 Rainer
 
 
 Hmm, where did the blas come in? I don't seem to have it on the SuSE
 10 machine that I have access to (but it is running R-base-2.2.0-0).
 
  
 Peter Dalgaard wrote:
 Rainer M Krug [EMAIL PROTECTED] writes:

 Hi

 I have problems installing R 2.1.1. from rpm
 (R-base-2.2.0-1.i586.rpm) on SuSE 10. It installs fine, all
 dependances are OK (at least Yast does not complain) but when I try
 to run R, it gives the following error message:

 symbol lookup error: /usr/lib/libblas.so.3: undefined symbol:
 _gfortran_filename

 and R quits.

 blas version: 3.0-926

 Any help appreciated,

 Rainer
 I suspect you're missing
 turmalin:~/rpm -qf `which gfortran`
 gcc-fortran-4.0.2_20050901-3
 

-- 
--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:+27 - (0)83 9479 042

email:[EMAIL PROTECTED]
   [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


[R] Why is bubbles() creating empty png graphs?

2005-12-15 Thread Rainer M Krug
This code below produces empty XXX.png files - if I use plot(), it works 
and if I enter the commands

png(filename=fn)
bubble(positions, do.sqrt=FALSE, main=q)
dev.off()

manually, it works as well.

I am lost - any help appreciated.

The weird thing is that it worked before I made some changes... (I don't 
have a copy of the working version...).

R version:

platform i686-pc-linux-gnu
arch i686
os   linux-gnu
system   i686, linux-gnu
status
major2
minor2.0
year 2005
month10
day  06
svn rev  35749
language R

Operating system: SuSE 10

Rainer


-

library(gstat)
library(RMySQL)
library(DAAG)

m - dbDriver(MySQL)
con - dbConnect(m, group = renpatch_renosterbos)

tbls - dbListTables(con)
runs - 1:5
years - seq(98, 0, -7)

progress_end - length(tbls) * length(runs) * length(years)
progress - 0

for (year in years)
{
fd - paste(/home/rkrug/Documents/R/plots/Y, year, sep=)
dir.create(fd, showWarnings=FALSE, recursive = TRUE)
for (run in runs)
{
for (tn in tbls)
{
fn - paste(fd, /, tn, _R, run, _Y, year, .png, sep=)
progress - progress + 1
cat(progress, 'of', progress_end,  | , fn,  | )
flush.console()
if (!file.exists(fn))
{
q - paste(select X,Y,RX from, tn, where (_run=, run, ) AND 
(_Year=, year, ))
rs - dbSendQuery(con, q)
positions - fetch(rs, n = -1)
while (!dbHasCompleted(rs))
{
cat(.)
flush.console()
}
cat(length(positions$X), points)
png(filename=fn)
bubble(positions, do.sqrt=FALSE, main=q)
#plot(positions)
dev.off()
pause()
cat( | Done \n)
}
}
}
}

-- 
--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:+27 - (0)83 9479 042

email:[EMAIL PROTECTED]
   [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


Re: [R] Why is bubbles() creating empty png graphs?

2005-12-15 Thread Rainer M Krug
Thanks a lot for yor help - it is working now

Rainer


Roger Bivand wrote:
 On Thu, 15 Dec 2005, Rainer M Krug wrote:
 
 This code below produces empty XXX.png files - if I use plot(), it works 
 and if I enter the commands

 png(filename=fn)
 bubble(positions, do.sqrt=FALSE, main=q)
 dev.off()

 manually, it works as well.
 
 This a hidden FAQ 7.22: Why do lattice/trellis graphics not work?
 
 bubble() in package sp or gstat calls lattice function xyplot internally, 
 so doing print(bubble(...)) should work.
 
 I am lost - any help appreciated.

 The weird thing is that it worked before I made some changes... (I don't 
 have a copy of the working version...).

 R version:

 platform i686-pc-linux-gnu
 arch i686
 os   linux-gnu
 system   i686, linux-gnu
 status
 major2
 minor2.0
 year 2005
 month10
 day  06
 svn rev  35749
 language R

 Operating system: SuSE 10

 Rainer


 -

 library(gstat)
 library(RMySQL)
 library(DAAG)

 m - dbDriver(MySQL)
 con - dbConnect(m, group = renpatch_renosterbos)

 tbls - dbListTables(con)
 runs - 1:5
 years - seq(98, 0, -7)

 progress_end - length(tbls) * length(runs) * length(years)
 progress - 0

 for (year in years)
 {
 fd - paste(/home/rkrug/Documents/R/plots/Y, year, sep=)
 dir.create(fd, showWarnings=FALSE, recursive = TRUE)
 for (run in runs)
 {
 for (tn in tbls)
 {
 fn - paste(fd, /, tn, _R, run, _Y, year, .png, sep=)
 progress - progress + 1
 cat(progress, 'of', progress_end,  | , fn,  | )
 flush.console()
 if (!file.exists(fn))
 {
 q - paste(select X,Y,RX from, tn, where (_run=, run, ) AND 
 (_Year=, year, ))
 rs - dbSendQuery(con, q)
 positions - fetch(rs, n = -1)
 while (!dbHasCompleted(rs))
 {
 cat(.)
 flush.console()
 }
 cat(length(positions$X), points)
 png(filename=fn)
 bubble(positions, do.sqrt=FALSE, main=q)
 #plot(positions)
 dev.off()
 pause()
 cat( | Done \n)
 }
 }
 }
 }


 

-- 
--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:+27 - (0)83 9479 042

email:[EMAIL PROTECTED]
   [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


[R] O-ring statistic in R?

2005-12-06 Thread Rainer M Krug
Hi

Thorsten Wiegand used in his paper Wiegand T., and K. A. Moloney 2004. 
Rings, circles and null-models for point pattern analysis in ecology. 
Oikos 104: 209-229 a statistic he called O-Ring statistic which is 
similar to Ripley's K, only that it uses rings instead of circles.

http://www.oesa.ufz.de/towi/towi_programita.html#ring

Is this statistic included in one of the packages in R?

Thanks,

Rainer

--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:+27 - (0)83 9479 042

email:[EMAIL PROTECTED]
   [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


Re: [R] install.packages under SuSE 10 behind proxy, R 2.2.0 from source

2005-10-27 Thread Rainer M. Krug
Hi

I figured it out.
if I use install.packages(..., method=wget) it works
but if I use the default method, it doesn't.


Rainer

Rainer M. Krug wrote:
 Hi
 
 I installed R 2.2.0 from source and want to use install.packages but it 
 doesn't work.
 
 http_proxy is set to http://proxy.sun.ac.za:3128
 
 but it still can't connect to the repository.
 The mirror is available, I can connect to it via the internet.
 
 Any help welcome,
 
 Rainer
 
 
 



-- 
NEW TELEPHONE NUMBER
Tel:+27 - (0)72 808 2975 (w)

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


[R] tcltk package problems (R 2.2.0, SuSE 10)

2005-10-27 Thread Rainer M. Krug
Hi

I installed R 2.2.0 from source and I have the packages for tcl and tk 
installed on my system, but the package tcltk says, when I try to load 
the library tcltk: Tcl/Tk support is not available on this system.

Are there any settings / variables which I have to set so that R 
recognises that Tcl/Tk support is installed on the system?

Rainer


-- 
NEW TELEPHONE NUMBER
Tel:+27 - (0)72 808 2975 (w)

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


[R] install.packages under SuSE 10 behind proxy, R 2.2.0 from source

2005-10-26 Thread Rainer M. Krug
Hi

I installed R 2.2.0 from source and want to use install.packages but it 
doesn't work.

http_proxy is set to http://proxy.sun.ac.za:3128

but it still can't connect to the repository.
The mirror is available, I can connect to it via the internet.

Any help welcome,

Rainer



-- 
NEW TELEPHONE NUMBER
Tel:+27 - (0)72 808 2975 (w)

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


[R] Show Progress in loop

2005-10-10 Thread Rainer M. Krug
Hi

I have a loop which is doing time consuming calculations and I would 
like to be able to have some feedback on where it is in it's 
calculations. I tried to simply show the counter variable in the loop, 
but id doesn't work as all display seems to be delayed until the loop is 
completed. Is there any way of displaying the progress of a loop?

Rainer

The loop:

for (i in 2:Result$NoSims)
{
ppp - runifpoint(Result$NoPlants)
K - Kest(ppp)
Result$LSim[i,] - sqrt(K$iso / pi) - K$r
CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1])
Result$SigCM[i] - sum(CM, na.rm=TRUE)
i  #Doesn't display in the loop
}

-- 
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

__
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


Re: [R] Show Progress in loop

2005-10-10 Thread Rainer M. Krug
I put print(i) in the loop instead of i, but it still only prints (in 
the Windows R GUI) i after it finished the calculations.
I guess it might be due to the output buffering you mentioned - but how 
do I unset it?

Rainer

Peter Dalgaard wrote:
 Rainer M. Krug [EMAIL PROTECTED] writes:
 
 
Hi

I have a loop which is doing time consuming calculations and I would 
like to be able to have some feedback on where it is in it's 
calculations. I tried to simply show the counter variable in the loop, 
but id doesn't work as all display seems to be delayed until the loop is 
completed. Is there any way of displaying the progress of a loop?

Rainer

The loop:

for (i in 2:Result$NoSims)
{
  ppp - runifpoint(Result$NoPlants)
  K - Kest(ppp)
  Result$LSim[i,] - sqrt(K$iso / pi) - K$r
  CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1])
  Result$SigCM[i] - sum(CM, na.rm=TRUE)
  i  #Doesn't display in the loop
}
 
 
 Just print(i) and if on Windows, remember to unset output buffering. 
 



-- 
NEW TELEPHONE NUMBER
Tel:+27 - (0)72 808 2975 (w)

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


Re: [R] Show Progress in loop

2005-10-10 Thread Rainer M. Krug
Thanks - flush.console() did the trick.

As you might guess, I am quite new to R. I like the idea of vectorizing 
the calculation, but I guess it is not possible in this case - I will 
ask in a new thread.

Thanks,

Rainer


Uwe Ligges wrote:
 Rainer M. Krug wrote:
 
 Hi

 I have a loop which is doing time consuming calculations and I would 
 like to be able to have some feedback on where it is in it's 
 calculations. I tried to simply show the counter variable in the loop, 
 but id doesn't work as all display seems to be delayed until the loop 
 is completed. Is there any way of displaying the progress of a loop?

 Rainer

 The loop:

 for (i in 2:Result$NoSims)
 {
 ppp - runifpoint(Result$NoPlants)
 K - Kest(ppp)
 Result$LSim[i,] - sqrt(K$iso / pi) - K$r
 CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1])
 Result$SigCM[i] - sum(CM, na.rm=TRUE)
 i  #Doesn't display in the loop
 }

 
 
 - Update your console (I guess you are on Windows?) by using 
 flush.console().
 - You might want to measure time consumption, hence see ?Rprof.
 - Save some more time by moving as much as possible out of your loop by 
 doing it in a vectorized way (I don't know all the functions you are 
 using, hence cannot make any further recommendations).
 
 Uwe Ligges



-- 
NEW TELEPHONE NUMBER
Tel:+27 - (0)72 808 2975 (w)

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


[R] Vectorizing loop

2005-10-10 Thread Rainer M. Krug
Hi

I have the following loop and would like to vectorize it. Any ideas if 
it is possible?

Thanks,

Rainer

Tha Loop:

for (i in 2:Result$NoSims)
{
ppp - runifpoint(Result$NoPlants)
K - Kest(ppp)
Result$LSim[i,] - sqrt(K$iso / pi) - K$r
CM - (Result$LSim[i,] * Result$LSim[i,]) / abs(K$r[2] - K$r[1])
Result$SigCM[i] - sum(CM, na.rm=TRUE)
print(i)
flush.console()
}








-- 
NEW TELEPHONE NUMBER
Tel:+27 - (0)72 808 2975 (w)

Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation
Biology (UCT)

Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa

Tel:+27 - (0)72 808 2975 (w)
Fax:+27 - (0)21 808 3304
Cell:   +27 - (0)83 9479 042

email:  [EMAIL PROTECTED]
[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


  1   2   >