[R] Problems with passing ... to a function

2005-12-22 Thread Ales Ziberna
Dear useRs!



I have written a function that should pass argument m to the next 
function, however it does not! Please have a look at the function below that 
shows a problem and tell me what I am missing. As you can see, the blocks 
argument is passed corectly, while m is not.



Best,

Ales Ziberna





 opt.par.new-function(
 #function for optimizig partition in blockmodeling
 M, #matrix
 clu, #initial partition
 maxiter=50, #maximum number of iterations
 trace.iter=FALSE, #save a result of each iteration or only the best 
(minimal error)
 switch.names=is.null(BLOCKS), #should partitions that only differ in group 
names be considert equal (is c(1,1,2)==c(2,2,1))
 save.initial.param=TRUE, #should the initial parameters be saved
 approach,
 ... #other arguments to called functions - to 'crit.fun'
){

 
if(save.initial.param)initial.param-tryCatch(lapply(as.list(sys.frame(sys.nframe())),eval),error=function(...)return(error))#saves
 the inital parameters f-function(blocks,...)(print(blocks)) f(...) 
f-function(m,...)(print(m)) 
f(...)}opt.par.new(M=M,m=1,clu=rep(1:2,times=c(7,8)),blocks=c(null,reg),approach=val)

__
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] Huber location estimate

2005-12-22 Thread Prof Brian Ripley
On Thu, 22 Dec 2005, Murray Jorgensen wrote:

 We have a choice when calculating the Huber location estimate:
  set.seed(221205)
  y - 7 + 3*rt(30,1)

That's Cauchy, BTW, a very extreme case.

  library(MASS)
  huber(y)$mu
 [1] 5.9117
  coefficients(rlm(y~1))
 (Intercept)
  5.9204

 I was surprised to get two different results. The function huber() works
  directly with the definition whereas rlm() uses iteratively reweighted
 least squares.

 My surprise is because I vaguely remember

 @ARTICLE{hw77,
   author  = {Holland, P. W. and Welsch, R. E.},
   title   = {Robust Regression using Iteratively Reweighted Least-Squares},
   journal = {Communications in Statistics: Theory and Methods},
   volume  = {A6(9)},
   number  = {},
   pages   = {813-827},
   year= {1977}
 }
 as saying that the two methods were equivalent. Obviously they aren't
 quite. Comments welcome.

Scale estimation differs.  You have (unfairly to the uncredited author) 
not included all the output:

 huber(y)
$mu
[1] 5.911719

$s
[1] 4.096697

 rlm(y~1)
Call:
rlm(formula = y ~ 1)
Converged in 5 iterations

Coefficients:
(Intercept)
5.920354

Degrees of freedom: 30 total; 29 residual
Scale estimate: 3.75

Note that the huber() scale estimate is the initial MAD, whereas rlm 
iterates.  Because during iteration the 'center' for MAD is known to be 
zero, the results differ.  For symmetric distributions there is little 
difference, but your sample is not close to symmetric.

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

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


[R] program work

2005-12-22 Thread Enrico Pavan - TSW
Hi i'm enrico pavan and I work for TSW in Treviso, Italy and also I
study Statistic at Treviso's University. TSW is an agency that work in
search engine marketing and with R we would like to make some statistic
about the site web work using logs file. Is it possible with R? Does R
support and read logs file?

I'll wait a reply,

Best Regard

 

Enrico Pavan

Stat. Analytic


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


[R] Hiding a function from ls()

2005-12-22 Thread Erich Neuwirth
I need to define a small helper function
which should not be listed by ls().
What is the best and cleanest way of achieving this?

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-38624 Fax: +43-1-4277-9386

__
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] Huber location estimate

2005-12-22 Thread Murray Jorgensen


Prof Brian Ripley wrote:
 On Thu, 22 Dec 2005, Murray Jorgensen wrote:
 
 We have a choice when calculating the Huber location estimate:
  set.seed(221205)
  y - 7 + 3*rt(30,1)
 
 
 That's Cauchy, BTW, a very extreme case.

Sure, the sort of situation where one might want a robust estimator.

[...]

 Note that the huber() scale estimate is the initial MAD, whereas rlm 
 iterates.  Because during iteration the 'center' for MAD is known to be 
 zero, the results differ.  For symmetric distributions there is little 
 difference, but your sample is not close to symmetric.

[Blush] yes I knew that and somehow I forgot. But leave rlm() alone for 
a while and do IRLS with fixed scale:

th - median(y)
s - mad(y)
# paste this in a few times:
w - ifelse((y-th 1.345*s  y-th-1.345*s), 1, 1.345*s/abs(y-th))
th - weighted.mean(y,w)
th

We converge to
  th
[1] 5.9203
close to the answer given by rlm() different from
  huber(y)$mu
[1] 5.9117

So the variable scale does not account for the difference.

Murray Jorgensen

-- 
Dr Murray Jorgensen  http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: [EMAIL PROTECTED]Fax 7 838 4155
Phone  +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862

__
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] Hiding a function from ls()

2005-12-22 Thread Martin Maechler
 Erich == Erich Neuwirth [EMAIL PROTECTED]
 on Thu, 22 Dec 2005 10:06:38 +0100 writes:

Erich I need to define a small helper function
Erich which should not be listed by ls().

Erich What is the best and cleanest way of achieving this?

it depends:

1) if it's part of a package, the best and cleanest is 
   - have the package use a namespace
   - do nothing special at, so your helper function is not
  exported from the namespace, and hence not much visible at all.
 
   The encouraged use of much more such helper function
   (i.e. modular programming) is one prominent reason
   for using name spaces.

2) If it's just part of a small script  {anything else should be
   in a package anyway :-)},

   just start the function name with a . (dot).
   Then, ls() only would list it when used with the additional
   argument setting  ls(...,  all.names = TRUE)


Martin Maechler, ETH Zurich

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


Re: [R] bivariate kernel density estimates at point locations (rather than at grid locations)

2005-12-22 Thread Adelchi Azzalini
On Wed, 21 Dec 2005 12:21:54 -0500, Strickland, Matthew wrote:

SM Hello Dr. Adelchi Azzalini,
SM 


Dr. Strickland, 

your message was directed to the whole r-help list with no CC to
myself, and sometimes I do not have the chance to browse the
 r-help list for weeks..

SM Thank you for your quick response to my question that I posted on
SM the r-help board about bivariate kernel density estimates.  I have
SM been using your sm package the past few days and have encountered
SM a problem with estimating the density for only 1 point. I am using
SM R 2.2.0, sm version 2.1-0 on a Windows machine.  Example code
SM below:
SM 
SM #The code below creates 3 point locations
SM 
SM x.locs = c(74, 75, 77)
SM y.locs = c(64, 63, 61)
SM points = cbind(x.locs, y.locs)
SM 
SM #If I send this data into sm.density everything works fine.
SM 
SM dens = sm.density(points, h=c(1, 1))
SM 
SM #However, if I only wish to send 1 point location to sm.density,
SM #i.e.,
SM 
SM points.2 =points[1,]
SM dens.2 = sm.density(points.2, h=c(1, 1)) 
SM 
SM R returns to me the error:length(h) != 1

formally, the error is due to this

R is.vector(points.2)
[1] TRUE

sm.density receives a vector of length 2, and it  works for that
case: estimation of a one-dimensional density from which you
supplied two data values. Then it finds a two-dimensional h
and there it complains.

On the statistical side, I cannot follow the logic of estimating
nonparametrically a density function on the basis of only one 
(supposed bivariate) observation.

SM 
SM It appears to me that sm.density thinks that my 1 point is a
SM 1-dimensional location rather than a 2-dimensional location, and I
SM am getting an error when I request a bivariate kernel.  Do you
SM have any suggestions?  
SM 

I am not sure to grasp what you have in mind; is it perhaps that you
want the following?

dens.2 = sm.density(points, h=c(1, 1), eval.points=points, eval.grid=FALSE) 
print(dens.2$estimate[1])

best regards,

Adelchi


SM Best,
SM Matt
SM 
SM 
SM -Original Message-
SM From: Adelchi Azzalini [mailto:[EMAIL PROTECTED] 
SM Sent: Friday, December 16, 2005 2:42 AM
SM To: Strickland, Matthew
SM Cc: r-help@stat.math.ethz.ch; [EMAIL PROTECTED]
SM Subject: Re: [R] bivariate kernel density estimates at point
SM locations (rather than at grid locations)
SM 
SM On Thu, 15 Dec 2005 14:21:17 -0500, Strickland, Matthew wrote:
SM 
SM SM Hi,
SM SM 
SM SM My data consists of a set of point locations (x,y). 
SM SM 
SM SM I would like to know if there is a procedure for bivariate
SM SM kernel  density estimation in R that returns the density
SM SM estimates at the  observed point locations rather than at grid
SM SM locations. I have  looked at a number of different routines
SM SM and they all seem to return  estimates at grid locations.
SM SM 
SM 
SM One option is to use (from package sm),
SM   sm.density(xy, eval.points=xy, eval.grid=FALSE) where xy in a
SM   (n\times 2) matrix.
SM 
SM Best wishes,
SM Adelchi Azzalini
SM 
SM --
SM Adelchi Azzalini  [EMAIL PROTECTED] Dipart.Scienze
SM Statistiche, Università di Padova, Italia tel. +39 049 8274147, 
SM http://azzalini.stat.unipd.it/
SM 
SM __
SM R-help@stat.math.ethz.ch mailing list
SM https://stat.ethz.ch/mailman/listinfo/r-help
SM PLEASE do read the posting guide!
SM http://www.R-project.org/posting-guide.html
SM

__
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] Huber location estimate

2005-12-22 Thread Martin Maechler
 Murray == Murray Jorgensen [EMAIL PROTECTED]
 on Thu, 22 Dec 2005 22:13:45 +1300 writes:

Murray Prof Brian Ripley wrote:
 On Thu, 22 Dec 2005, Murray Jorgensen wrote:
 
 We have a choice when calculating the Huber location estimate:
  set.seed(221205)
  y - 7 + 3*rt(30,1)
 
 
 That's Cauchy, BTW, a very extreme case.

Murray Sure, the sort of situation where one might want a robust estimator.

Murray [...]

 Note that the huber() scale estimate is the initial MAD, whereas rlm 
 iterates.  Because during iteration the 'center' for MAD is known to be 
 zero, the results differ.  For symmetric distributions there is little 
 difference, but your sample is not close to symmetric.

Murray [Blush] yes I knew that and somehow I forgot. But leave rlm() alone 
for 
Murray a while and do IRLS with fixed scale:

Murray th - median(y)
Murray s - mad(y)
Murray # paste this in a few times:
Murray w - ifelse((y-th 1.345*s  y-th-1.345*s), 1, 1.345*s/abs(y-th))
Murray th - weighted.mean(y,w)
Murray th

Murray We converge to
 th
Murray [1] 5.9203
Murray close to the answer given by rlm() different from
 huber(y)$mu
Murray [1] 5.9117

Murray So the variable scale does not account for the difference.

No, the main difference is the different default:  
huber() has  k=1.5
and rlm()   has  k=1.345 :

Try this

set.seed(221205)
y - 7 + 3*rt(30,1)

str(huber(y, k = 1.345), digits = 5)
## List of 2
##  $ mu: num 5.9203
##  $ s : num 4.0967

str(rlm(y ~ 1)[c(coefficients, s)], digits = 5) #
## (edited to)
##  $ coefficients: num 5.9204
##  $ s   : num 3.7463

which gives 'mu' very close, even for the iterated
vs. non-iterated scales.

Martin Maechler, ETH Zurich

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


Re: [R] Problems with passing ... to a function

2005-12-22 Thread Ales Ziberna
Thanks to the helpful R-hlep-er, the problem has been solved.
'm' was matching 'maxiter'.

Thanks again,
Ales Ziberna

- Original Message - 
From: Ales Ziberna [EMAIL PROTECTED]
To: R-help r-help@stat.math.ethz.ch
Sent: Thursday, December 22, 2005 9:25 AM
Subject: Problems with passing ... to a function


Dear useRs!



I have written a function that should pass argument m to the next
function, however it does not! Please have a look at the function below that
shows a problem and tell me what I am missing. As you can see, the blocks
argument is passed corectly, while m is not.



Best,

Ales Ziberna





 opt.par.new-function(
 #function for optimizig partition in blockmodeling
 M, #matrix
 clu, #initial partition
 maxiter=50, #maximum number of iterations
 trace.iter=FALSE, #save a result of each iteration or only the best
(minimal error)
 switch.names=is.null(BLOCKS), #should partitions that only differ in group
names be considert equal (is c(1,1,2)==c(2,2,1))
 save.initial.param=TRUE, #should the initial parameters be saved
 approach,
 ... #other arguments to called functions - to 'crit.fun'
){

 
if(save.initial.param)initial.param-tryCatch(lapply(as.list(sys.frame(sys.nframe())),eval),error=function(...)return(error))#savesthe
 inital parameters f-function(blocks,...)(print(blocks)) 
f(...)f-function(m,...)(print(m))f(...)}opt.par.new(M=M,m=1,clu=rep(1:2,times=c(7,8)),blocks=c(null,reg),approach=val)

__
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] Huber location estimate

2005-12-22 Thread Murray Jorgensen
D'oh!  Apologies for wasting everybody's time!

Murray

Martin Maechler wrote:
Murray == Murray Jorgensen [EMAIL PROTECTED]
on Thu, 22 Dec 2005 22:13:45 +1300 writes:
 
 
 Murray Prof Brian Ripley wrote:
  On Thu, 22 Dec 2005, Murray Jorgensen wrote:
  
  We have a choice when calculating the Huber location estimate:
   set.seed(221205)
   y - 7 + 3*rt(30,1)
  
  
  That's Cauchy, BTW, a very extreme case.
 
 Murray Sure, the sort of situation where one might want a robust 
 estimator.
 
 Murray [...]
 
  Note that the huber() scale estimate is the initial MAD, whereas rlm 
  iterates.  Because during iteration the 'center' for MAD is known to 
 be 
  zero, the results differ.  For symmetric distributions there is little 
  difference, but your sample is not close to symmetric.
 
 Murray [Blush] yes I knew that and somehow I forgot. But leave rlm() 
 alone for 
 Murray a while and do IRLS with fixed scale:
 
 Murray th - median(y)
 Murray s - mad(y)
 Murray # paste this in a few times:
 Murray w - ifelse((y-th 1.345*s  y-th-1.345*s), 1, 1.345*s/abs(y-th))
 Murray th - weighted.mean(y,w)
 Murray th
 
 Murray We converge to
  th
 Murray [1] 5.9203
 Murray close to the answer given by rlm() different from
  huber(y)$mu
 Murray [1] 5.9117
 
 Murray So the variable scale does not account for the difference.
 
 No, the main difference is the different default:  
 huber() has  k=1.5
 and rlm()   has  k=1.345 :
 
 Try this
 
 set.seed(221205)
 y - 7 + 3*rt(30,1)
 
 str(huber(y, k = 1.345), digits = 5)
 ## List of 2
 ##  $ mu: num 5.9203
 ##  $ s : num 4.0967
 
 str(rlm(y ~ 1)[c(coefficients, s)], digits = 5) #
 ## (edited to)
 ##  $ coefficients: num 5.9204
 ##  $ s   : num 3.7463
 
 which gives 'mu' very close, even for the iterated
 vs. non-iterated scales.
 
 Martin Maechler, ETH Zurich

-- 
Dr Murray Jorgensen  http://www.stats.waikato.ac.nz/Staff/maj.html
Department of Statistics, University of Waikato, Hamilton, New Zealand
Email: [EMAIL PROTECTED]Fax 7 838 4155
Phone  +64 7 838 4773 wkHome +64 7 825 0441Mobile 021 1395 862

__
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] Logistic regression to select genes and estimate cutoff point?

2005-12-22 Thread Ido M. Tamir
You could take a look at www.bioconductor.org
limma would be a good starting point.

hth
ido

__
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] No PNG support 2.2.1

2005-12-22 Thread Sylvain Brohée
Hi everybody,

When trying to save my plots as PNG images, I get this error message?
Can anybody give me a solution?

 png(my_plot.png)
Error in X11(paste(png::, filename, sep = ), width, height, pointsize,  :
unable to start device PNG
In addition: Warning message:
no png support in this version of R

Thank you very much,

Sylvain

-- 
Sylvain Brohée

Service de Conformation des Macromolécules
Biologiques et de Bioinformatique (SCMBB)   
Université Libre de Bruxelles   
Boulevard du Triomphe - CP263   
1050 Bruxelles (Belgium)
Tel : +32(0)2/650.54.34
Fax : +32(0)2/650.54.25

__
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] program work

2005-12-22 Thread Ido M. Tamir
 Does R support and read logs file?
R can read log files if they are text files.
?read.table

hth
ido

__
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] No PNG support 2.2.1

2005-12-22 Thread Sylvain Brohée
I am effectively running R under Suse linux 9.2... However libpng is compiled 
and works!
Thanks ,

Sylvain


On Thursday 22 December 2005 12:02, Landini Massimiliano wrote:
 On Thu, 22 Dec 2005 12:01:00 +0100, you wrote:
 |=[:o)  Hi everybody,
 |=[:o)
 |=[:o)  When trying to save my plots as PNG images, I get this error
 | message? =[:o)  Can anybody give me a solution?
 |=[:o)
 |=[:o)   png(my_plot.png)
 |=[:o)  Error in X11(paste(png::, filename, sep = ), width, height,
 | pointsize,  : =[:o)  unable to start device PNG
 |=[:o)  In addition: Warning message:
 |=[:o)  no png support in this version of R
 |=[:o)
 |=[:o)  Thank you very much,
 |=[:o)

 you are using kmail so i think that your OS is *nix: do you have libpng
 compiled???

 ;o)

 |=[:o)  Sylvain
 |=[:o)
 |=[:o)  --
 |=[:o)  Sylvain Brohée
 |=[:o)
 |=[:o)  Service de Conformation des Macromolécules
 |=[:o)  Biologiques et de Bioinformatique (SCMBB)
 |=[:o)  Université Libre de Bruxelles
 |=[:o)  Boulevard du Triomphe - CP263
 |=[:o)  1050 Bruxelles (Belgium)
 |=[:o)  Tel : +32(0)2/650.54.34
 |=[:o)  Fax : +32(0)2/650.54.25
 |=[:o)
 |=[:o)  __
 |=[:o)  R-help@stat.math.ethz.ch mailing list
 |=[:o)  https://stat.ethz.ch/mailman/listinfo/r-help
 |=[:o)  PLEASE do read the posting guide!
 | http://www.R-project.org/posting-guide.html

 ---
-- Landini dr. Massimiliano
 Tel. mob. (+39) 347 140 11 94
 Tel./Fax. (+39) 051 762 196
 e-mail: numero (dot) primo (at) tele2 (dot) it
 ---
-- Legge di Hanggi: Più stupida
 è la tua ricerca, più verrà letta e approvata. Corollario alla Legge di
 Hanggi: Più importante è la tua ricerca, meno verrà capita.
 ---
--

-- 
Sylvain Brohée

Service de Conformation des Macromolécules
Biologiques et de Bioinformatique (SCMBB)   
Université Libre de Bruxelles   
Boulevard du Triomphe - CP263   
1050 Bruxelles (Belgium)
Tel : +32(0)2/650.54.34
Fax : +32(0)2/650.54.25

__
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] strsplit with dataframes

2005-12-22 Thread Henrik Andersson
Hello fellow R people,

I can not figure out a pretty way to use strplit with vectors

Imagine that I got the following data from someone with ID's 
representing several factors

ID  data
A1-B1-t10
A1-B1-t21
A1-B2-t15
A1-B2-t210
A1-B10-t1   0
A1-B10-t2   1
A1-B20-t1   5
A1-B20-t2   10

...

I would like to turn this dataframe to

station substation time data
A1  B1  t1  0
A1  B1  t2  1
A1  B2  t1  5
A1  B2  t2  10
A1  B10 t1  0
A1  B10 t2  1
A1  B20 t1  5
A1  B20 t2  10
...

This must surely be done easily, but there are not an example like this 
in ?strsplit

Cheers,
-
Henrik Andersson
Netherlands Institute of Ecology -
Centre for Estuarine and Marine Ecology
P.O. Box 140
4400 AC Yerseke
Phone: +31 113 577472
[EMAIL PROTECTED]
http://www.nioo.knaw.nl/ppages/handersson

__
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] strsplit with dataframes

2005-12-22 Thread Jacques VESLOT
try:
cbind.data.frame(do.call(rbind, strsplit(as.character(yourdf$ID), 
-)), yourdf$data)



Henrik Andersson a écrit :

Hello fellow R people,

I can not figure out a pretty way to use strplit with vectors

Imagine that I got the following data from someone with ID's 
representing several factors

ID data
A1-B1-t1   0
A1-B1-t2   1
A1-B2-t1   5
A1-B2-t2   10
A1-B10-t1  0
A1-B10-t2  1
A1-B20-t1  5
A1-B20-t2  10

...

I would like to turn this dataframe to

station substation time data
A1 B1  t1  0
A1 B1  t2  1
A1 B2  t1  5
A1 B2  t2  10
A1 B10 t1  0
A1 B10 t2  1
A1 B20 t1  5
A1 B20 t2  10
...

This must surely be done easily, but there are not an example like this 
in ?strsplit

Cheers,
-
Henrik Andersson
Netherlands Institute of Ecology -
Centre for Estuarine and Marine Ecology
P.O. Box 140
4400 AC Yerseke
Phone: +31 113 577472
[EMAIL PROTECTED]
http://www.nioo.knaw.nl/ppages/handersson

__
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-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] Plot problems: xlim

2005-12-22 Thread Ronnie Babigumira
Hi,
Still fresh in R, tried to figure this out, now on my second day running with 
no luck (and a pile of hair on my desk) so 
I have thrown in the towel and would like to ask for some help.

Here is what I am trying to do. I am trying to plot a distribution, I have 99 
points, bound in the range

xlim.min: -0.0173
xlim.max: 0.02103

However, I have a value outside this range (0.2454959) which I would like to 
add to the plot as a line and to do this I 
use abline(v=0.2454959)

This is what I write

 xlim = c(-0.02, 0.3)
 denz - density(morp)
 plot.density(denz, xlim = xlim, ylim = c(0,70))
 hist(morp, freq=F, add= T)
 abline(v=0.2454959)

Without any options, plot.density spreads out nicely, however, naturally, the 
line I want to add is not plotted since it 
is well outside the range automatically determined by plot.density hence the 
need to add xlim however this produces 
something I dont find aesthetically appealing. The plot is squeezed out into a 
very lean bell shape.

So (finally) my question, how can i widen the spread of my plot and yet also be 
able to add my xline.

Many thanks

Ronnie

__
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] Plot problems: xlim

2005-12-22 Thread Jacques VESLOT
Please give an example of your data.

set.seed(231) 
morp - rnorm(20)
range(morp)
[1] -2.311664  1.650254

You can plot 2 histograms, one of them with the extreme value:

par(mfrow=c(2,1))
hist(morp, breaks=10, freq=F)
lines(density(morp))
par(mfrow=c(1,2))
hist(morp, breaks=10, freq=F)
lines(density(morp))
hist(morp, breaks=seq(min(morp), max(morp), length=10), xlim=c(-3, 13), 
freq=F)
lines(density(morp))
abline(v=7.5, lty=3)


Ronnie Babigumira a écrit :

Hi,
Still fresh in R, tried to figure this out, now on my second day running with 
no luck (and a pile of hair on my desk) so 
I have thrown in the towel and would like to ask for some help.

Here is what I am trying to do. I am trying to plot a distribution, I have 99 
points, bound in the range

xlim.min: -0.0173
xlim.max: 0.02103

However, I have a value outside this range (0.2454959) which I would like to 
add to the plot as a line and to do this I 
use abline(v=0.2454959)

This is what I write

 xlim = c(-0.02, 0.3)
 denz - density(morp)
 plot.density(denz, xlim = xlim, ylim = c(0,70))
 hist(morp, freq=F, add= T)
 abline(v=0.2454959)

Without any options, plot.density spreads out nicely, however, naturally, the 
line I want to add is not plotted since it 
is well outside the range automatically determined by plot.density hence the 
need to add xlim however this produces 
something I dont find aesthetically appealing. The plot is squeezed out into a 
very lean bell shape.

So (finally) my question, how can i widen the spread of my plot and yet also 
be able to add my xline.

Many thanks

Ronnie

__
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-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 Rmpi on Fedora with mpich2 installed.

2005-12-22 Thread vittorio
I don't know Fedora but you should have installed the dev(-elopment) packages 
too (like mpich-dev or similar for instance). Usually under unixes those 
supplementary packages contain all the header files such as mpi.h  needed to 
compile a C program.

Vittorio 

Alle 20:45, martedì 20 dicembre 2005, Ye, Bin ha scritto:
 Thank you very much, Martin! I've tried that already, but it still can't
 find the mpi.h file.

 Any other suggestions?



 Bin


 -Original Message-
 From: Martin Morgan [mailto:[EMAIL PROTECTED]
 Sent: Tue 12/20/2005 2:58 PM
 To: Ye, Bin
 Subject: Re: [R] Install Rmpi on Fedora with mpich2 installed.

 Hi Bin,

 I don't have direct experience installing Rmpi on mpich2, but you can
 specify the location of the mpi.h files with commands like

 ./configure --with-mpi=/usr/local/mpich2

 when in the unpacked Rmpi packate, or

 R CMD INSTALL Rmpi_... --configure-args=--with-mpi=/usr/local/mpich2

 when installing the package from the command line.  The ... are the
 results of tab completion to the Rmpi tarball, and the path
 /usr/local/mpich2 should lead to a direcotry hierarchy such that mpi.h
 will be found in something like /usr/local/mpich2/include/mpi.h (some
 insight into what is going on is in the configure.in file).

 Hope that helps!

 Martin

 Ye, Bin [EMAIL PROTECTED] writes:
  Hi, everyone,
 
  I want to install Rmpi on a cluster with Fedora linux. It already
  installed mpich2, but not lam-mpi. I installed R-2.2.0 on it already.
 
  And I got error as below:
 
  * Installing *source* package 'Rmpi' ...
  Try to find mpi.h ...
  checking for gcc... gcc
  checking for C compiler default output file name... a.out
  checking whether the C compiler works... yes
  checking whether we are cross compiling... no
  checking for suffix of executables...
  checking for suffix of object files... o
  checking whether we are using the GNU C compiler... yes
  checking whether gcc accepts -g... yes
  checking for gcc option to accept ANSI C... none needed
  checking how to run the C preprocessor... gcc -E
  checking for egrep... grep -E
  checking for ANSI C header files... yes
  checking for sys/types.h... yes
  checking for sys/stat.h... yes
  checking for stdlib.h... yes
  checking for string.h... yes
  checking for memory.h... yes
  checking for strings.h... yes
  checking for inttypes.h... yes
  checking for stdint.h... yes
  checking for unistd.h... yes
  checking mpi.h usability... no
  checking mpi.h presence... no
  checking for mpi.h... no
  Try to find mpi.h ...
  Cannot find mpi head file
  Please check if --with-mpi=/usr/local/mpich2/bin/ is right
  ERROR: configuration failed for package 'Rmpi'
  ** Removing '/usr/local/R-2.2.0/library/Rmpi'
 
  Somehow it can not find the mpi.h which is in usr/local/mpich2. Can
  anyone kindly give me some hint on what should be done? Will installing
  lam-mpi solve the problem? If so, should mpich2 be uninstalled first? Or
  just modify the path will do?
 
  Thanks a lot!
 
 
  Bin
 
  __
  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-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-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] panel order in xyplot

2005-12-22 Thread Antje Döring
Hi all,

 

I have a question concerning xyplot. My data is a data.frame looking like that:

 

In the first column I have numbers from 0 to 23 (hours of a day), the second 
column contains the name of a weekday (Day as factor) and the third column 
contains the number I am interested in. So as an example, the first five rows 
look like that:

 

Hour Day Freq

1 0  Mo23

2 1  Mo20

3 2  Mo14

4 3  Mo27

5 4  Mo26

 

To read: On Monday between 0 and 1 o'clock 23 things happened. 

 

The code of the xyplot looks like that:

 

trellis.device(new = FALSE, col = FALSE)

xyplot(Freq ~ Hour | Day, data = mydata,

   xlab = hour, ylab = number, main = xxx, ylim = 1:30,

   scales = list(x = list(at = seq(0,24,6), labels = c(0, 6, 12, 18, 24), 
cex = 0.7, relation = free), 

   y = list(tick.number = 5, cex = 0.7)), between = list(x = 0.5, y = 1.5), 

   layout = c(4,2), aspect = 1,

   panel = function(x,y){

 panel.grid()

  panel.barchart(x, y, horiz = F, aspect = 1, col = red)

   }

   )

 

Now my problem:

The plot is ordered by default, that in the first row I can see Friday, 
Saturday and Sunday, in the second row there is Monday, Tuesday, Wednesday and 
Thursday. I like to order the panels that way that in the first row there 
should be Monday-Thursday, the last row to contain Friday - Sunday. 

Is there any parameter in xyplot I can add to achieve this result? Any 
parameter where I can tell how the panels have to be arranged?

 

Thanks a lot for any help. 

 

Antje


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


Re: [R] Logistic regression to select genes and estimate cutoff point?

2005-12-22 Thread Frank E Harrell Jr
Lingsheng Dong wrote:
 Hi, all, 
 I am new to R or even to statistics. Not sure if the question has a answer. 
 But I couldn't find a straight forward answer in the help mailing list. 
 I need use MicroArray data to select several diagnostic genes between Normal 
 samples and Tumor samples and use these genes to predict unknow samples.
 Since the sample size is so small and data doesn't follow normal 
 distribution, I am thinking to use logistic regression instead of Student T 
 test to select genes. To make the problem simpler, I assume each gene is 
 independent to each other without interactions.
 My questions is how I should build up the model: one model for each gene or a 
 multiple variable model to include all genes? Which is the test to compare 
 the discrimination power of each gene? I am thinking it is Wald statistic for 
 the multiple variable model and Maximum likelihood for the single gene 
 models? Am I  correct?
 To estimate the cutoff point, I guess the answer is the gene expression when 
 p=0.5 in the model. Am I on the right direction?
 Any suggestion is appreciated!
 Thanks a lot.
 Lingsheng 

Just a comment: Do you not have a statistician to work with at your 
institution?  You are new to statistics and are asking a question that 
would be very difficult to deal with for someone with a PhD in 
statistics and 20 years of experience.  Some of the issues involved are 
multiple comparisons, false discovery rate, shrinkage, array geometry 
effects, nonparametric vs. parametric statistics, stability of selected 
genes, discovery validation, ...

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

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


[R] data frame

2005-12-22 Thread Rhett Eckstein
Dear R users:

 s4 - seq(length=10, from=1, by=5)
 s-data.frame(s4,s4,s4)
I would like to do some modification to s.
And I want the form like the following,if it is possible, how should I do?
The last column is the sum of previous three column.
   s4 s4.1 s4.2sum
1   11
26   6
3   11112
4   16622
5   21   111 33
6   26   166 48
7   3121   11   63
8   3626   16   78
9   4131   21   93
10 4636   26   108


Thanks for any help !!

__
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] bVar slot of lmer objects and standard errors

2005-12-22 Thread Ulrich Keller
Hello,

I am looking for a way to obtain standard errors for emprirical Bayes estimates 
of a model fitted with lmer (like the ones plotted on page 14 of the document 
available at 
http://www.eric.ed.gov/ERICDocs/data/ericdocs2/content_storage_01/000b/80/2b/b3/94.pdf).
 Harold Doran mentioned 
(http://tolstoy.newcastle.edu.au/~rking/R/help/05/08/10638.html) that  the 
posterior modes' variances can be found in the bVar slot of lmer objects. 
However, when I fit e.g. this model:

lmertest1-lmer(mathtot~1+(m_escs_c|schoolid),hlmframe)

then [EMAIL PROTECTED] is a three-dimensional array with dimensions (2,2,28). 
The factor schoolid has 28 levels, and there are random effects for the 
intercept and m_escs_c, but what does the third dimension correspond to? In 
other words, what are the contents of bVar, and how can I use them to get 
standard errors?

Thanks in advance for your answers and Merry Christmas,

Uli Keller

__
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] data frame

2005-12-22 Thread jim holtman
Here is one way.  You can change depending on what you want the offsets to
be:
 s4 - seq(length=10, from=1, by=5)
 s4
 [1]  1  6 11 16 21 26 31 36 41 46
 f.x - function(vec, n) c(rep(0,n), vec)[1:length(vec)]
 f.x(s4,2)
 [1]  0  0  1  6 11 16 21 26 31 36
 df - data.frame(s4=s4, s4.1=f.x(s4,2), s4.2=f.x(s4,4))
 df
   s4 s4.1 s4.2
1   100
2   600
3  1110
4  1660
5  21   111
6  26   166
7  31   21   11
8  36   26   16
9  41   31   21
10 46   36   26
 df$sum - rowSums(df)
 df
   s4 s4.1 s4.2 sum
1   100   1
2   600   6
3  1110  12
4  1660  22
5  21   111  33
6  26   166  48
7  31   21   11  63
8  36   26   16  78
9  41   31   21  93
10 46   36   26 108




On 12/22/05, Rhett Eckstein [EMAIL PROTECTED] wrote:

 Dear R users:

  s4 - seq(length=10, from=1, by=5)
  s-data.frame(s4,s4,s4)
 I would like to do some modification to s.
 And I want the form like the following,if it is possible, how should I do?
 The last column is the sum of previous three column.
   s4 s4.1 s4.2sum
 1   11
 26   6
 3   11112
 4   16622
 5   21   111 33
 6   26   166 48
 7   3121   11   63
 8   3626   16   78
 9   4131   21   93
 10 4636   26   108


 Thanks for any help !!

 __
 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




--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] data frame

2005-12-22 Thread Sean Davis



On 12/22/05 9:11 AM, Rhett Eckstein [EMAIL PROTECTED] wrote:

 Dear R users:
 
 s4 - seq(length=10, from=1, by=5)
 s-data.frame(s4,s4,s4)
 I would like to do some modification to s.
 And I want the form like the following,if it is possible, how should I do?
 The last column is the sum of previous three column.
s4 s4.1 s4.2sum
 1   11
 26   6
 3   11112
 4   16622
 5   21   111 33
 6   26   166 48
 7   3121   11   63
 8   3626   16   78
 9   4131   21   93
 10 4636   26   108

Rhett,

You might want to look at ?embed.  It would need some modification, but you
can hopefully get the idea.

 embed(s4,3)

Sean

__
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] panel order in xyplot

2005-12-22 Thread Deepayan Sarkar
On 12/22/05, Antje Döring [EMAIL PROTECTED] wrote:
 Hi all,



 I have a question concerning xyplot. My data is a data.frame looking like
 that:



 In the first column I have numbers from 0 to 23 (hours of a day), the second
 column contains the name of a weekday (Day as factor) and the third column
 contains the number I am interested in. So as an example, the first five
 rows look like that:



 Hour Day Freq

 1 0  Mo23

 2 1  Mo20

 3 2  Mo14

 4 3  Mo27

 5 4  Mo26



 To read: On Monday between 0 and 1 o'clock 23 things happened.



 The code of the xyplot looks like that:



 trellis.device(new = FALSE, col = FALSE)

 xyplot(Freq ~ Hour | Day, data = mydata,

xlab = hour, ylab = number, main = xxx, ylim = 1:30,

scales = list(x = list(at = seq(0,24,6), labels = c(0, 6, 12, 18,
 24), cex = 0.7, relation = free),

y = list(tick.number = 5, cex = 0.7)), between = list(x = 0.5, y =
 1.5),

layout = c(4,2), aspect = 1,

panel = function(x,y){

  panel.grid()

   panel.barchart(x, y, horiz = F, aspect = 1, col = red)

}

)



 Now my problem:

 The plot is ordered by default, that in the first row I can see Friday,
 Saturday and Sunday, in the second row there is Monday, Tuesday, Wednesday
 and Thursday. I like to order the panels that way that in the first row
 there should be Monday-Thursday, the last row to contain Friday - Sunday.

 Is there any parameter in xyplot I can add to achieve this result?

'as.table'.

 Any parameter where I can tell how the panels have to be arranged?

Deepayan
--
http://www.stat.wisc.edu/~deepayan/

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

[R] add factor to dataframe given ranges

2005-12-22 Thread Albert Vilella
Hi all,

I would like to factorize the entries in a dataframe given some
groupings. E.g:

mydf = data.frame(
  a = rnorm(100,10),
  b = rnorm(100,10),
  c = rgamma(100, 1, scale=1))

group = hist(mydf$c, breaks=FD)
group$breaks

The idea is to create a factor mydf$d with levels corresponding to
the ranges in group$breaks.

There must be an easy way to do this that I haven't found out.

Thanks in advance,

Albert.

__
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] from Colombia - help

2005-12-22 Thread Michael Dewey
At 13:50 20/12/05, andres felipe wrote:
   Hi, my name is Andres Felipe Barrientos, I'm a student of Statistic and 
 don't speak in english. En mi trabajo de grado necesito implementar la 
 funcion smooth.spline y necesito saber con que tipo de spline trabaja 
 (b-splines o naturales).

Since I have not yet seen a reply here goes.
It is very honest of you to tell us it is your 'trabajo de grado' but 
should you not ask your tutor for help?
Have you tried ?smooth.spline which tells you what the function does 
(admittedly fairly tersely)?

   Ademas me gustaria saber cual es la base que se usa para encontrar 
 estos splines, por ejemplo, cosenos, senos, polinomios entre otros 
 Otra pregunta que tengo consiste en saber cual es la relacion que 
 sostiene la funcion smooth.spline y ns Agradeciendo la atencion 
 prestada y esperando una respuesta desde la universidad del valle, quien 
 le escribe. Andres Felipe



-
  1GB gratis, Antivirus y Antispam
  Correo Yahoo!, el mejor correo web del mundo
  Abrí tu cuenta aquí
 [[alternative HTML version deleted]]

Michael Dewey
http://www.aghmed.fsnet.co.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


Re: [R] boot problem

2005-12-22 Thread Angelo Canty
What are you trying to do?  boot does the resampling for you so you should 
pass the statistic that you want calculated on the resamples.  Read the 
helpfile regarding the format of the statistic.  It should take two 
arguments, one of which is a vector of indices specifying the resample.

On Tue, 20 Dec 2005, david v wrote:

 Hello,
 This is the code that is giving me problems
 
 library(boot)
 data-read.table(test,header=FALSE,sep=\t,row.names=1)
 data
   V2 V3 V4
 A  5  8  9
 B 12 54 89
 C   65 89 23
 D   32 69 44
 E   21 84 97
 F   33 59 71
 G   16 45 93
 H2 46 55
 I   22 33 88
 
 resample - function(x,index) {
 sample(data,replace=TRUE)
 }
 dist-boot(data,resample,R=1000)
 Erreur : nombre d'indices incorrect sur la matrice (french)
 Error: number of indices wrong in the matrix (moreless)
 
 Can anybody help???
 
 __
 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
 

-- 
--
|   Angelo J. CantyEmail: [EMAIL PROTECTED] |
|   Mathematics and Statistics Phone: (905) 525-9140 x 27079 |
|   McMaster UniversityFax  : (905) 522-0935 |
|   1280 Main St. W. |
|   Hamilton ON L8S 4K1  |

__
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] add factor to dataframe given ranges

2005-12-22 Thread Marc Schwartz (via MN)
On Thu, 2005-12-22 at 16:58 +0100, Albert Vilella wrote:
 Hi all,
 
 I would like to factorize the entries in a dataframe given some
 groupings. E.g:
 
 mydf = data.frame(
   a = rnorm(100,10),
   b = rnorm(100,10),
   c = rgamma(100, 1, scale=1))
 
 group = hist(mydf$c, breaks=FD)
 group$breaks
 
 The idea is to create a factor mydf$d with levels corresponding to
 the ranges in group$breaks.
 
 There must be an easy way to do this that I haven't found out.
 
 Thanks in advance,
 
 Albert.

See ?cut

Then:

 myfac.c - cut(mydf$c, breaks = group$breaks)

Take note of the additional arguments in cut() relative to the nature of
the interval cutpoints (ie. 'right' and 'include.lowest').

HTH,

Marc Schwartz

__
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] add factor to dataframe given ranges

2005-12-22 Thread Marc Schwartz (via MN)
On Thu, 2005-12-22 at 10:08 -0600, Marc Schwartz (via MN) wrote:
 On Thu, 2005-12-22 at 16:58 +0100, Albert Vilella wrote:
  Hi all,
  
  I would like to factorize the entries in a dataframe given some
  groupings. E.g:
  
  mydf = data.frame(
a = rnorm(100,10),
b = rnorm(100,10),
c = rgamma(100, 1, scale=1))
  
  group = hist(mydf$c, breaks=FD)
  group$breaks
  
  The idea is to create a factor mydf$d with levels corresponding to
  the ranges in group$breaks.
  
  There must be an easy way to do this that I haven't found out.
  
  Thanks in advance,
  
  Albert.
 
 See ?cut
 
 Then:
 
  myfac.c - cut(mydf$c, breaks = group$breaks)


One quick update here which is more clearly based upon your comment
above:

   mydf$d - cut(mydf$c, breaks = group$breaks)

Which will add the resultant factor as a new column 'd' to your existing
mydf.

Marc

__
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] reading long matrix

2005-12-22 Thread Colin Beale
Hi,

I'm needing some help finding a function to read a large text file into an 
array in R. The data are essentially presence / absence / na data for many 
species and come as a grid with each species name (after two spaces) at the 
beginning of the matrix defining the map for that species. An excerpt could 
therefore be:

  SPECIES1
999001099
900110109
011101000
901100101
110100019
901110019

  SPECIES2
99999
900110119
011101100
901010101
11019
90019

  SPECIES3
999001099
900100109
011100010
901100100
110100019
901110019

where 9 is actually na, 0 is absence and 1 presence. The final array I want to 
create should have dimensions that are the x and y coordinates and the number 
of species (known in advance). (In this example dim = c(9,6,3)). It would be 
sort of neat if the code could also read the species name into the appropriate 
names attribute, but this is a refinement that I could probably do if someone 
can help me read the data into R and into an array in the first place. I'm 
currently thinking a line by line approach using readLines might be the best 
option, but I've got a very long file - well over 100 species, each a matrix of 
70 x 100 datapoints. making this option rther time consuming, I expect - 
especially as the next dataset has 1300 species and a much larger grid...

Any hints would be gratefully recieved.

Colin Beale
Macaulay Land Use Research Institute

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


Re: [R] Plot problems: xlim

2005-12-22 Thread Ben Bolker
Ronnie Babigumira rb.glists at gmail.com writes:

   It sounds like you might want to break your axis.
plotrix provides a function to draw the axis break,
but you have to mess around with the data scaling
and axis labels yourself.  See  RSiteSearch(axis 
break); most of these discussions
are about breaking y axes but the same techniques
apply to the x axis.

  good luck,
Ben Bolker

__
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 put constraint in R?

2005-12-22 Thread Spencer Graves
  What are you trying to do?

  Suppose, for example, that you have a categorical variable 
representing 3 different age groups, and you want to estimate a linear 
model.  As long as R recognizes the variable as categorical (of class 
factor or ordered factor, R handles this automatically using 
contrasts.  If this is your question, I suggest you read about 
factors, Formulae for Statistical Models and Contrasts in An 
Introduction to R, which is the upper-left choice after 'help.start()' 
in recent versions of R (or downloadable from www.r-project.org - 
Documentation - Manuals).

  If you would like more help from this group, I believe you will 
increase your chances of getting quickly the information you seek in you 
PLEASE do read the posting guide! www.R-project.org/posting-guide.html.

  hope this helps.
  spencer graves

Oana Mocila wrote:

 Dear all,
 
 I have a problem when I was working on Age-Period-Cohort study in R. I tried 
 to put constraint to
 two coefficients on age (so that to solve the identification problem due to 
 linear dependency). But
 I don't know how to do this in R(put constraint). If you could give me some 
 suggestion, it will be very helpful!
 
 Oana
 
 __
 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

-- 
Spencer Graves, PhD
Senior Development Engineer
PDF Solutions, Inc.
333 West San Carlos Street Suite 700
San Jose, CA 95110, USA

[EMAIL PROTECTED]
www.pdf.com http://www.pdf.com
Tel:  408-938-4420
Fax: 408-280-7915

__
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] reading long matrix

2005-12-22 Thread jim holtman
Here is a way of reading the data into a 'list'.  You can convert the list
to any array of the proper dimensions.

 input - scan('/tempxx.txt.r', what='')
Read 21 items
 input
 [1] SPECIES1  999001099 900110109 011101000 901100101 110100019
 [7] 901110019 SPECIES2  99999 900110119 011101100 901010101
[13] 11019 90019 SPECIES3  999001099 900100109 011100010
[19] 901100100 110100019 901110019
 # find the names
 breaks - grep([[:alpha:]][[:alnum:]]+, input)
 # determine the sizes
 map - cbind(breaks, diff(c(breaks, length(input)+1)))
 out - list()
 # repeat for each data block
 for (i in 1:nrow(map)){
+ .set - NULL
+ for (j in 1:(map[i, 2] - 1)){
+ .set - rbind(.set, strsplit(input[map[i, 1] + j], '')[[1]])
+ }
+ out[[input[map[i, 1 - .set
+ }
 out
$SPECIES1
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,] 9  9  9  0  0  1  0  9  9
[2,] 9  0  0  1  1  0  1  0  9
[3,] 0  1  1  1  0  1  0  0  0
[4,] 9  0  1  1  0  0  1  0  1
[5,] 1  1  0  1  0  0  0  1  9
[6,] 9  0  1  1  1  0  0  1  9

$SPECIES2
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,] 9  9  9  0  0  0  0  9  9
[2,] 9  0  0  1  1  0  1  1  9
[3,] 0  1  1  1  0  1  1  0  0
[4,] 9  0  1  0  1  0  1  0  1
[5,] 1  1  0  0  0  0  0  1  9
[6,] 9  0  0  0  0  0  0  1  9

$SPECIES3
 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,] 9  9  9  0  0  1  0  9  9
[2,] 9  0  0  1  0  0  1  0  9
[3,] 0  1  1  1  0  0  0  1  0
[4,] 9  0  1  1  0  0  1  0  0
[5,] 1  1  0  1  0  0  0  1  9
[6,] 9  0  1  1  1  0  0  1  9





On 12/22/05, Colin Beale [EMAIL PROTECTED] wrote:

 Hi,

 I'm needing some help finding a function to read a large text file into an
 array in R. The data are essentially presence / absence / na data for many
 species and come as a grid with each species name (after two spaces) at the
 beginning of the matrix defining the map for that species. An excerpt could
 therefore be:

 SPECIES1
 999001099
 900110109
 011101000
 901100101
 110100019
 901110019

 SPECIES2
 99999
 900110119
 011101100
 901010101
 11019
 90019

 SPECIES3
 999001099
 900100109
 011100010
 901100100
 110100019
 901110019

 where 9 is actually na, 0 is absence and 1 presence. The final array I
 want to create should have dimensions that are the x and y coordinates and
 the number of species (known in advance). (In this example dim = c(9,6,3)).
 It would be sort of neat if the code could also read the species name into
 the appropriate names attribute, but this is a refinement that I could
 probably do if someone can help me read the data into R and into an array in
 the first place. I'm currently thinking a line by line approach using
 readLines might be the best option, but I've got a very long file - well
 over 100 species, each a matrix of 70 x 100 datapoints. making this option
 rther time consuming, I expect - especially as the next dataset has 1300
 species and a much larger grid...

 Any hints would be gratefully recieved.

 Colin Beale
 Macaulay Land Use Research Institute

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




--
Jim Holtman
Cincinnati, OH
+1 513 247 0281

What the problem you are trying to solve?

[[alternative HTML version deleted]]

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


Re: [R] reading long matrix

2005-12-22 Thread Liaw, Andy
Here's one possibility, if you know the number of species and the numbers of
rows and columns before hand, and the dimension for all species are the
same.

readSpeciesMap - function(fname, nspecies, nr, nc) {
spcnames - character(nspecies)
spcdata - array(0, c(nc, nr, nspecies))
## open the file for reading, and close it upon exit.
f - file(fname, open=r)
on.exit(close(f))
for (i in seq(along=spcnames)) {
## read the name
spcnames[i] - readLines(f, 1)[[1]]
## read the grid
spcdata[, , i] - as.numeric(unlist(strsplit(readLines(f, nr), )))
## pick up the empty line
readLines(f, 1)
}
## replace the 9s with NAs
spcdata[spcdata == 9] - NA
dimnames(spcdata)[[3]] - spcnames
## transpose the array in each species
aperm(spcdata, c(2, 1, 3))
}

Using the example you supplied (saved in the file species.txt):

 readSpeciesMap(species.txt, 3, 6, 9)
, ,   SPECIES1

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,]   NA   NA   NA0010   NA   NA
[2,]   NA0011010   NA
[3,]011101000
[4,]   NA01100101
[5,]11010001   NA
[6,]   NA0111001   NA

, ,   SPECIES2

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,]   NA   NA   NA0000   NA   NA
[2,]   NA0011011   NA
[3,]011101100
[4,]   NA01010101
[5,]11000001   NA
[6,]   NA0000001   NA

, ,   SPECIES3

 [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9]
[1,]   NA   NA   NA0010   NA   NA
[2,]   NA0010010   NA
[3,]011100010
[4,]   NA01100100
[5,]11010001   NA
[6,]   NA0111001   NA

Andy


From: Colin Beale
 
 Hi,
 
 I'm needing some help finding a function to read a large text 
 file into an array in R. The data are essentially presence / 
 absence / na data for many species and come as a grid with 
 each species name (after two spaces) at the beginning of the 
 matrix defining the map for that species. An excerpt could 
 therefore be:
 
   SPECIES1
 999001099
 900110109
 011101000
 901100101
 110100019
 901110019
 
   SPECIES2
 99999
 900110119
 011101100
 901010101
 11019
 90019
 
   SPECIES3
 999001099
 900100109
 011100010
 901100100
 110100019
 901110019
 
 where 9 is actually na, 0 is absence and 1 presence. The 
 final array I want to create should have dimensions that are 
 the x and y coordinates and the number of species (known in 
 advance). (In this example dim = c(9,6,3)). It would be sort 
 of neat if the code could also read the species name into the 
 appropriate names attribute, but this is a refinement that I 
 could probably do if someone can help me read the data into R 
 and into an array in the first place. I'm currently thinking 
 a line by line approach using readLines might be the best 
 option, but I've got a very long file - well over 100 
 species, each a matrix of 70 x 100 datapoints. making this 
 option rther time consuming, I expect - especially as the 
 next dataset has 1300 species and a much larger grid...
 
 Any hints would be gratefully recieved.
 
 Colin Beale
 Macaulay Land Use Research Institute
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! 
 http://www.R-project.org/posting-guide.html
 


__
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] Testing a linear hypothesis after maximum likelihood

2005-12-22 Thread Peter Muhlberger
I'd like to be able to test linear hypotheses after setting up and running a
model using optim or perhaps nlm.  One hypothesis I need to test are that
the average of several coefficients is less than zero, so I don't believe I
can use the likelihood ratio test.

I can't seem to find a provision anywhere for testing linear combinations of
coefficients after max. likelihood.

Cheers  happy holidays,

Peter

__
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] Reading in large file in pieces

2005-12-22 Thread Sean Davis
I have a large file (millions of lines) and would like to read it in pieces.
The file is logically separated into little modules, but these modules do
not have a common size, so I have to scan the file to know where they are.
They are independent, so I don't have to read one at the end to interpret
one at the beginning.  Is there a way to read one line at a time and parse
it on the fly and do so quickly, or do I need to read say 100k lines at a
time and then work with those?  Only a small piece of each module will
remain in memory after parsing is completed on each module.

My direct question is:  Is there a fast way to parse one line at a time
looking for breaks between modules, or am I better off taking large but
manageable chunks from the file and parsing that chunk all at once?

Thanks,
Sean

__
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] (no subject)

2005-12-22 Thread wei sun
Hi,

I am new in writing R extension.
I read the Writing R Extensions, and search online but just cannot  
find the answer.

I am trying to add c-code, which depend on GSL C  library, into my R  
package.
I am using Max OS-X 10.4.3, powerpc-apple-darwin8-gcc-4.0.1

I begin wtih package.skeleton, and then add my c file into folder src
and then add  file Makevars:

PKG_LIBS=-lgsl -lgslcblas -lm

In the zzz.R file, I add the function .First.lib:

.First.lib - function(lib, pkg) {
   library.dynam(anovaGSL, pkg, lib)
}

I think these two things are enough. then I just run R CMD check  
anovaGSL (my package name)
followed is the error message:

Error: .First.lib failed for 'anovaGSL'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose  
= FALSE)
Execution halted
See section 'Generic functions and methods' of the 'Writing R  
Extensions'
manual.
* checking replacement functions ... WARNING
Error: .First.lib failed for 'anovaGSL'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose  
= FALSE)
Execution halted
In R, the argument of a replacement function which corresponds to the  
right
hand side must be named 'value'.
* checking foreign function calls ... WARNING
Error: .First.lib failed for 'anovaGSL'
Call sequence:
2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose  
= FALSE)
Execution halted
See section 'System and foreign language interfaces' of the 'Writing R
Extensions' manual.
* checking Rd files ... OK
* checking for missing documentation entries ... ERROR
Error: .First.lib failed for 'anovaGSL'


appreciate any help!!!


wei


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


[R] convolution of the double exponential distribution

2005-12-22 Thread Bickel, David
Is there any R function that computes the convolution of the double
exponential distribution?

If not, is there a good way to integrate ((q+x)^n)*exp(-2x) over x from
0 to Inf for any value of q and for any positive integer n? I need to
perform the integration within a function with q and n as arguments. The
function integrate() is giving me this message:

evaluation of function gave a result of wrong length

David
___
David R. Bickel  http://davidbickel.com
Research Scientist
Pioneer Hi-Bred International (DuPont)
Bioinformatics and Exploratory Research
7200 NW 62nd Ave.; PO Box 184
Johnston, IA 50131-0184
515-334-4739 Tel
515-334-4473 Fax
[EMAIL PROTECTED], [EMAIL PROTECTED]

This communication is for use by the intended recipient and ...{{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


Re: [R] convolution of the double exponential distribution

2005-12-22 Thread Duncan Murdoch
On 12/22/2005 7:56 PM, Bickel, David wrote:
 Is there any R function that computes the convolution of the double
 exponential distribution?
 
 If not, is there a good way to integrate ((q+x)^n)*exp(-2x) over x from
 0 to Inf for any value of q and for any positive integer n? I need to
 perform the integration within a function with q and n as arguments. The
 function integrate() is giving me this message:
 
 evaluation of function gave a result of wrong length

Under the substitution of y = q+x, that looks like a gamma integral. 
The x = 0 to Inf range translates into y = q to Inf, so you'll need an 
incomplete gamma function, such as pgamma.  Be careful to get the 
constant multiplier right.

Duncan Murdoch

__
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 specify dev.print target by a variable?

2005-12-22 Thread Leif Kirschenbaum
I want to do the following:

  DEVw=500
  DEVh=350
  fname=my_plot
  dev.print(file=fname, device=FOO, width=DEVw, height=DEVh, bg=transparent)

How do I do this such that I can specify FOO to be one of several choices? 
(GDD, PNG, postscript, etc.)
If I make FOO a character variable, then dev.print complains.
I tried a simpled substitute but didn't get it to work...
I'm thinking it's going to involve a do.call and substitute but I'm not 
sure.

Using:

$platform[1] i386-pc-mingw32
$arch[1] i386
$os[1] mingw32
$system[1] i386, mingw32
$status[1] 
$major[1] 2
$minor[1] 2.0
$year[1] 2005
$month[1] 10
$day[1] 06
$svn rev[1] 35749
$language[1] R

and also running the same code on:

$platform[1] i686-redhat-linux-gnu
$arch[1] i686
$os[1] linux-gnu
$system[1] i686, linux-gnu
$status[1] 
$major[1] 2
$minor[1] 0.0
$year[1] 2004
$month[1] 10
$day[1] 04
$language[1] R


-Leif S. Kirschenbaum, Ph.D.
 Yield Integration Engineer
 Reflectivity, Inc.

__
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 specify dev.print target by a variable?

2005-12-22 Thread Berwin A Turlach
G'day Leif,

 LK == Leif Kirschenbaum [EMAIL PROTECTED] writes:

LK How do I do this such that I can specify FOO to be one of
LK several choices? (GDD, PNG, postscript, etc.)  If I make FOO a
LK character variable, then dev.print complains.
Mmh, I am not sure what the complaint of R 2.2.0 on MS Windows is, but
I guess it is the same as under linux:

 DEVw=500
 DEVh=350
 fname=my_plot
 plot(rnorm(300))
 FOO - png
 dev.print(file=fname, device=FOO, width=DEVw, height=DEVh, bg=transparent)
Error in dev.copy(device = png, file = fname, width = DEVw, height = DEVh,  : 
'device' should be a function

Which is very informative.  `device' is supposed to be a function, not
a character variable, thus:

 FOO - png
 dev.print(file=fname, device=FOO, width=DEVw, height=DEVh, bg=transparent)
X11 
  2 
 FOO - pdf
 dev.print(file=fname, device=FOO, width=DEVw, height=DEVh, bg=transparent)
X11 
  2 

all seem to work.

HTH.

Cheers,

Berwin

== Full address 
Berwin A Turlach  Tel.: +61 (8) 6488 3338 (secr)   
School of Mathematics and Statistics+61 (8) 6488 3383 (self)  
The University of Western Australia   FAX : +61 (8) 6488 1028
35 Stirling Highway   
Crawley WA 6009e-mail: [EMAIL PROTECTED]
Australiahttp://www.maths.uwa.edu.au/~berwin

__
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] reading long matrix

2005-12-22 Thread Gabor Grothendieck
One way to do this is to use read.fwf.  I have borrowed Jim's
use of scan and use a similar calculation to get the indexes
of the breaks, breaks.  We then determine the common number
of rows and columns in each species.

The second group of statements replaces all 9's with spaces
so that upon parsing them as numbers they will be NAs and then sets
up a text connection to the resulting character vector.  These are then
read in by read.fwf, nr rows at a time and the result is
unlist'ed to a numeric vector, nums.  The last statement
reshapes it into an array and adds the species names as
the last dimension names.

# read data in
L - scan(clipboard, what = )
breaks - grep(^[[:alpha:]], L)
nr - breaks[2] - breaks[1] - 1; nc - nchar(L[2])

# parse numbers
n - length(L[-breaks]) / nr
con - textConnection(gsub(9,  , L[-breaks]))
nums - unlist(replicate(n, read.fwf(con, widths = rep(1, nc), n = nr)))
result - array(nums, c(6,9,3), c(NULL, NULL, L[breaks]))


On 12/22/05, Colin Beale [EMAIL PROTECTED] wrote:
 Hi,

 I'm needing some help finding a function to read a large text file into an 
 array in R. The data are essentially presence / absence / na data for many 
 species and come as a grid with each species name (after two spaces) at the 
 beginning of the matrix defining the map for that species. An excerpt could 
 therefore be:

  SPECIES1
 999001099
 900110109
 011101000
 901100101
 110100019
 901110019

  SPECIES2
 99999
 900110119
 011101100
 901010101
 11019
 90019

  SPECIES3
 999001099
 900100109
 011100010
 901100100
 110100019
 901110019

 where 9 is actually na, 0 is absence and 1 presence. The final array I want 
 to create should have dimensions that are the x and y coordinates and the 
 number of species (known in advance). (In this example dim = c(9,6,3)). It 
 would be sort of neat if the code could also read the species name into the 
 appropriate names attribute, but this is a refinement that I could probably 
 do if someone can help me read the data into R and into an array in the first 
 place. I'm currently thinking a line by line approach using readLines might 
 be the best option, but I've got a very long file - well over 100 species, 
 each a matrix of 70 x 100 datapoints. making this option rther time 
 consuming, I expect - especially as the next dataset has 1300 species and a 
 much larger grid...

 Any hints would be gratefully recieved.

 Colin Beale
 Macaulay Land Use Research Institute

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


__
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] reading long matrix

2005-12-22 Thread Gabor Grothendieck
One correction.  I had hard coded the last statement for testing
with the data provided.  Change it to this for generality:

result - array(nums, c(nr, nc, n), c(NULL, NULL, L[breaks]))



On 12/22/05, Gabor Grothendieck [EMAIL PROTECTED] wrote:
 One way to do this is to use read.fwf.  I have borrowed Jim's
 use of scan and use a similar calculation to get the indexes
 of the breaks, breaks.  We then determine the common number
 of rows and columns in each species.

 The second group of statements replaces all 9's with spaces
 so that upon parsing them as numbers they will be NAs and then sets
 up a text connection to the resulting character vector.  These are then
 read in by read.fwf, nr rows at a time and the result is
 unlist'ed to a numeric vector, nums.  The last statement
 reshapes it into an array and adds the species names as
 the last dimension names.

 # read data in
 L - scan(clipboard, what = )
 breaks - grep(^[[:alpha:]], L)
 nr - breaks[2] - breaks[1] - 1; nc - nchar(L[2])

 # parse numbers
 n - length(L[-breaks]) / nr
 con - textConnection(gsub(9,  , L[-breaks]))
 nums - unlist(replicate(n, read.fwf(con, widths = rep(1, nc), n = nr)))
 result - array(nums, c(6,9,3), c(NULL, NULL, L[breaks]))


 On 12/22/05, Colin Beale [EMAIL PROTECTED] wrote:
  Hi,
 
  I'm needing some help finding a function to read a large text file into an 
  array in R. The data are essentially presence / absence / na data for many 
  species and come as a grid with each species name (after two spaces) at the 
  beginning of the matrix defining the map for that species. An excerpt could 
  therefore be:
 
   SPECIES1
  999001099
  900110109
  011101000
  901100101
  110100019
  901110019
 
   SPECIES2
  99999
  900110119
  011101100
  901010101
  11019
  90019
 
   SPECIES3
  999001099
  900100109
  011100010
  901100100
  110100019
  901110019
 
  where 9 is actually na, 0 is absence and 1 presence. The final array I want 
  to create should have dimensions that are the x and y coordinates and the 
  number of species (known in advance). (In this example dim = c(9,6,3)). It 
  would be sort of neat if the code could also read the species name into the 
  appropriate names attribute, but this is a refinement that I could probably 
  do if someone can help me read the data into R and into an array in the 
  first place. I'm currently thinking a line by line approach using readLines 
  might be the best option, but I've got a very long file - well over 100 
  species, each a matrix of 70 x 100 datapoints. making this option rther 
  time consuming, I expect - especially as the next dataset has 1300 species 
  and a much larger grid...
 
  Any hints would be gratefully recieved.
 
  Colin Beale
  Macaulay Land Use Research Institute
 
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide! 
  http://www.R-project.org/posting-guide.html
 


__
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] Reading in large file in pieces

2005-12-22 Thread Ales Ziberna
See ?scan
or maybe ?readLines


- Original Message - 
From: Sean Davis [EMAIL PROTECTED]
To: r-help r-help@stat.math.ethz.ch
Sent: Friday, December 23, 2005 12:08 AM
Subject: [R] Reading in large file in pieces


I have a large file (millions of lines) and would like to read it in pieces.
The file is logically separated into little modules, but these modules do
not have a common size, so I have to scan the file to know where they are.
They are independent, so I don't have to read one at the end to interpret
one at the beginning.  Is there a way to read one line at a time and parse
it on the fly and do so quickly, or do I need to read say 100k lines at a
time and then work with those?  Only a small piece of each module will
remain in memory after parsing is completed on each module.

My direct question is:  Is there a fast way to parse one line at a time
looking for breaks between modules, or am I better off taking large but
manageable chunks from the file and parsing that chunk all at once?

Thanks,
Sean

__
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-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] Reading in large file in pieces

2005-12-22 Thread Prof Brian Ripley
On Thu, 22 Dec 2005, Sean Davis wrote:

 I have a large file (millions of lines) and would like to read it in pieces.
 The file is logically separated into little modules, but these modules do
 not have a common size, so I have to scan the file to know where they are.
 They are independent, so I don't have to read one at the end to interpret
 one at the beginning.  Is there a way to read one line at a time and parse
 it on the fly and do so quickly, or do I need to read say 100k lines at a
 time and then work with those?  Only a small piece of each module will
 remain in memory after parsing is completed on each module.

 My direct question is:  Is there a fast way to parse one line at a time
 looking for breaks between modules, or am I better off taking large but
 manageable chunks from the file and parsing that chunk all at once?

On any reasonable OS (you have not told us yours), it will make no 
difference as the file reads will be buffered.  Assuming you are doing 
something like opening a connection and calling readLines(n=1), of course.

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

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


Re: [R] (C programming problem on MacOS X)

2005-12-22 Thread Prof Brian Ripley
Please do INSTALL the package and test loading it before R CMD check.
You will get better errror messages.  This has been discussed on the 
appropriate R list (R-devel, not here), many times.

Since you mention -lgslcblas and no BLAS, my guess is that your shared 
object has unsatisfied entry points.

However, can you not obtain advice locally on R / MacOS X programming: 
your address suggests that you have neighbours who are long-term 
practitioners?

On Thu, 22 Dec 2005, wei sun wrote:

 Hi,

 I am new in writing R extension.
 I read the Writing R Extensions, and search online but just cannot
 find the answer.

You seeem to have failed to find the R posting guide and its request to 
use a proper subject line, not to send HTML mail and to use an appropriate 
list.

 I am trying to add c-code, which depend on GSL C  library, into my R
 package.
 I am using Max OS-X 10.4.3, powerpc-apple-darwin8-gcc-4.0.1

 I begin wtih package.skeleton, and then add my c file into folder src
 and then add  file Makevars:

 PKG_LIBS=-lgsl -lgslcblas -lm

 In the zzz.R file, I add the function .First.lib:

 .First.lib - function(lib, pkg) {
   library.dynam(anovaGSL, pkg, lib)
 }

 I think these two things are enough. then I just run R CMD check
 anovaGSL (my package name)
 followed is the error message:

 Error: .First.lib failed for 'anovaGSL'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose
 = FALSE)
 Execution halted
 See section 'Generic functions and methods' of the 'Writing R
 Extensions'
 manual.
 * checking replacement functions ... WARNING
 Error: .First.lib failed for 'anovaGSL'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose
 = FALSE)
 Execution halted
 In R, the argument of a replacement function which corresponds to the
 right
 hand side must be named 'value'.
 * checking foreign function calls ... WARNING
 Error: .First.lib failed for 'anovaGSL'
 Call sequence:
 2: stop(gettextf(.First.lib failed for '%s', libraryPkgName(package)),
domain = NA)
 1: library(package, lib.loc = lib.loc, character.only = TRUE, verbose
 = FALSE)
 Execution halted
 See section 'System and foreign language interfaces' of the 'Writing R
 Extensions' manual.
 * checking Rd files ... OK
 * checking for missing documentation entries ... ERROR
 Error: .First.lib failed for 'anovaGSL'


 appreciate any help!!!


 wei


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


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

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


Re: [R] how to specify dev.print target by a variable?

2005-12-22 Thread Prof Brian Ripley
On Fri, 23 Dec 2005, Berwin A Turlach wrote:

 G'day Leif,

 LK == Leif Kirschenbaum [EMAIL PROTECTED] writes:

LK How do I do this such that I can specify FOO to be one of
LK several choices? (GDD, PNG, postscript, etc.)  If I make FOO a
LK character variable, then dev.print complains.
 Mmh, I am not sure what the complaint of R 2.2.0 on MS Windows is, but
 I guess it is the same as under linux:

 DEVw=500
 DEVh=350
 fname=my_plot
 plot(rnorm(300))
 FOO - png
 dev.print(file=fname, device=FOO, width=DEVw, height=DEVh, bg=transparent)
 Error in dev.copy(device = png, file = fname, width = DEVw, height = DEVh,  
 :
   'device' should be a function

 Which is very informative.  `device' is supposed to be a function, not
 a character variable, thus:

 FOO - png
 dev.print(file=fname, device=FOO, width=DEVw, height=DEVh, bg=transparent)
 X11
  2
 FOO - pdf
 dev.print(file=fname, device=FOO, width=DEVw, height=DEVh, bg=transparent)
 X11
  2

 all seem to work.

And my guess is that Leif wants to be able to do

mydevice - png
dev.print(device = get(mydevice), ...)
^^^

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

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