Re: [R] edit.data.frame

2006-01-13 Thread Prof Brian Ripley
That changes the object if you make a change in the editor, so definitely 
NOT to be recommended.


On Fri, 13 Jan 2006, ronggui wrote:


I think fix(data.frame.name) is the best way .
2006/1/13, Prof Brian Ripley [EMAIL PROTECTED]: On Thu, 12 Jan 2006, Fredrik Lundgren wrote:  Sometimes I have huge data.frames and the 
small spreadsheetlike  edit.data.frame is quite handy to get an overview of the data. However,  when I close the editor all data are rolled over 
the console window,  which takes time and clutters the window. Is there a way to avoid this? If you mean printed to the R terminal/console, assign 
the result or use invisible(edit(object)). -- 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-p!
roject.org/posting-guide.html

--黄荣贵Deparment of SociologyFudan University




--
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] Curve fitting

2006-01-13 Thread ndurand
I made a mistake in my equations : all the logarithms are neperian!

- Réacheminé par Nadege ND Durand/RD/abx/FR le 01/13/2006 09:15 -


Nadege ND Durand
01/12/2006 19:11

 
Pour :  [EMAIL PROTECTED]
cc : 
Objet : Curve fitting 

Hi!

I have a problem of curve fitting.

I use the following data :

 - vector of predictor data : 
0
0.4
0.8
1.2
1.6

- vector of response data : 
0.81954
0.64592
0.51247
0.42831
0.35371

 I perform parametric fits using custom equations

when I use this equation :   y  =  yo + K *(1/(1+exp(-(a+b*ln(x)   the 
fitting result is OK
but when I use this more general equation :y  =  yo + K 
*(1/(1+exp(-(a+b*log(x)+c*x  , then I get an aberrant curve!

I don't understand that... The second fitting should be at least as good 
as the first one because when taking c=0, both equations are identical!

There is here a mathematical phenomenon that I don't understand!could 
someone help me

Thanks a lot in advance!

Nadège 


[[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] edit.data.frame

2006-01-13 Thread David Firth
On 12 Jan 2006, at 22:17, Fredrik Lundgren wrote:

 Dear list,

 Sometimes I have huge data.frames and the small spreadsheetlike
 edit.data.frame is quite handy to get an overview of the data.  
 However,
 when I close the editor all data are rolled over the console window,
 which takes time and clutters the window. Is there a way to avoid  
 this?


An alternative to the editor is showData() from the relimp package.   
It is modeless, meaning that your data window can be left open/ 
minimized while you work in R.  I haven't tested it with _very_ large  
data frames though.

David

--
Professor David Firth
http://www.warwick.ac.uk/go/dfirth

__
R-help@stat.math.ethz.ch 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] Basis of fisher.test

2006-01-13 Thread Ted Harding
On 13-Jan-06 Prof Brian Ripley wrote:
 On Thu, 12 Jan 2006 [EMAIL PROTECTED] wrote:
[...]
 ?fisher.test says only:
 
 [That following is not a quote from a current version of R.]
 
 In the one-sided 2 by 2 cases, p-values are obtained
 directly using the hypergeometric distribution.
 Otherwise, computations are based on a C version of
 the FORTRAN subroutine FEXACT which implements the
 network developed by Mehta and Patel (1986) and
 improved by Clarkson, Fan  Joe (1993). The FORTRAN
 code can be obtained from
 URL: http://www.netlib.org/toms/643.
 
 No, it *also* says
 
   Two-sided tests are based on the probabilities of the tables, and
   take as 'more extreme' all tables with probabilities less than or
   equal to that of the observed table, the p-value being the sum of
   such probabilities.
 
 which answers the question (there are only two-sided tests for such 
 tables).

Thanks for the above information, which is indeed the definitive
straightforward answer to my question!

(Not sure that I quite agree with the two-sided terminology, though,
since the ranking is unidirectional based on decreasing probability,
and the P-value is that of the least-probability tail -- i.e. analagous
to the large (-2*loglik) tail of a likelihood-ratio test -- which
I've always visualised as a 1-tailed test (depite the fact that
the other tail can on occasion be indicative of a fit too good to
be true).

 Now, what does the posting guide say about stating the R version and 
 updating before posting?

Well, I plead that in practice there is necessarily a grey area
here! My quotation was from ?fisher.test in R-2.1.0beta of
2004/04/08, the most recent version installed on any of my machines.
Admittedly a bit behind the times, but not grossly; and that help
page has not changed in this respect since the earliest version I
have installed, which is R-1.2.3 of 2001/04/26.

Contents of help pages can change overnight as R evolves.
While it is better to be up-to-date than behind the times (even
slightly), there is a compromise to be struck between upgrading
to the latest R every time one has a question which might be
answered thereby, or going on-line to read the latest PDF
documentation from CRAN, on the one hand, and on the other asking
a straightforward question to the list.

Thanks again, and best wishes,
Ted.


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 13-Jan-06   Time: 08:55:11
-- XFMail --

__
R-help@stat.math.ethz.ch 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] Basis of fisher.test

2006-01-13 Thread Prof Brian Ripley
On Fri, 13 Jan 2006 [EMAIL PROTECTED] wrote:

 On 13-Jan-06 Prof Brian Ripley wrote:
 On Thu, 12 Jan 2006 [EMAIL PROTECTED] wrote:
 [...]
 ?fisher.test says only:

 [That following is not a quote from a current version of R.]

 In the one-sided 2 by 2 cases, p-values are obtained
 directly using the hypergeometric distribution.
 Otherwise, computations are based on a C version of
 the FORTRAN subroutine FEXACT which implements the
 network developed by Mehta and Patel (1986) and
 improved by Clarkson, Fan  Joe (1993). The FORTRAN
 code can be obtained from
 URL: http://www.netlib.org/toms/643.

 No, it *also* says

   Two-sided tests are based on the probabilities of the tables, and
   take as 'more extreme' all tables with probabilities less than or
   equal to that of the observed table, the p-value being the sum of
   such probabilities.

 which answers the question (there are only two-sided tests for such
 tables).

 Thanks for the above information, which is indeed the definitive
 straightforward answer to my question!

 (Not sure that I quite agree with the two-sided terminology, though,
 since the ranking is unidirectional based on decreasing probability,
 and the P-value is that of the least-probability tail -- i.e. analagous
 to the large (-2*loglik) tail of a likelihood-ratio test -- which
 I've always visualised as a 1-tailed test (depite the fact that
 the other tail can on occasion be indicative of a fit too good to
 be true).

As statistics is usually taught, significance tests are always one-tailed. 
The two-sided t-test is one-tailed, the test statistic being |T|.

In any case, the `two-sided' is part of the arguments given to the 
function, so this para is just using the already-established terminology.

 Now, what does the posting guide say about stating the R version and
 updating before posting?

 Well, I plead that in practice there is necessarily a grey area
 here! My quotation was from ?fisher.test in R-2.1.0beta of
 2004/04/08, the most recent version installed on any of my machines.
 Admittedly a bit behind the times, but not grossly; and that help
 page has not changed in this respect since the earliest version I
 have installed, which is R-1.2.3 of 2001/04/26.

 Contents of help pages can change overnight as R evolves.
 While it is better to be up-to-date than behind the times (even
 slightly), there is a compromise to be struck between upgrading
 to the latest R every time one has a question which might be
 answered thereby, or going on-line to read the latest PDF
 documentation from CRAN, on the one hand, and on the other asking
 a straightforward question to the list.

Well, if you had given the R version number the problem would have been 
much more obvious.

 Thanks again, and best wishes,
 Ted.

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 13-Jan-06   Time: 08:55:11
 -- XFMail --

 __
 R-help@stat.math.ethz.ch 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] edit.data.frame - summary

2006-01-13 Thread Fredrik Lundgren
Thanks to

David Firth
Brian Ripley
ronggui
jim holtman

who help with this question.

showData() from the relimp package works and shows the dataframe as.is
but scrolls rather weak with huge data.frames (15 000 x 120)

fix(...) is somewhat dangerous as you usually don't want to correct 
individual data but
get an overview

invisible(edit(...)) does the trick and scrolls with excellent speed 
even with huge dataframes
but not exactly as.is (dates as negative or positive integer, minor 
problem).

Fredrik



- Original Message - 
From: David Firth [EMAIL PROTECTED]
To: Fredrik Lundgren [EMAIL PROTECTED]
Cc: R-help r-help@stat.math.ethz.ch
Sent: Friday, January 13, 2006 9:21 AM
Subject: Re: [R] edit.data.frame


 On 12 Jan 2006, at 22:17, Fredrik Lundgren wrote:

 Dear list,

 Sometimes I have huge data.frames and the small spreadsheetlike
 edit.data.frame is quite handy to get an overview of the data. 
 However,
 when I close the editor all data are rolled over the console window,
 which takes time and clutters the window. Is there a way to avoid 
 this?


 An alternative to the editor is showData() from the relimp package. 
 It is modeless, meaning that your data window can be left open/ 
 minimized while you work in R.  I haven't tested it with _very_ large 
 data frames though.

 David

 --
 Professor David Firth
 http://www.warwick.ac.uk/go/dfirth


__
R-help@stat.math.ethz.ch 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] first derivative of a time series

2006-01-13 Thread gj
Hi,

I need to derive a time series that represents the first derivative of an
original time series. The function coefDeriv in the cyclones package seemed to
be the ticket, but I'm not sure if I am interpreting the output of the function
correctly...or even using the function correctly.

This is a snipbit of what I've been trying:

library(cyclones)

## read in my 1-column of values, each line is a different time step
ts.table - read.table(timeseries.1d)
ts.values - ts.table[,1]

## first calculate coefficients to pass to coefDeriv
ts.coef - coefFit(ts.values)

d.ts - coefDeriv(ts.coef)
---

However, when I try to look at d.ts$y.deriv, assumning that this will plot the
derivative I want, all the numbers are huge (on the order of e+02 to e+08) when
my original time series ranged from 0 to 970. Am I going about this the wrong
way? Or are there other tools that would lead me to estimating the derivative
of a time series?

Thanks in advance for any help!
g

__
R-help@stat.math.ethz.ch 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 with gepRglm::likfit.glsm

2006-01-13 Thread ernesto
Hi,

I'm exploring likfit.glsm and I need some help. I have to say that I'm
not an MCMC expert ...

I did a first run of likfit.glsm with S.scale=0.002 and it worked
whithout problems but there was strong autocorrelation and the chain
convergence for the ramdom effects was quite poor, so I changed S.scale
to 0.4, which gave acceptance rates close to 0.6 as proposed on the
documentation, and the autocorrelation and chain convergence was ok.
However when I tried to run likfit.glsm it gave the following error:

 gdn.glsm2.lf - likfit.glsm(gdn.glsm2.prelf, cov.model =
exponential, ini.phi=26, lambda=0)

likfit.glsm: likelihood maximisation using the function optim.
phi =  26 tausq.rel =  0
Error in if (det(Delta2) != 0) { : missing value where TRUE/FALSE needed
In addition: Warning message:
cannot use argument lambda with the given objects in mcmc.obj in:
likfit.glsm(gdn.glsm2.prelf, cov.model = exponential, ini.phi = 26,

below is the code for both runs.

Thanks

EJ

# first run

mod - list(beta=gdn.lf$beta, cov.pars=gdn.lf$cov.pars,
cov.model=gdn.lf$cov.model, nugget=gdn.lf$nugget,
aniso.pars=gdn.lf$aniso.pars, family=poisson, lambda=gdn.lf$lambda)

mcc - mcmc.control(S.scale=0.002)
gdn.glsm1 - glsm.mcmc(gdn, model=mod, mcmc.input=mcc)
gdn.glsm1.prelf - prepare.likfit.glsm(gdn.glsm1)
gdn.glsm1.lf - likfit.glsm(gdn.glsm1.prelf, cov.model = exponential,
ini.phi=26, lambda = 0)

# second run

mcc - mcmc.control(S.scale=0.4)
gdn.glsm2 - glsm.mcmc(gdn, model=mod, mcmc.input=mcc)
gdn.glsm2.prelf - prepare.likfit.glsm(gdn.glsm2)
gdn.glsm2.lf - likfit.glsm(gdn.glsm2.prelf, cov.model = exponential,
ini.phi=26, lambda=0)

__
R-help@stat.math.ethz.ch 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] infinite recursion in do.call when lme4 loaded only

2006-01-13 Thread Martin Maechler
 Dieter == Dieter Menne [EMAIL PROTECTED]
 on Thu, 12 Jan 2006 18:14:32 + (UTC) writes:

Dieter Peter Dalgaard p.dalgaard at biostat.ku.dk writes:
  A larg program which worked with lme4/R about a year ago failed when I
  re-run it today. I reproduced the problem with the program below.

  -- When lme4 is loaded (but never used), the do.call fails
 with infinite recursion after 60 seconds. Memory used increases
 beyond bonds in task manager.
 
 However, it surely has to do with methods dispatch:
 
  system.time(do.call(rbind.data.frame,caScore))
 [1] 0.99 0.00 0.99 0.00 0.00
 
 which provides you with another workaround.

Dieter Peter, I had increased the optional value already, but I still 
don't understand 
Dieter what this recursion overflow has to do with the lm4 loading.

Aahh, you've hit a secret ;-)  no, but a semi-hidden feature:
lme4 loads Matrix and Matrix  activates versions of rbind() and
cbind() which use rbind2/cbind2 which are S4 generics and
default methods that are slightly different than then the
original base rbind() and cbind(). 
This was a necessity since the original rbind(), cbind() have
first argument ..., i.e. an invalid signature for S4 method
dispatch.

This was in NEWS for R 2.2.0 :

o   Experimental versions of cbind() and rbind() in methods package,
based on new generic function cbind2(x,y) and rbind2().  This will
allow the equivalent of S4 methods for cbind() and rbind() ---
currently only after an explicit activation call, see ?cbind2.

And 'Matrix' uses the activation call in its .OnLoad hook.
This is now getting much too technical to explain for R-help, so
if we want to go there, we should move this topic to R-devel,
and I'd like to do so, and will be glad if you can provide more
details on how exactly you're using rbind.

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] infinite recursion in do.call when lme4 loaded only

2006-01-13 Thread Martin Maechler
 MM == Martin Maechler [EMAIL PROTECTED]
 on Fri, 13 Jan 2006 12:24:51 +0100 writes:

 Dieter == Dieter Menne [EMAIL PROTECTED]
 on Thu, 12 Jan 2006 18:14:32 + (UTC) writes:

Dieter Peter Dalgaard p.dalgaard at biostat.ku.dk writes:
  A larg program which worked with lme4/R about a year ago failed when I
  re-run it today. I reproduced the problem with the program below.

  -- When lme4 is loaded (but never used), the do.call fails
 with infinite recursion after 60 seconds. Memory used increases
 beyond bonds in task manager.
 
 However, it surely has to do with methods dispatch:
 
  system.time(do.call(rbind.data.frame,caScore))
 [1] 0.99 0.00 0.99 0.00 0.00
 
 which provides you with another workaround.

Dieter Peter, I had increased the optional value already, but I still 
don't understand 
Dieter what this recursion overflow has to do with the lm4 loading.

MM Aahh, you've hit a secret ;-)  no, but a semi-hidden feature:
MM lme4 loads Matrix and Matrix  activates versions of rbind() and
MM cbind() which use rbind2/cbind2 which are S4 generics and
MM default methods that are slightly different than then the
MM original base rbind() and cbind(). 
MM This was a necessity since the original rbind(), cbind() have
MM first argument ..., i.e. an invalid signature for S4 method
MM dispatch.

MM This was in NEWS for R 2.2.0 :

MM o   Experimental versions of cbind() and rbind() in methods package,
MM based on new generic function cbind2(x,y) and rbind2().  This will
MM allow the equivalent of S4 methods for cbind() and rbind() ---
MM currently only after an explicit activation call, see ?cbind2.

MM And 'Matrix' uses the activation call in its .OnLoad hook.
MM This is now getting much too technical to explain for R-help, so
MM if we want to go there, we should move this topic to R-devel,
MM and I'd like to do so, and will be glad if you can provide more
MM details on how exactly you're using rbind.

One thing -- very useful for you -- I forgot to add:

You can easily quickly revert the  other cbind/rbind
activation by using

methods:::bind_activation(FALSE)

so you don't need to unload lme4 or Matrix,  and you can
reactivate them again after your special computation by

methods:::bind_activation(on = TRUE)

Martin

__
R-help@stat.math.ethz.ch 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] Scientific notation in plots

2006-01-13 Thread Oddmund Nordgård

Is it possible to use scientific notation of numbers on the axis of plots
without using the xEy notation. That means: a beatiful 1x10^3 instead of 1E3.
Logarithmic scale, in my case.

Thank you very much!

Oddmund

**

  Oddmund Nordgård

  Department of Haematology and Oncology
  Stavanger University Hospital
  P.O. Box 8100
  4068 STAVANGER
  Phone: 51 51 89 34
  Email: [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] edit.data.frame - summary

2006-01-13 Thread Prof Brian Ripley
On Fri, 13 Jan 2006, Fredrik Lundgren wrote:

 Thanks to

 David Firth
 Brian Ripley
 ronggui
 jim holtman

 who help with this question.

 showData() from the relimp package works and shows the dataframe as.is
 but scrolls rather weak with huge data.frames (15 000 x 120)

 fix(...) is somewhat dangerous as you usually don't want to correct
 individual data but
 get an overview

 invisible(edit(...)) does the trick and scrolls with excellent speed
 even with huge dataframes

It has been tested on tens of thousands of columns.

 but not exactly as.is (dates as negative or positive integer, minor
 problem).

Well, actually this is `as.is' and showData is not (and that _is_ 
documented on the help page).  If you want to see the printed 
representation, call invisible(edit(format(your_df)))


A non-modal read-only version of the dataeditors would be a nice 
programming exercise.

-- 
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] help with gepRglm::likfit.glsm

2006-01-13 Thread Ruben Roa
 -Original Message-
 From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED] On Behalf Of ernesto
 Sent: Friday, January 13, 2006 9:25 AM
 To:   Mailing List R
 Subject:  [R] help with gepRglm::likfit.glsm
 
 Hi,
 
 I'm exploring likfit.glsm and I need some help. I have to say that I'm
 not an MCMC expert ...
 
 I did a first run of likfit.glsm with S.scale=0.002 and it worked
 whithout problems but there was strong autocorrelation and the chain
 convergence for the ramdom effects was quite poor, so I changed S.scale
 to 0.4, which gave acceptance rates close to 0.6 as proposed on the
 documentation, and the autocorrelation and chain convergence was ok.
 However when I tried to run likfit.glsm it gave the following error:
 
  gdn.glsm2.lf - likfit.glsm(gdn.glsm2.prelf, cov.model =
 exponential, ini.phi=26, lambda=0)
 
 likfit.glsm: likelihood maximisation using the function optim.
 phi =  26 tausq.rel =  0
 Error in if (det(Delta2) != 0) { : missing value where TRUE/FALSE needed
 In addition: Warning message:
 cannot use argument lambda with the given objects in mcmc.obj in:
 likfit.glsm(gdn.glsm2.prelf, cov.model = exponential, ini.phi = 26,
-
Regarding the warning: the argument 'lambda' corresponds to the model for 
continuous variables (used in geoR) whereas you seem to have counts.
The error has occurred to me when i try to fit a spatial correlation function 
that the data does not support. For example when i try to fit the matern model
with too few observations. Then i fall back into exponential or gaussian and
then the error disappears. Try fitting the gaussian. Also try changing the 
initial
values for the correlation distance.
Ruben

__
R-help@stat.math.ethz.ch 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 and filemaker pro DB

2006-01-13 Thread Michael Bibo
I have been looking for a database application to use in conjunction with R (on
a Windows network).  When I approached my organization's IT department to ask
about using MySQL, they made a counter-offer of Filemaker Pro (v8).  It is not
specifically mentioned in 'R Data Import/Export', nor do searches of the
archives turn up much information.

Does anyone have any experience using Filemaker Pro with R?
Should package RODBC work with Filemaker, as it is odbc-compliant? (I will be
doing some trials anyway).
Any other relevant advice welcome.

Michael Bibo
Queensland Health
[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] Taking code from packages

2006-01-13 Thread Duncan Murdoch
On 1/13/2006 2:04 AM, Ales Ziberna wrote:
 Hello!
 
 I am currently in the process of creating (my first) package, which (when
 ready) I intend to publish to CRAN. In the process of creating this package
 I have taken some code form existing packages. I have actually copied parts
 of functions in to new functions. This code is usually something very basic
 such as Rand index. What is the proper procedure for this?
 
 Since most of R (and also the packages I have taken code form) is published
 under GPL, I think this should be OK. However I do not know if:
 1.I should still ask authors of the packages for permission or at
 least notify them.

It is polite to notify them.

 2.Ad references to the functions (and packages) from which I had taken
 the code or only to the references they use.

The GPL requires that you maintain their copyright notices.  You have 
the right to use their work, the GPL doesn't give you ownership of it.
The usual way to do this is to leave their copyright notice intact, and 
add your own if you have made modifications.

An alternative which is usually (but not always) better is to say that 
your package depends on theirs, and then just use their functions.  The 
advantage is that it avoids any of the above mixed copyright issues, and 
it makes sure that when the author fixes a bug, you benefit too.  The 
disadvantage is that it makes your package dependent on theirs, so if 
changes are needed in it for some future version of R, you'll have to 
wait for the other maintainer to do them (or copy their code at that point).

(I'm a little sensitive about dependencies now, since the LaTeX seminar 
template I've used a few times no longer works.  It depends on too many 
LaTeX packages, and someone, somewhere has introduced incompatibilities 
in them.  Seems like I'll be forced to use Powerpoint or Impress.)

Duncan Murdoch

 
 What about regarding code that was sent to the list, usually as a response
 to one of my problems. I assume that in this case it is best to consult the
 author?

 Any comments and opinions are very welcomed!
 
 Best regards,
 Ales Ziberna
 
 __
 R-help@stat.math.ethz.ch 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] multivariate markov switching

2006-01-13 Thread Carlo Fezzi
Dear helpers,

Does anyone know about a package or a function that allows to estimate
Multivariate Markov-Switching Models, like MS-VAR as introduced by
Krolzig(1997) with R ?

Thanks a lot!!

Carlo

__
R-help@stat.math.ethz.ch 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] Getting the numeric value of difftime

2006-01-13 Thread Christian Neumann
Hi folks,

I have a small, maybe newbie, question concerning date operations.
The follwing snippet

date1 = 2005-11-20;
date2 = 2005-11-17;
difftime(date1, date2)

results in Time difference of 3 days. How can I extract just the 
numerical value 3?
As a workaround I apply mean() on the result which gives me just a 
numerical value.

Thanks a lot,

Christian

__
R-help@stat.math.ethz.ch 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] Scientific notation in plots

2006-01-13 Thread IAIN GALLAGHER
try something like this:

axis(side=2, at=c(0, 5e+5, 1.5e+6, 2.5e+6),
labels=expression(0, 5%*%10^5, 1.5%*%10^6, 2.5%*%10^6)

it will place your 5e+5, 1.5e+6, 2.5e+6 as scientific
notation at the correct positions on the y axis. the
key is the labels=expression part.

Cheers

iain

--- Oddmund Nordgård [EMAIL PROTECTED] wrote:

 
 Is it possible to use scientific notation of numbers
 on the axis of plots
 without using the xEy notation. That means: a
 beatiful 1x10^3 instead of 1E3.
 Logarithmic scale, in my case.
 
 Thank you very much!
 
 Oddmund
 
 **
 
   Oddmund Nordgård
 
   Department of Haematology and Oncology
   Stavanger University Hospital
   P.O. Box 8100
   4068 STAVANGER
   Phone: 51 51 89 34
   Email: [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-help@stat.math.ethz.ch 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] multivariate markov switching

2006-01-13 Thread Ingmar Visser
I don't know the MS-VAR model. The graphical models page on the r-project
site refers to a number of packages that deal with these types of models of
which I don't know the specifics. The depmix package does multivariate
hidden markov models.
best, ingmar

 From: Carlo Fezzi [EMAIL PROTECTED]
 Organization: Dip. Scienze Statistiche - Univ. di Bologna
 Date: Fri, 13 Jan 2006 13:50:04 +0100 (CET)
 To: r-help@stat.math.ethz.ch
 Subject: [R] multivariate markov switching
 
 Dear helpers,
 
 Does anyone know about a package or a function that allows to estimate
 Multivariate Markov-Switching Models, like MS-VAR as introduced by
 Krolzig(1997) with R ?
 
 Thanks a lot!!
 
 Carlo
 
 __
 R-help@stat.math.ethz.ch 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] Getting the numeric value of difftime

2006-01-13 Thread Barry Rowlingson
Christian Neumann wrote:
 Hi folks,
 
 I have a small, maybe newbie, question concerning date operations.
 The follwing snippet
 
 date1 = 2005-11-20;
 date2 = 2005-11-17;
 difftime(date1, date2)
 
 results in Time difference of 3 days. How can I extract just the 
 numerical value 3?
 As a workaround I apply mean() on the result which gives me just a 
 numerical value.

  If you want to get one thing _as_ another the R-ish solution is nearly 
always to do as.another(oneThing).

  You want it numeric? You got it!

  date1 = 2005-11-20;
  date2 = 2005-11-17;
  difftime(date1, date2)
Time difference of 3 days
  as.numeric(difftime(date1, date2))
[1] 3

Barry

__
R-help@stat.math.ethz.ch 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] Getting the numeric value of difftime

2006-01-13 Thread Gabor Grothendieck
This was just discussed two days ago:

https://www.stat.math.ethz.ch/pipermail/r-help/2006-January/084453.html

On 1/13/06, Christian Neumann [EMAIL PROTECTED] wrote:
 Hi folks,

 I have a small, maybe newbie, question concerning date operations.
 The follwing snippet

 date1 = 2005-11-20;
 date2 = 2005-11-17;
 difftime(date1, date2)

 results in Time difference of 3 days. How can I extract just the
 numerical value 3?
 As a workaround I apply mean() on the result which gives me just a
 numerical value.

 Thanks a lot,

 Christian

 __
 R-help@stat.math.ethz.ch 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] CRAN versions of lme4/Matrix don't appear to work with R 2.1.1

2006-01-13 Thread White, Charles E WRAIR-Wash DC
After downloading from the WA mirror, the lme4 related packages appear
to run fine . Thanks for everyone's help.

Chuck

__
R-help@stat.math.ethz.ch 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] CRAN versions of lme4/Matrix don't appear to work with R 2.1.1

2006-01-13 Thread Dirk Eddelbuettel

On 12 January 2006 at 17:42, White, Charles E WRAIR-Wash DC wrote:
| 1) It was the Statlib mirror from which I was downloading. If I don't get any 
more interesting messages before I return to work in the morning, I'll try 
installing off of a different mirror.

IIRC we had repeated 'bug reports' from users of Statlib. That mirror seems
to not value internal consistency too highly. Maybe it is aiming to become a
'randomized mirror' ?  Just kidding...

Dirk

-- 
Hell, there are no rules here - we're trying to accomplish something. 
  -- Thomas A. Edison

__
R-help@stat.math.ethz.ch 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] [Rd] infinite recursion in do.call when lme4 loaded only

2006-01-13 Thread Dieter Menne
Martin Maechler maechler at stat.math.ethz.ch writes:

 One thing -- very useful for you -- I forgot to add:
 
 You can easily quickly revert the  other cbind/rbind
 activation by using
 
 methods:::bind_activation(FALSE)
 
 so you don't need to unload lme4 or Matrix,  and you can
 reactivate them again after your special computation by
 
 methods:::bind_activation(on = TRUE)

Do haut's di hi... Looks like we need a non-recursive replacement for
the elegant do.call(rbind..) constructs.

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


Re: [R] Getting the numeric value of difftime

2006-01-13 Thread Dimitris Rizopoulos
just try

as.numeric(difftime(date1, date2))


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://www.med.kuleuven.be/biostat/
 http://www.student.kuleuven.be/~m0390867/dimitris.htm


- Original Message - 
From: Christian Neumann [EMAIL PROTECTED]
To: r-help@stat.math.ethz.ch
Sent: Friday, January 13, 2006 2:05 PM
Subject: [R] Getting the numeric value of difftime


 Hi folks,

 I have a small, maybe newbie, question concerning date operations.
 The follwing snippet

 date1 = 2005-11-20;
 date2 = 2005-11-17;
 difftime(date1, date2)

 results in Time difference of 3 days. How can I extract just the
 numerical value 3?
 As a workaround I apply mean() on the result which gives me just a
 numerical value.

 Thanks a lot,

 Christian

 __
 R-help@stat.math.ethz.ch 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


Re: [R] Scientific notation in plots

2006-01-13 Thread Oddmund Nordgård

Just what I needed!

Thank you very much!

Oddmund

On Fri, 13 Jan 2006, IAIN GALLAGHER wrote:

 try something like this:

 axis(side=2, at=c(0, 5e+5, 1.5e+6, 2.5e+6),
 labels=expression(0, 5%*%10^5, 1.5%*%10^6, 2.5%*%10^6)

 it will place your 5e+5, 1.5e+6, 2.5e+6 as scientific
 notation at the correct positions on the y axis. the
 key is the labels=expression part.

 Cheers

 iain

 --- Oddmund Nordgård [EMAIL PROTECTED] wrote:

 
  Is it possible to use scientific notation of numbers
  on the axis of plots
  without using the xEy notation. That means: a
  beatiful 1x10^3 instead of 1E3.
  Logarithmic scale, in my case.
 
  Thank you very much!
 
  Oddmund
 
  **
 
Oddmund Nordgård
 
Department of Haematology and Oncology
Stavanger University Hospital
P.O. Box 8100
4068 STAVANGER
Phone: 51 51 89 34
Email: [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-help@stat.math.ethz.ch 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] Taking code from packages

2006-01-13 Thread Gabor Grothendieck
I usually place in my mypackage-package.Rd file a pointer
to the existence of a THANKS file and then put the THANKS
file in the inst directory (which gets copied to the top level
directory by the build tools during the build).  For example,
after installing dyn try:

   library(dyn)
   package?dyn

for instructions on accessing the THANKS file from within R.

On 1/13/06, Ales Ziberna [EMAIL PROTECTED] wrote:
 Hello!

 I am currently in the process of creating (my first) package, which (when
 ready) I intend to publish to CRAN. In the process of creating this package
 I have taken some code form existing packages. I have actually copied parts
 of functions in to new functions. This code is usually something very basic
 such as Rand index. What is the proper procedure for this?

 Since most of R (and also the packages I have taken code form) is published
 under GPL, I think this should be OK. However I do not know if:
 1.  I should still ask authors of the packages for permission or at
 least notify them.
 2.  Ad references to the functions (and packages) from which I had taken
 the code or only to the references they use.

 What about regarding code that was sent to the list, usually as a response
 to one of my problems. I assume that in this case it is best to consult the
 author?

 Any comments and opinions are very welcomed!

 Best regards,
 Ales Ziberna

 __
 R-help@stat.math.ethz.ch 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] Course in Statistical Practise in Epidemiology using R

2006-01-13 Thread BXC (Bendix Carstensen)
Course in
STATISTICAL PRACTICE IN EPIDEMIOLOGY USING R

Tartu, Estonia, Thursday 8  - Tuesday 13 June 2006

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

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

The methods will be illustrated using R in practical exercises.  

The Epi package for epidemiological analysis in R will be introduced.

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

Price: 500 EUR. (250 EUR for cuntries outside EU-2003 and the like).

Application deadline: 15 April 2006.

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

--
Krista Fischer, University of Tartu, Estonia
Esa Läärä, University of Oulu, Finland
Bendix Carstensen, Steno Diabetes Center, Denmark 

Organizers

__
R-help@stat.math.ethz.ch 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 with no separator

2006-01-13 Thread Liaw, Andy
Perhaps read.fwf() can be of use...

Andy

From: Jeffrey T. Steedle
 
 I have data in which each row consists of a long string of number,
 letters, symbols, and blank spaces.  I would like to simply scan in
 strings of length 426, but R takes the spaces that occur in 
 the data as
 separators.  Is there any way around this?
 
 Thanks,
 Jeff Steedle 
 
 -- 
 Jeffrey T. Steedle ([EMAIL PROTECTED])
 Psychological Studies in Education
 Stanford University School of Education
 
 __
 R-help@stat.math.ethz.ch 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] Curve fitting

2006-01-13 Thread Ben Bolker
 ndurand at fr.abx.fr writes:

 
 I made a mistake in my equations : all the logarithms are neperian!
 
 - Réacheminé par Nadege ND Durand/RD/abx/FR le 01/13/2006 09:15 -
 

  it doesn't matter; all the basic issues raised by me and
by Albyn Jones still apply.  If we are going to help you,
you need to provide more detail about what you tried in R
and more background on what you're trying to achieve in general.
As we both said, fitting a 5-parameter model to 5 data
points is nearly impossible.  If you provide more detail
about your data and your broader goal, we might be able
to help.

  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] Scientific notation in plots

2006-01-13 Thread McGehee, Robert
You could also use a function like this to transform a number x into your 
beautiful notation, where x is the number and digits is the number of digits 
you would like to see after the decimal. Then you could use the axis and labels 
syntax suggested by Iain, as such:

sciNotation - function(x, digits = 1) {
if (length(x)  1) {
return(append(sciNotation(x[1]), sciNotation(x[-1])))
}
if (!x) return(0)
exponent - floor(log10(x))
base - round(x / 10^exponent, digits)
as.expression(substitute(base %*% 10^exponent, 
list(base = base, exponent = exponent)))
}

plot(1:1000, axes = FALSE, type = l, frame.plot = TRUE)
axis(1, at = axTicks(1), label = sciNotation(axTicks(1), 1))

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of IAIN GALLAGHER
Sent: Friday, January 13, 2006 8:09 AM
To: Oddmund Nordgård
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] Scientific notation in plots

try something like this:

axis(side=2, at=c(0, 5e+5, 1.5e+6, 2.5e+6),
labels=expression(0, 5%*%10^5, 1.5%*%10^6, 2.5%*%10^6)

it will place your 5e+5, 1.5e+6, 2.5e+6 as scientific
notation at the correct positions on the y axis. the
key is the labels=expression part.

Cheers

iain

--- Oddmund Nordgård [EMAIL PROTECTED] wrote:

 
 Is it possible to use scientific notation of numbers
 on the axis of plots
 without using the xEy notation. That means: a
 beatiful 1x10^3 instead of 1E3.
 Logarithmic scale, in my case.
 
 Thank you very much!
 
 Oddmund
 
 **
 
   Oddmund Nordgård
 
   Department of Haematology and Oncology
   Stavanger University Hospital
   P.O. Box 8100
   4068 STAVANGER
   Phone: 51 51 89 34
   Email: [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-help@stat.math.ethz.ch 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] Problems installing R 2.2.1

2006-01-13 Thread Anne P Shelton
We are trying to install R2.2.1 on a  IBM P655 Cluster, SuSE LE 9.1 
We are using gcc v 3.3.3
 
and we are getting this error on make
 
g77 -fPIC  -g -O2 -ffloat-store -c dlamc.f -o dlamc.lo
g77  -fPIC  -g -O2 -c dlapack0.f -o dlapack0.lo
g77  -fPIC  -g -O2 -c dlapack1.f -o dlapack1.lo
g77  -fPIC  -g -O2 -c dlapack2.f -o dlapack2.lo
g77  -fPIC  -g -O2 -c dlapack3.f -o dlapack3.lo
g77  -fPIC  -g -O2 -c cmplx.f -o cmplx.lo
gcc -shared -L/usr/local/lib  -o libRlapack.so dlamc.lo dlapack0.lo
dlapack1.lo dlapack2.lo dlapack3.lo cmplx.lo  -lf77blas -latlas -lg2c
-lm -lgcc_s
/usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/../../../../powerpc-suse-linux
/bin/ld: Error: The symbol `s_wsfe' has a R_PPC_REL24 relocation, that
means '/usr/local/lib/libf77blas.a(xerbla.o)' was compiled without
-fPIC.
/usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/../../../../powerpc-suse-linux
/bin/ld: Error: The symbol `do_fio' has a R_PPC_REL24 relocation, that
means '/usr/local/lib/libf77blas.a(xerbla.o)' was compiled without
-fPIC.
/usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/../../../../powerpc-suse-linux
/bin/ld: Error: The symbol `do_fio' has a R_PPC_REL24 relocation, that
means '/usr/local/lib/libf77blas.a(xerbla.o)' was compiled without
-fPIC.
/usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/../../../../powerpc-suse-linux
/bin/ld: Error: The symbol `e_wsfe' has a R_PPC_REL24 relocation, that
means '/usr/local/lib/libf77blas.a(xerbla.o)' was compiled without
-fPIC.
/usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/../../../../powerpc-suse-linux
/bin/ld: Error: The symbol `s_stop' has a R_PPC_REL24 relocation, that
means '/usr/local/lib/libf77blas.a(xerbla.o)' was compiled without
-fPIC.
collect2: ld returned 1 exit status
make[4]: *** [libRlapack.so] Error 1
make[4]: Leaving directory
`/opt/devel/POWER/R/R-2.2.1/src/modules/lapack'
make[3]: *** [R] Error 2
make[3]: Leaving directory
`/opt/devel/POWER/R/R-2.2.1/src/modules/lapack'
make[2]: *** [R] Error 1
make[2]: Leaving directory `/opt/devel/POWER/R/R-2.2.1/src/modules'
make[1]: *** [R] Error 1
make[1]: Leaving directory `/opt/devel/POWER/R/R-2.2.1/src'
make: *** [R] Error 1
 
Any ideas would be appreciated.  I will continue reading the
documentation.

 
Anne Shelton
ITS Research IT Group
University at Albany
1400 Washington Ave. - MSC-100
Albany, NY 1
 
Office: 437-4525  Cell: 788-8634
 

[[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] Taking code from packages

2006-01-13 Thread Jeff Gentry

On Fri, 13 Jan 2006, Ales Ziberna wrote:
 I am currently in the process of creating (my first) package, which (when
 ready) I intend to publish to CRAN. In the process of creating this package
 I have taken some code form existing packages. I have actually copied parts
 of functions in to new functions. This code is usually something very basic
 such as Rand index. What is the proper procedure for this?

Why not simply specify that their package is a dependency and use their
code directly?

__
R-help@stat.math.ethz.ch 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] R newbie example code question

2006-01-13 Thread Michael Friendly
Ted:

Your .xthelp is extremely useful, help on Linux being otherwise
quite awkward to use since a pager in the same window make it hard
to cut/paste examples --- where 'more' or 'less' really means
'instead of' :-)

Suggestion: include -title

  cat(cat  $HLPFIL\nxterm -title 'R-help' -e less $HLPFIL \n, 
file=con)

hintIt would be nice if this solution made it into the R-FAQ or R-Admin
manual./hint
Failing that, it is a good example of something that would
work well in a wiki.  But, thankfully, you included the subject line
from the original thread to make it searchable in the news archives.


(Ted Harding) wrote:


   [R] help output paged in separate window
 
 The solution I finally opted for, and still use,
 is based (in a Linux environment) on including
 the following code in your .Rprofile file:
 
 
 .xthelp - function() {
 tdir - tempdir()
 pgr - paste(tdir, /pgr, sep=)
 con - file(pgr, w)
 cat(#! /bin/bash\n, file=con)
 cat(export HLPFIL=`mktemp , tdir, /R_hlp.XX`\n,
  sep=, file=con)
 cat(cat  $HLPFIL\nxterm -e less $HLPFIL \n, file=con)
 close(con)
 system(paste(chmod 755 , pgr, sep=))
 options(pager=pgr)
 }
 .xthelp()
 rm(.xthelp)
 
 
 (and it's also specific to the 'bash' shell because
 of the #! /bin/bash\n, but you should be able to
 change this appropriately). The above was posted by
 Roger Bivand on 27 May.
 
 When you start an R session, this code is executed as
 part of sourcing your .Rprofile, and it has the effect that
 any output from R which would be paged is stored in a
 temporary  file which is then read by 'less' in a
 separate X window which is detached from your R session
 (i.e. your command interface will not hang while it is
 being displayed). You can close the X window displaying
 the 'less' output by closing 'less' (e.g. type q), or
 you can leave it open and any new paged output will go
 into a new window -- so you can for instance do
 
 ?glm
 ?family
 ?binomial
 
 and you will have three mutually relevant help windows
 open at once between which you can cross-reference.
 
 As to extracting the code for examples, this is easy
 in X windows since you just use your mouse: left-button
 drag to hghlight a block of text, middle-button click
 to paste the block into another window (of course the
 mouse must be over the correct window!)
 
 So you can use the mouse to copy code from the help
 pages to the command window.
 
 As I say, this is a Linux-oriented solution, and I don't
 know what details would be required for anything similar
 in a Windows environment.
 
 It is also worth reading the various contributions to
 the above thread, since several suggestions were made.
 
 Hoping this helps,
 Ted.
 
 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 10-Jan-06   Time: 13:30:35
 -- XFMail --
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
 

-- 
Michael Friendly Email: friendly AT yorku DOT ca
Professor, Psychology Dept.
York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT  M3J 1P3 CANADA

__
R-help@stat.math.ethz.ch 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] Taking code from packages

2006-01-13 Thread Ales Ziberna
First thank you for you reply!



First let me assure you that I did not think or intent to just use their 
code and use GPL as an excuse.



Although I would like to just make my package dependant on theirs and use 
their functions that is not possible. The main reason is that I do not want 
to use the whole functions, but just parts of it. For example, I only need 
one statistics, while their function computes several. Since I call my 
function several thousand times, I want to make it as fast as possible.



I am also modified (although only slightly) the functions, I am a little 
worried about naming them as sole authors of the function, since I do not 
want to make them responsible for any mistakes I have made.



What I was thinking of doing is:

  1.. Notify the original authors!
  2.. In the Author (s) section of the function help, I would write Their 
name (Modifications made by My Name).
  3.. Use the same license (GPL 2) as they do.

I did not intent to write them as the package authors, since their code 
represent a very small part of the whole package.



How does that sound?



Best regards,

Ales Ziberna



P.S.: I did not find any other special copyright notices.





- Original Message - 
From: Duncan Murdoch [EMAIL PROTECTED]
To: Ales Ziberna [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Sent: Friday, January 13, 2006 1:46 PM
Subject: Re: [R] Taking code from packages


On 1/13/2006 2:04 AM, Ales Ziberna wrote:
 Hello!

 I am currently in the process of creating (my first) package, which (when
 ready) I intend to publish to CRAN. In the process of creating this 
 package
 I have taken some code form existing packages. I have actually copied 
 parts
 of functions in to new functions. This code is usually something very 
 basic
 such as Rand index. What is the proper procedure for this?

 Since most of R (and also the packages I have taken code form) is 
 published
 under GPL, I think this should be OK. However I do not know if:
 1. I should still ask authors of the packages for permission or at
 least notify them.

It is polite to notify them.

 2. Ad references to the functions (and packages) from which I had taken
 the code or only to the references they use.

The GPL requires that you maintain their copyright notices.  You have
the right to use their work, the GPL doesn't give you ownership of it.
The usual way to do this is to leave their copyright notice intact, and
add your own if you have made modifications.

An alternative which is usually (but not always) better is to say that
your package depends on theirs, and then just use their functions.  The
advantage is that it avoids any of the above mixed copyright issues, and
it makes sure that when the author fixes a bug, you benefit too.  The
disadvantage is that it makes your package dependent on theirs, so if
changes are needed in it for some future version of R, you'll have to
wait for the other maintainer to do them (or copy their code at that point).

(I'm a little sensitive about dependencies now, since the LaTeX seminar
template I've used a few times no longer works.  It depends on too many
LaTeX packages, and someone, somewhere has introduced incompatibilities
in them.  Seems like I'll be forced to use Powerpoint or Impress.)

Duncan Murdoch


 What about regarding code that was sent to the list, usually as a response
 to one of my problems. I assume that in this case it is best to consult 
 the
 author?

 Any comments and opinions are very welcomed!

 Best regards,
 Ales Ziberna

 __
 R-help@stat.math.ethz.ch 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] Problems installing R 2.2.1

2006-01-13 Thread Peter Dalgaard
Anne P Shelton [EMAIL PROTECTED] writes:

 We are trying to install R2.2.1 on a  IBM P655 Cluster, SuSE LE 9.1 
 We are using gcc v 3.3.3
  
 and we are getting this error on make
  
 g77 -fPIC  -g -O2 -ffloat-store -c dlamc.f -o dlamc.lo
 g77  -fPIC  -g -O2 -c dlapack0.f -o dlapack0.lo
 g77  -fPIC  -g -O2 -c dlapack1.f -o dlapack1.lo
 g77  -fPIC  -g -O2 -c dlapack2.f -o dlapack2.lo
 g77  -fPIC  -g -O2 -c dlapack3.f -o dlapack3.lo
 g77  -fPIC  -g -O2 -c cmplx.f -o cmplx.lo
 gcc -shared -L/usr/local/lib  -o libRlapack.so dlamc.lo dlapack0.lo
 dlapack1.lo dlapack2.lo dlapack3.lo cmplx.lo  -lf77blas -latlas -lg2c
 -lm -lgcc_s
 /usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/../../../../powerpc-suse-linux
 /bin/ld: Error: The symbol `s_wsfe' has a R_PPC_REL24 relocation, that
 means '/usr/local/lib/libf77blas.a(xerbla.o)' was compiled without
 -fPIC.
 /usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/../../../../powerpc-suse-linux
 /bin/ld: Error: The symbol `do_fio' has a R_PPC_REL24 relocation, that
 means '/usr/local/lib/libf77blas.a(xerbla.o)' was compiled without
 -fPIC.
 /usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/../../../../powerpc-suse-linux
 /bin/ld: Error: The symbol `do_fio' has a R_PPC_REL24 relocation, that
 means '/usr/local/lib/libf77blas.a(xerbla.o)' was compiled without
 -fPIC.
 /usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/../../../../powerpc-suse-linux
 /bin/ld: Error: The symbol `e_wsfe' has a R_PPC_REL24 relocation, that
 means '/usr/local/lib/libf77blas.a(xerbla.o)' was compiled without
 -fPIC.
 /usr/lib/gcc-lib/powerpc-suse-linux/3.3.3/../../../../powerpc-suse-linux
 /bin/ld: Error: The symbol `s_stop' has a R_PPC_REL24 relocation, that
 means '/usr/local/lib/libf77blas.a(xerbla.o)' was compiled without
 -fPIC.
 collect2: ld returned 1 exit status
 make[4]: *** [libRlapack.so] Error 1
 make[4]: Leaving directory
 `/opt/devel/POWER/R/R-2.2.1/src/modules/lapack'
 make[3]: *** [R] Error 2
 make[3]: Leaving directory
 `/opt/devel/POWER/R/R-2.2.1/src/modules/lapack'
 make[2]: *** [R] Error 1
 make[2]: Leaving directory `/opt/devel/POWER/R/R-2.2.1/src/modules'
 make[1]: *** [R] Error 1
 make[1]: Leaving directory `/opt/devel/POWER/R/R-2.2.1/src'
 make: *** [R] Error 1
  
 Any ideas would be appreciated.  I will continue reading the
 documentation.

Looks like you need to recompile ATLAS (or stop trying to link against
it). This is slightly tricky because ATLAS is not too keen on making
PIC code. AFAIR (it's been a while) you may or may not be given the
choice of modifying flags during the configuration phase (where need
to stick in -fPIC all over the place). Alternatively, you can just let
it run and diddle the Make.Linux_* file afterwards.

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

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


Re: [R] Taking code from packages

2006-01-13 Thread Gabor Grothendieck
On 1/13/06, Ales Ziberna [EMAIL PROTECTED] wrote:
 First thank you for you reply!



 First let me assure you that I did not think or intent to just use their
 code and use GPL as an excuse.



 Although I would like to just make my package dependant on theirs and use
 their functions that is not possible. The main reason is that I do not want
 to use the whole functions, but just parts of it. For example, I only need
 one statistics, while their function computes several. Since I call my
 function several thousand times, I want to make it as fast as possible.

You might want to time the difference just in case.Predicting performance
is notoriously difficult to do.

__
R-help@stat.math.ethz.ch 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] R newbie example code question

2006-01-13 Thread Ted Harding
On 13-Jan-06 Michael Friendly wrote:
 Ted:
 
 Your .xthelp is extremely useful, help on Linux being otherwise
 quite awkward to use since a pager in the same window make it hard
 to cut/paste examples --- where 'more' or 'less' really means
 'instead of' :-)

Glad you found it useful. I find it indispensable!
For the record: this is not my code but Roger Bivand's,
it being the one out of several suggestions on that thread
which I decided to adopt. I still admire the neat way he
wrapped it all up.

One of the beautiful features is that *anything* which would
be paged comes up in the separate window, so for instance
you could execute in R

  page(glm)

and you can then scan up and down, and cutpaste chunks if
you want, etc., and in several different windows for different
things at once (or even the same thing several times over if
you want to see different parts at the same time). Great for
playing with variants.

 Suggestion: include -title
 
 cat(cat  $HLPFIL\nxterm -title 'R-help' -e less $HLPFIL \n, 
 file=con)
 
 hintIt would be nice if this solution made it into the R-FAQ
 or R-Admin manual./hint Failing that, it is a good example of
 something that would work well in a wiki.  But, thankfully, you
 included the subject line from the original thread to make it
 searchable in the news archives.

A good hint! In fact a good place for it (or for a URL to it)
could be the help file for help and friends. In the circumstances,
this is where I would have looked first./hint

Best wishes,
Ted.

 (Ted Harding) wrote:
 
 
   [R] help output paged in separate window
 
 The solution I finally opted for, and still use,
 is based (in a Linux environment) on including
 the following code in your .Rprofile file:
 
 
 .xthelp - function() {
 tdir - tempdir()
 pgr - paste(tdir, /pgr, sep=)
 con - file(pgr, w)
 cat(#! /bin/bash\n, file=con)
 cat(export HLPFIL=`mktemp , tdir, /R_hlp.XX`\n,
  sep=, file=con)
 cat(cat  $HLPFIL\nxterm -e less $HLPFIL \n, file=con)
 close(con)
 system(paste(chmod 755 , pgr, sep=))
 options(pager=pgr)
 }
 .xthelp()
 rm(.xthelp)
 
 
 (and it's also specific to the 'bash' shell because
 of the #! /bin/bash\n, but you should be able to
 change this appropriately). The above was posted by
 Roger Bivand on 27 May.
 
 When you start an R session, this code is executed as
 part of sourcing your .Rprofile, and it has the effect that
 any output from R which would be paged is stored in a
 temporary  file which is then read by 'less' in a
 separate X window which is detached from your R session
 (i.e. your command interface will not hang while it is
 being displayed). You can close the X window displaying
 the 'less' output by closing 'less' (e.g. type q), or
 you can leave it open and any new paged output will go
 into a new window -- so you can for instance do
 
 ?glm
 ?family
 ?binomial
 
 and you will have three mutually relevant help windows
 open at once between which you can cross-reference.
 
 As to extracting the code for examples, this is easy
 in X windows since you just use your mouse: left-button
 drag to hghlight a block of text, middle-button click
 to paste the block into another window (of course the
 mouse must be over the correct window!)
 
 So you can use the mouse to copy code from the help
 pages to the command window.
 
 As I say, this is a Linux-oriented solution, and I don't
 know what details would be required for anything similar
 in a Windows environment.
 
 It is also worth reading the various contributions to
 the above thread, since several suggestions were made.
 
 Hoping this helps,
 Ted.
 
 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 10-Jan-06   Time: 13:30:35
 -- XFMail --
 
 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide!
 http://www.R-project.org/posting-guide.html
 
 
 -- 
 Michael Friendly Email: friendly AT yorku DOT ca
 Professor, Psychology Dept.
 York University  Voice: 416 736-5115 x66249 Fax: 416 736-5814
 4700 Keele Streethttp://www.math.yorku.ca/SCS/friendly.html
 Toronto, ONT  M3J 1P3 CANADA


E-Mail: (Ted Harding) [EMAIL PROTECTED]
Fax-to-email: +44 (0)870 094 0861
Date: 13-Jan-06   Time: 15:45:47
-- XFMail --

__
R-help@stat.math.ethz.ch 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] Can I ask for the C code inside an R function using .C?

2006-01-13 Thread Yingfu Xie
Hello, all,

It is a general question, but I couldn't find the answer elsewhere. 
I am using an R function using .C but don't understand one of its
behaviors without the C code. I am wondering the so-called 'open
source'. It doesn't include the C code together with the R function,
does it? So what I want to ask is whether it is justified, possible or
polite to ask for the C code behind the R function.
Sorry if I miss anything! Thank you as always!

Regards,
Yingfu
###

This message has been scanned by F-Secure Anti-Virus for Mic...{{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] Taking code from packages

2006-01-13 Thread Prof Brian Ripley
The thing that is most important and has not been mentioned is to ensure 
that modified functions have a changed name.

People have taken my code without consulting me, changed what it did and 
put it up in a package with the original name (and no indication that I 
was the author), and then quoted GPL at me when I complained.  So this may 
perhaps help you understand where some of your answers are coming from.

I would suggest adding to your suggested documentation the exact source 
you used (it makes it easier to find out if that had been updated later).

R itself borrows software from other packages, and you will see some 
examples of how it is referenced in various places including COPYRIGHTS.
In retrospect we should have been more careful to rename things, e.g. 
entry points in conpiled code, even if we made no changes as the original 
author might want to use his current versions with R.


On Fri, 13 Jan 2006, Ales Ziberna wrote:

 First thank you for you reply!



 First let me assure you that I did not think or intent to just use their
 code and use GPL as an excuse.



 Although I would like to just make my package dependant on theirs and use
 their functions that is not possible. The main reason is that I do not want
 to use the whole functions, but just parts of it. For example, I only need
 one statistics, while their function computes several. Since I call my
 function several thousand times, I want to make it as fast as possible.



 I am also modified (although only slightly) the functions, I am a little
 worried about naming them as sole authors of the function, since I do not
 want to make them responsible for any mistakes I have made.



 What I was thinking of doing is:

  1.. Notify the original authors!
  2.. In the Author (s) section of the function help, I would write Their
 name (Modifications made by My Name).
  3.. Use the same license (GPL 2) as they do.

 I did not intent to write them as the package authors, since their code
 represent a very small part of the whole package.



 How does that sound?



 Best regards,

 Ales Ziberna



 P.S.: I did not find any other special copyright notices.





 - Original Message -
 From: Duncan Murdoch [EMAIL PROTECTED]
 To: Ales Ziberna [EMAIL PROTECTED]
 Cc: r-help@stat.math.ethz.ch
 Sent: Friday, January 13, 2006 1:46 PM
 Subject: Re: [R] Taking code from packages


 On 1/13/2006 2:04 AM, Ales Ziberna wrote:
 Hello!

 I am currently in the process of creating (my first) package, which (when
 ready) I intend to publish to CRAN. In the process of creating this
 package
 I have taken some code form existing packages. I have actually copied
 parts
 of functions in to new functions. This code is usually something very
 basic
 such as Rand index. What is the proper procedure for this?

 Since most of R (and also the packages I have taken code form) is
 published
 under GPL, I think this should be OK. However I do not know if:
 1. I should still ask authors of the packages for permission or at
 least notify them.

 It is polite to notify them.

 2. Ad references to the functions (and packages) from which I had taken
 the code or only to the references they use.

 The GPL requires that you maintain their copyright notices.  You have
 the right to use their work, the GPL doesn't give you ownership of it.
 The usual way to do this is to leave their copyright notice intact, and
 add your own if you have made modifications.

 An alternative which is usually (but not always) better is to say that
 your package depends on theirs, and then just use their functions.  The
 advantage is that it avoids any of the above mixed copyright issues, and
 it makes sure that when the author fixes a bug, you benefit too.  The
 disadvantage is that it makes your package dependent on theirs, so if
 changes are needed in it for some future version of R, you'll have to
 wait for the other maintainer to do them (or copy their code at that point).

 (I'm a little sensitive about dependencies now, since the LaTeX seminar
 template I've used a few times no longer works.  It depends on too many
 LaTeX packages, and someone, somewhere has introduced incompatibilities
 in them.  Seems like I'll be forced to use Powerpoint or Impress.)

 Duncan Murdoch


 What about regarding code that was sent to the list, usually as a response
 to one of my problems. I assume that in this case it is best to consult
 the
 author?

 Any comments and opinions are very welcomed!

 Best regards,
 Ales Ziberna

 __
 R-help@stat.math.ethz.ch 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


-- 
Brian D. Ripley,  [EMAIL PROTECTED]

Re: [R] Can I ask for the C code inside an R function using .C?

2006-01-13 Thread Liaw, Andy
Source code for R and all CRAN packages are on CRAN.  If you want the C or
Fortran code used in R or add-on packages, you need to download the source
(the .tar.gz files).  You won't see the code if you just install the binary.

Andy

From: Yingfu Xie
 
 Hello, all,
 
 It is a general question, but I couldn't find the answer elsewhere. 
 I am using an R function using .C but don't understand one of its
 behaviors without the C code. I am wondering the so-called 'open
 source'. It doesn't include the C code together with the R function,
 does it? So what I want to ask is whether it is justified, possible or
 polite to ask for the C code behind the R function.
 Sorry if I miss anything! Thank you as always!
 
 Regards,
 Yingfu
 ###
 
 This message has been scanned by F-Secure Anti-Virus for 
 Mic...{{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
 


__
R-help@stat.math.ethz.ch 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] Can I ask for the C code inside an R function using .C?

2006-01-13 Thread Ingmar Visser
You can download the source from any package from a CRAN mirror near you and
the src directory will contain the source code of the included C and fortran
functions.
hth, ingmar

 From: Yingfu Xie [EMAIL PROTECTED]
 Date: Fri, 13 Jan 2006 17:04:43 +0100
 To: r-help@stat.math.ethz.ch
 Subject: [R] Can I ask for the C code inside an R function using .C?
 
 Hello, all,
 
 It is a general question, but I couldn't find the answer elsewhere.
 I am using an R function using .C but don't understand one of its
 behaviors without the C code. I am wondering the so-called 'open
 source'. It doesn't include the C code together with the R function,
 does it? So what I want to ask is whether it is justified, possible or
 polite to ask for the C code behind the R function.
 Sorry if I miss anything! Thank you as always!
 
 Regards,
 Yingfu
 ###
 
 This message has been scanned by F-Secure Anti-Virus for Mic...{{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


__
R-help@stat.math.ethz.ch 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] Saving data in an R package - how to maintain that t avariable is a 'factor' when it is coded as 1, 2, 3...

2006-01-13 Thread Søren Højsgaard
I have a .txt file obtained by saving a data frame in which the first four 
columns are factors (but represented as 1,2,3 etc). The first four lines are
 
Pig Evit Cu Litter Start Weight Feed Time
4601 1 1 1 26.5 26.5 NA 1
4601 1 1 1 26.5 27.5 5.25 2
4601 1 1 1 26.5 36.5 17.6 3
4601 1 1 1 26.5 40.2 28.5 4

I would like to include that data set in an R-package. When I load the data 
from the package the first four columns are read in as numeric variables. This 
is consistent with the documentation of read.table - but it is not what I want! 
I can of course change the coding of the variables, but there ought to be 
another way. Can anyone help me on that?
Best regards
Søren Højsgaard

__
R-help@stat.math.ethz.ch 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] CRAN versions of lme4/Matrix don't appear to work with R 2.1.1

2006-01-13 Thread Spencer Graves
  Are you familiar with sessionInfo(), e.g.:

  sessionInfo()
R version 2.2.1, 2005-12-20, i386-pc-mingw32

attached base packages:
[1] methods   stats graphics  grDevices utils datasets
[7] base

other attached packages:
  lme4   latticeMatrix
  0.98-1 0.12-11  0.99-6

  This can almost eliminate the possibilities for typographical errors 
in specifying the version name.  The posting guide 
(www.R-project.org/posting-guide.html) also asks posters to mention 
mention the platform (Windows2000, Linux, MacOS X).

  Best Wishes,
  spencer graves

White, Charles E WRAIR-Wash DC wrote:
 After downloading from the WA mirror, the lme4 related packages appear
 to run fine . Thanks for everyone's help.
 
 Chuck
 
 __
 R-help@stat.math.ethz.ch 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] Saving data in an R package - how to maintain that t avariable is a 'factor' when it is coded as 1, 2, 3...

2006-01-13 Thread jim holtman
colClasses

 x - read.table('clipboard', header=T,
colClasses=c(rep('factor',4),rep('numeric',4)))

 x

   Pig Evit Cu Litter Start   Weight  Feed Time
1 46011  1  1  26.5 26.5NA1
2 46011  1  1  26.5 27.5  5.252
3 46011  1  1  26.5 36.5 17.603
4 46011  1  1  26.5 40.2 28.504
 str(x)
`data.frame':   4 obs. of  8 variables:
 $ Pig   : Factor w/ 1 level 4601: 1 1 1 1
 $ Evit  : Factor w/ 1 level 1: 1 1 1 1
 $ Cu: Factor w/ 1 level 1: 1 1 1 1
 $ Litter: Factor w/ 1 level 1: 1 1 1 1
 $ Start : num  26.5 26.5 26.5 26.5
 $ Weight: num  26.5 27.6 36.5 40.3
 $ Feed  : numNA  5.2 17.6 28.5
 $ Time  : num  1 2 3 4




On 1/13/06, Søren Højsgaard [EMAIL PROTECTED] wrote:

 I have a .txt file obtained by saving a data frame in which the first four
 columns are factors (but represented as 1,2,3 etc). The first four lines are

 Pig Evit Cu Litter Start Weight Feed Time
 4601 1 1 1 26.5 26.5 NA 1
 4601 1 1 1 26.5 27.5 5.25 2
 4601 1 1 1 26.5 36.5 17.6 3
 4601 1 1 1 26.5 40.2 28.5 4

 I would like to include that data set in an R-package. When I load the
 data from the package the first four columns are read in as numeric
 variables. This is consistent with the documentation of read.table - but
 it is not what I want! I can of course change the coding of the variables,
 but there ought to be another way. Can anyone help me on that?
 Best regards
 Søren Højsgaard

 __
 R-help@stat.math.ethz.ch 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] Saving data in an R package - how to maintain that t avariable is a 'factor' when it is coded as 1, 2, 3...

2006-01-13 Thread Prof Brian Ripley

?read.table, see argument colClasses.

You can use a .R wrapper to a .tab file in the data directory of a 
package.  Or, perhaps better, include it as a .rda file.


On Fri, 13 Jan 2006, Søren Højsgaard wrote:


I have a .txt file obtained by saving a data frame in which the first four 
columns are factors (but represented as 1,2,3 etc). The first four lines are

Pig Evit Cu Litter Start Weight Feed Time
4601 1 1 1 26.5 26.5 NA 1
4601 1 1 1 26.5 27.5 5.25 2
4601 1 1 1 26.5 36.5 17.6 3
4601 1 1 1 26.5 40.2 28.5 4

I would like to include that data set in an R-package. When I load the data 
from the package the first four columns are read in as numeric variables. This 
is consistent with the documentation of read.table - but it is not what I want! 
I can of course change the coding of the variables, but there ought to be 
another way. Can anyone help me on that?
Best regards
Søren Højsgaard

__
R-help@stat.math.ethz.ch 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

[R] glmmPQL: Na/NaN/Inf in foreign function call

2006-01-13 Thread David Reitter
I'm using glmmPQL, and I still have a few problems with it.
In addition to the issue reported earlier, I'm getting the following  
error and I was wondering if there's something I can do about it.


Error in logLik.reStruct(object, conLin) : Na/NaN/Inf in foreign  
function call (arg 3)

... Warnings:
1: Singular precistion matrix in level -1, block 4
(...)
4: 

The interaction terms are

primed ~ log(dist) * role
random = ~ dist | target.utt / prime.utt

The family is binomial (logit).

I ensured that log(dist) is always [0; 1]. Role is a factor (binary).  
target.utt and prime.utt are categories as well.

This is version 2.1.1 - is the latest version more reliable?

Thanks for any help you can give me.
Dave

__
R-help@stat.math.ethz.ch 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] Can I ask for the C code inside an R function using .C?

2006-01-13 Thread Francisco J. Zagmutt
If you have a slow connection and/or you don't want to download the entire 
source code you can find the sources for R on this site 
https://svn.r-project.org/R/trunk/

Francisco


From: Liaw, Andy [EMAIL PROTECTED]
To: 'Yingfu Xie' [EMAIL PROTECTED], r-help@stat.math.ethz.ch
Subject: Re: [R] Can I ask for the C code inside an R function using .C?
Date: Fri, 13 Jan 2006 11:13:51 -0500

Source code for R and all CRAN packages are on CRAN.  If you want the C or
Fortran code used in R or add-on packages, you need to download the source
(the .tar.gz files).  You won't see the code if you just install the 
binary.

Andy

From: Yingfu Xie
 
  Hello, all,
 
  It is a general question, but I couldn't find the answer elsewhere.
  I am using an R function using .C but don't understand one of its
  behaviors without the C code. I am wondering the so-called 'open
  source'. It doesn't include the C code together with the R function,
  does it? So what I want to ask is whether it is justified, possible or
  polite to ask for the C code behind the R function.
  Sorry if I miss anything! Thank you as always!
 
  Regards,
  Yingfu
  ###
 
  This message has been scanned by F-Secure Anti-Virus for
  Mic...{{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
 
 

__
R-help@stat.math.ethz.ch 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] better way to replace missing values with zero

2006-01-13 Thread roger bos
I would like to replace all missing values (NAs) with zero like below--where
ever they may be--but some of the column classes are non-numeric so I get an
error:

 dim(temp)
[1] 699 313
 temp[is.na(temp)] - 0
Error in as.Date.default(value) : do not know how to convert 'value' to
class Date


So I have to use more conveluted code:

   for (k in c(1:ncol(temp))) {
   if (class(temp[, k])==numeric) {
   temp[, k][is.na(temp[, k])] - 0
   }
   }

This is much more code and requires a for loop.  Can anyone please show me a
better way?

Thanks,

Roger

[[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] Can I ask for the C code inside an R function using .C?

2006-01-13 Thread Liaw, Andy
Just wondering:  How do people with slow connections get R?  The Windows
binary is about 25MB, while the source .tar.gz is only 13.7MB.

Andy

From: Francisco J. Zagmutt
 
 
 If you have a slow connection and/or you don't want to 
 download the entire 
 source code you can find the sources for R on this site 
 https://svn.r-project.org/R/trunk/
 
 Francisco
 
 
 From: Liaw, Andy [EMAIL PROTECTED]
 To: 'Yingfu Xie' [EMAIL PROTECTED], 
 r-help@stat.math.ethz.ch
 Subject: Re: [R] Can I ask for the C code inside an R 
 function using .C?
 Date: Fri, 13 Jan 2006 11:13:51 -0500
 
 Source code for R and all CRAN packages are on CRAN.  If you 
 want the C or
 Fortran code used in R or add-on packages, you need to 
 download the source
 (the .tar.gz files).  You won't see the code if you just install the 
 binary.
 
 Andy
 
 From: Yingfu Xie
  
   Hello, all,
  
   It is a general question, but I couldn't find the answer 
 elsewhere.
   I am using an R function using .C but don't understand one of its
   behaviors without the C code. I am wondering the so-called 'open
   source'. It doesn't include the C code together with the 
 R function,
   does it? So what I want to ask is whether it is 
 justified, possible or
   polite to ask for the C code behind the R function.
   Sorry if I miss anything! Thank you as always!
  
   Regards,
   Yingfu
   ###
  
   This message has been scanned by F-Secure Anti-Virus for
   Mic...{{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
  
  
 
 __
 R-help@stat.math.ethz.ch 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] Variance-covariance by factor

2006-01-13 Thread Yang, Richard

Dear all,

I have a data frame with one factor and four numeric variables and
wish to obtain the var-cor matrix separately by factor. I tried by() and
sapply() but getting nowhere. I understand this can be done by subsetting
the dataframe, but there should have some sleek ways of doing it.

Here is a simulated dataframe;

s - rep(c(A,B,C), c(25,22,18))

d - c(rnorm(25,14,2.6),rnorm(22,15.2,2.8),rnorm(18,16.4,3.0))
h - c(rnorm(25,10,1.4),rnorm(22,11.2,1.8),rnorm(18,12.3,2.0))
l - c(rnorm(25,6.8,1.6), rnorm(22,7.0,1.7),rnorm(18,7.3,1.8))
w - c(rnorm(25,2.5,0.65),rnorm(22,2.6,0.7),rnorm(18,2.8,0.71))

sim - data.frame(cbind(S = s, D= d, H=h,L=l,W=w))

 sim.var - sapply(split(sim, sim$S), function(z) var(z))
Error in var(z) : missing observations in cov/cor
In addition: Warning message:
NAs introduced by coercion 

 sim.var - by(sim, sim$S, function(z) var(z))
Error in var(z) : missing observations in cov/cor
In addition: Warning message:
NAs introduced by coercion 

Debug() and trac() the function got no further info.

Because the error suggested missing data, I looked at the data frame and was
surprised

 str(sim)
`data.frame':   65 obs. of  5 variables:
 $ S: Factor w/ 3 levels A,B,C: 1 1 1 1 1 1 1 1 1 1 ...
 $ D: Factor w/ 65 levels 10.0860856437045,..: 51 12 21 11 8 15 57 44 19
60 ...
 $ H: Factor w/ 65 levels 10.0345903489406,..: 17 2 4 52 6 21 29 9 62 10
...
 $ L: Factor w/ 65 levels 10.3854663209663,..: 10 6 23 55 60 8 58 65 11 2
...
 $ W: Factor w/ 65 levels 0.93902749732563,..: 38 13 33 12 22 39 47 31 36
53 ...

Why the data.frame() converts numeric vectors d, h, l, w into factors? 

Any suggestions for 1) how to compute var-cor by factor in a data frame, and
2) why data.frame converts numeric variables into factors ?

 sessionInfo()
R version 2.2.0, 2005-10-06, i386-pc-mingw32 

attached base packages:
[1] methods   stats graphics  grDevices utils datasets
base 

Thanks,

Richard  Yang

Northern Forestry Centre   /Centre de foresterie du Nord
Canadian Forest Service/Service canadien des forêts
Natural Resources Canada   /Ressources naturelles Canada
5320-122 Street/5320, rue 122

Edmonton Alberta Canada
T6H 3S5



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

2006-01-13 Thread Guenther, Cameron
Hello,
I have a dataset d which is
 d
 pop catch 
1   66462.01 10807.757 
2   87486.73 46257.885 
3   57211.64  9345.058 
4   71321.62  4892.868 
5  100024.89 27334.248 
6  104504.91 48535.092 
7   95295.51 39348.195 
8   93737.35 34343.489 
9   89375.05 28750.743 
10  95312.65 30755.064 
11 100888.17 55404.370 
12  84790.23 37751.074 
13  81129.82 29277.443 
14  69797.09 21500.398 
15  61690.34 18199.664 
16  60671.08 19349.051 
17  62852.57 16300.982 
18  90646.32 34793.148 

And a function opt1:

opt1 - function (x) {
  Z - x + M
  c.hat - (x/Z)*pop*(1-exp(-Z))
  y - (catch - c.hat)^2
  return(y)
  }

And define M = 0.25 
For each row I want to return a value F that is a minimization of the
opt1 function

I have tried many variations of:
d$F-apply(d,2,optim(0.3,opt1,method=BFGS)
and even:
For (I in 1:length(pop))apply(d,2,optim(0.3,opt1,method=BFGS))

Every time I get the same error message

Error in optim(0.3, opt1, method = BFGS) : 
objective function in optim evaluates to length 18 not 1

So the apply function is returning 18 values of F which I want but the
function only wants to return 1 value.

Any Suggestions.
Thanks,
Cam

__
R-help@stat.math.ethz.ch 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] find mean of a list of timeseries

2006-01-13 Thread Gabor Grothendieck
Try:

(a+b+c)/3

On 1/13/06, tom wright [EMAIL PROTECTED] wrote:
 Can someone please give me a clue how to 're'write this so I dont need
 to use loops.

 a-ts(matrix(c(1,1,1,10,10,10,20,20,20),nrow=3),names=c('var1','var2','var3'))
 b-ts(matrix(c(2,2,2,11,11,11,21,21,21),nrow=3),names=c('var1','var2','var3'))
 c-ts(matrix(c(3,3,3,12,12,12,22,22,22),nrow=3),names=c('var1','var2','var3'))

 data-list(a,b,c)

 I now want to find the means of all vectors var1,var2 and var3

 i.e. I need to end up with a new time series with three data vectors
 (var1, var2 and var3)
 result-ts(matrix(c(2,2,2,11,11,11,21,21,21),nrow=3),names=c('var1','var2','var3))

 I think its the list thats throwing my use of apply, I might be wrong
 but what other data structure could I use?

 Many thanks
 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


[R] update 'groupedData' and 'lme' objects

2006-01-13 Thread Marco Geraci
  Dear R users, I have the following code:
  
  require(nlme)
  myfunc - function(data, n, m, maxIter = 3){
  working - groupedData(formula = y~x|id, data=data)
val - NULL
  r - 0
 while(r  maxIter){
  new.data - data.frame(x=rnorm(n),y=rnorm(n),id=rep(1:n,each=m))
  working - update(working, data = new.data)
  # val - some results
  r - r + 1
 }
val
}
  n - 10
m - 2
foo - data.frame(x=rnorm(n),y=rnorm(n),id=rep(1:n,each=m))
myfunc(foo, n=n, m=m)
  
-
  
I get this error message:
   myfunc(foo, n=n, m=m)
Error in inherits(data, data.frame) : object new.data not found
   
  I believe the error is generated within the evaluation of the function 
'update'.
The real code I used is more complicated but basically I got a similar error 
message when using 'update' for an object 'lme', e.g.
   
  function(...){
  fit.lme - lme(...)
 while(...){
create newdata
  fit.lme - update(fit.lme, newdata)
 }
  }
   
  Everything works fine when using an object 'lm'
 
  function(...){

  fit.lm - lm(...)
 while(...){
create newdata
  fit.lm - update(fit.lm, newdata)
 }
  }
  
I might be wrong, but I guess that this problem is related to different 
evaluation 
  frames, the one invoked by 'myfunc' and the one invoked by 'update' 
  (both for 'lme' and 'groupedData' objects).
   
  Any suggestion to overcome this problem would be greatly appreciated
  Marco Geraci
   
  R version: 2.2.1
  nlme version: 3.1-68.1
  OS: Window XP
   



-

 Photo Books. You design it and we’ll bind it!
[[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] Can I ask for the C code inside an R function using .C?

2006-01-13 Thread Francisco J. Zagmutt
Well, if you have a slow modem connection and you are an average user that 
doesn't want (or doesn't know how) to compile the source code, you may spend 
half an hour or more downloading the windows binary. Then you realize you 
want to see a .C function and you will have to spend another 15 to 20 
minutes downloading the source tar.gz...OR you can lookup the specific 
function in the mentioned website in a fraction of the time.  Off course, 
overall if you check C or Fortran functions all the time you may want to 
have a local copy of the source.  I think is great that users have that 
flexibility, hence they should be aware of both options.

Cheers

Francisco



,
you may prefer just to visit a web site and see the specific function that 
you want to learn about, rather than waiting another 15 to 20 minutes to 
download the source tar.gz.

From: Liaw, Andy [EMAIL PROTECTED]
To: 'Francisco J. Zagmutt' 
[EMAIL PROTECTED],[EMAIL PROTECTED],r-help@stat.math.ethz.ch
Subject: RE: [R] Can I ask for the C code inside an R function using .C?
Date: Fri, 13 Jan 2006 13:26:02 -0500

Just wondering:  How do people with slow connections get R?  The Windows
binary is about 25MB, while the source .tar.gz is only 13.7MB.

Andy

From: Francisco J. Zagmutt
 
 
  If you have a slow connection and/or you don't want to
  download the entire
  source code you can find the sources for R on this site
  https://svn.r-project.org/R/trunk/
 
  Francisco
 
 
  From: Liaw, Andy [EMAIL PROTECTED]
  To: 'Yingfu Xie' [EMAIL PROTECTED],
  r-help@stat.math.ethz.ch
  Subject: Re: [R] Can I ask for the C code inside an R
  function using .C?
  Date: Fri, 13 Jan 2006 11:13:51 -0500
  
  Source code for R and all CRAN packages are on CRAN.  If you
  want the C or
  Fortran code used in R or add-on packages, you need to
  download the source
  (the .tar.gz files).  You won't see the code if you just install the
  binary.
  
  Andy
  
  From: Yingfu Xie
   
Hello, all,
   
It is a general question, but I couldn't find the answer
  elsewhere.
I am using an R function using .C but don't understand one of its
behaviors without the C code. I am wondering the so-called 'open
source'. It doesn't include the C code together with the
  R function,
does it? So what I want to ask is whether it is
  justified, possible or
polite to ask for the C code behind the R function.
Sorry if I miss anything! Thank you as always!
   
Regards,
Yingfu
###
   
This message has been scanned by F-Secure Anti-Virus for
Mic...{{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
   
   
  
  __
  R-help@stat.math.ethz.ch mailing list
  https://stat.ethz.ch/mailman/listinfo/r-help
  PLEASE do read the posting guide!
  http://www.R-project.org/posting-guide.html
 
 
 


--
Notice:  This e-mail message, together with any attachments...{{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] apply

2006-01-13 Thread Berton Gunter
You are not calling apply() properly. Please read relevant reference
material carefully. You might also wish to pick up one of the several good
books on R (check CRAN website) -- I like VR's S PROGRAMMING.

I did not go through your example in detail, but your apply() call should be
of the form

apply(d,2,function(x)optim(x,...))

You may or may not get into scoping problems with the opt1 argument and have
to pass it in explicitly -- I can't remember how things work with optim. 

-- Bert Gunter
Genentech Non-Clinical Statistics
South San Francisco, CA
 
The business of the statistician is to catalyze the scientific learning
process.  - George E. P. Box
 
 

 -Original Message-
 From: [EMAIL PROTECTED] 
 [mailto:[EMAIL PROTECTED] On Behalf Of 
 Guenther, Cameron
 Sent: Friday, January 13, 2006 11:03 AM
 To: [EMAIL PROTECTED]
 Subject: [R] apply
 
 Hello,
 I have a dataset d which is
  d
  pop catch 
 1   66462.01 10807.757 
 2   87486.73 46257.885 
 3   57211.64  9345.058 
 4   71321.62  4892.868 
 5  100024.89 27334.248 
 6  104504.91 48535.092 
 7   95295.51 39348.195 
 8   93737.35 34343.489 
 9   89375.05 28750.743 
 10  95312.65 30755.064 
 11 100888.17 55404.370 
 12  84790.23 37751.074 
 13  81129.82 29277.443 
 14  69797.09 21500.398 
 15  61690.34 18199.664 
 16  60671.08 19349.051 
 17  62852.57 16300.982 
 18  90646.32 34793.148 
 
 And a function opt1:
 
 opt1 - function (x) {
   Z - x + M
   c.hat - (x/Z)*pop*(1-exp(-Z))
   y - (catch - c.hat)^2
   return(y)
   }
 
 And define M = 0.25 
 For each row I want to return a value F that is a minimization of the
 opt1 function
 
 I have tried many variations of:
 d$F-apply(d,2,optim(0.3,opt1,method=BFGS)
 and even:
 For (I in 1:length(pop))apply(d,2,optim(0.3,opt1,method=BFGS))
 
 Every time I get the same error message
 
 Error in optim(0.3, opt1, method = BFGS) : 
 objective function in optim evaluates to length 18 not 1
 
 So the apply function is returning 18 values of F which I want but the
 function only wants to return 1 value.
 
 Any Suggestions.
 Thanks,
 Cam
 
 __
 R-help@stat.math.ethz.ch 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] R and filemaker pro DB

2006-01-13 Thread Sean Davis



On 1/13/06 7:08 AM, Michael Bibo [EMAIL PROTECTED] wrote:

 I have been looking for a database application to use in conjunction with R
 (on
 a Windows network).  When I approached my organization's IT department to ask
 about using MySQL, they made a counter-offer of Filemaker Pro (v8).  It is not
 specifically mentioned in 'R Data Import/Export', nor do searches of the
 archives turn up much information.
 
 Does anyone have any experience using Filemaker Pro with R?
 Should package RODBC work with Filemaker, as it is odbc-compliant? (I will be
 doing some trials anyway).
 Any other relevant advice welcome.

I have used Fmpro via RODBC a bit.  I also use MySQL and PostgreSQL quite a
bit with R.  For smaller datasets, Fmpro is probably fine, but for larger
datasets (more than a few thousand rows), fmpro is pretty slow compared to a
dedicated SQL server.  Also, there is a great deal of flexibility in
database design, tuning, backup, and enterpriseness.  However, note that
SQL servers do not come with GUI front ends like fmpro, so if you are
building a database for use other than data management, fmpro is a good
quick solution.  So, I would do what you suggest you are going to do and set
up both MySQL or PostgreSQL and fmpro and see which better meets your needs.
They are quite different in many ways, though.

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] for loop should check the looping index !!

2006-01-13 Thread johan Faux
Hello ,
   
  a-c(1)
  for(i in 2:length(a))
  do.something with a[[i]]
   
  I get :
  Error in a[[i]] : subscript out of bounds
   
  Am I missing something here?  Doesnt R check the value of i inside for and 
if the condition is not tru, dont do anything 
   
  thanks,
  johan


-

 Got holiday prints? See all the ways to get quality prints in your hands ASAP.
[[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] Idempotent apply

2006-01-13 Thread hadley wickham
One small problem with apply is that it is not idempotent - it always
puts the result vector in the first dimension of the result array. For
example:

a - array(1:24, c(2,3,4))
dim(apply(a, c(1,2), I))
dim(apply(a, c(1,2), diff))

I've written a wrapper around apply that rearranges the dimensions
into the original order.

# Idempotent apply
iapply - function (X, MARGIN, FUN, ...)  {
dims - c((1:length(dim(X)))[!(1:length(dim(X)) %in% MARGIN)], MARGIN)
res - apply(X, MARGIN, FUN)

if (length(dim(res)) == length(dims)) {
aperm(res, order(dims))
} else {
res
}   
}

dim(iapply(a, c(1,2), I))
dim(iapply(a, c(1,2), diff))

Hopefully this may be of use to someone else.  The function isn't
completely satisfying as apply doesn't deal nicely with functions that
return higher-dimensional arrays (eg.  apply(a, 1, I)) and reduces 1-D
arrays to vectors (eg. apply(a,3,sum)).  Any comments on the code
would be greatfully appreciated.

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


[R] Syntax for linear mixed model

2006-01-13 Thread N.W.Galwey
The syntax below works, and gives the expected results, in R version 2.0.0,
provided that I have loaded packages Matrix, latticeExtra and lme4.
However, I cannot get it to work in version 2.2.1.   Can anyone tell me how
to fit this model in the more recent version?

 

Thanks in anticipation,

 

Nick Galwey

 

barleyprogeny.model1lme - lme(yield_g_m2 ~ 1, 

   data = barleyprogeny.unbalanced, random = ~ 1|fline + fblock) 

 


[[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] for loop should check the looping index !!

2006-01-13 Thread Tony Plate
Yep, you missed the fact that 2:1 generates the sequence c(2,1).

Personally, I'd excuse you for missing this, as the documentation for 
seq says:

  The operator ':' and the 'seq(from, to)' form generate the
  sequence 'from, from+1, ..., to'.

Maybe I'm missing something, but I don't see anywhere on the help page 
for seq and : any mention of the fact the seq() generates a descending 
sequence if 'to' is less than 'from'.

In programming, *never* use a construct like 1:length(x) or 2:length(x), 
always using something like seq(1,len=length(x)) (or simply 
seq(len=length(x)), or seq(2, len=length(x)-1) or seq(along=x)[-1].

-- Tony Plate


johan Faux wrote:
 Hello ,

   a-c(1)
   for(i in 2:length(a))
   do.something with a[[i]]

   I get :
   Error in a[[i]] : subscript out of bounds

   Am I missing something here?  Doesnt R check the value of i inside for 
 and if the condition is not tru, dont do anything 

   thanks,
   johan
 
   
 -
 
  Got holiday prints? See all the ways to get quality prints in your hands 
 ASAP.
   [[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-help@stat.math.ethz.ch 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] for loop should check the looping index !!

2006-01-13 Thread Peter Dalgaard
johan Faux [EMAIL PROTECTED] writes:

 Hello ,

   a-c(1)
   for(i in 2:length(a))
   do.something with a[[i]]

   I get :
   Error in a[[i]] : subscript out of bounds

   Am I missing something here?  Doesnt R check the value of i inside for 
 and if the condition is not tru, dont do anything 

Well,

 2:1
[1] 2 1


The for loop as such has no idea what you're going to do with the
index variable, so will faithfully try to do.something with a[[2]]

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

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


Re: [R] apply

2006-01-13 Thread Sundar Dorai-Raj
In addition the error message explicitly says:

Error in optim(0.3, opt1, method = BFGS) :
  objective function in optim evaluates to length 18 not 1

And from the objective function we see

opt1 - function (x) {
   Z - x + M
   c.hat - (x/Z)*pop*(1-exp(-Z))
   y - (catch - c.hat)^2
   return(y)
}

The last line should be replaced by:

sum(y)

rather than return(y). See ?optim, ?apply, and the reference Bert 
gives below.

HTH,

--sundar


Berton Gunter wrote:
 You are not calling apply() properly. Please read relevant reference
 material carefully. You might also wish to pick up one of the several good
 books on R (check CRAN website) -- I like VR's S PROGRAMMING.
 
 I did not go through your example in detail, but your apply() call should be
 of the form
 
 apply(d,2,function(x)optim(x,...))
 
 You may or may not get into scoping problems with the opt1 argument and have
 to pass it in explicitly -- I can't remember how things work with optim. 
 
 -- Bert Gunter
 Genentech Non-Clinical Statistics
 South San Francisco, CA
  
 The business of the statistician is to catalyze the scientific learning
 process.  - George E. P. Box
  
  
 
 
-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Guenther, Cameron
Sent: Friday, January 13, 2006 11:03 AM
To: [EMAIL PROTECTED]
Subject: [R] apply

Hello,
I have a dataset d which is
 d
 pop catch 
1   66462.01 10807.757 
2   87486.73 46257.885 
3   57211.64  9345.058 
4   71321.62  4892.868 
5  100024.89 27334.248 
6  104504.91 48535.092 
7   95295.51 39348.195 
8   93737.35 34343.489 
9   89375.05 28750.743 
10  95312.65 30755.064 
11 100888.17 55404.370 
12  84790.23 37751.074 
13  81129.82 29277.443 
14  69797.09 21500.398 
15  61690.34 18199.664 
16  60671.08 19349.051 
17  62852.57 16300.982 
18  90646.32 34793.148 

And a function opt1:

opt1 - function (x) {
  Z - x + M
  c.hat - (x/Z)*pop*(1-exp(-Z))
  y - (catch - c.hat)^2
  return(y)
  }

And define M = 0.25 
For each row I want to return a value F that is a minimization of the
opt1 function

I have tried many variations of:
d$F-apply(d,2,optim(0.3,opt1,method=BFGS)
and even:
For (I in 1:length(pop))apply(d,2,optim(0.3,opt1,method=BFGS))

Every time I get the same error message

Error in optim(0.3, opt1, method = BFGS) : 
objective function in optim evaluates to length 18 not 1

So the apply function is returning 18 values of F which I want but the
function only wants to return 1 value.

Any Suggestions.
Thanks,
Cam

__
R-help@stat.math.ethz.ch 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


Re: [R] Variance-covariance by factor

2006-01-13 Thread Gabor Grothendieck
The cbind should be removed:

sim - data.frame(S = s, D= d, H=h, L=l, W=w)
by(sim[,-1], sim$S, var)

On 1/13/06, Yang, Richard [EMAIL PROTECTED] wrote:

 Dear all,

I have a data frame with one factor and four numeric variables and
 wish to obtain the var-cor matrix separately by factor. I tried by() and
 sapply() but getting nowhere. I understand this can be done by subsetting
 the dataframe, but there should have some sleek ways of doing it.

 Here is a simulated dataframe;

 s - rep(c(A,B,C), c(25,22,18))

 d - c(rnorm(25,14,2.6),rnorm(22,15.2,2.8),rnorm(18,16.4,3.0))
 h - c(rnorm(25,10,1.4),rnorm(22,11.2,1.8),rnorm(18,12.3,2.0))
 l - c(rnorm(25,6.8,1.6), rnorm(22,7.0,1.7),rnorm(18,7.3,1.8))
 w - c(rnorm(25,2.5,0.65),rnorm(22,2.6,0.7),rnorm(18,2.8,0.71))

 sim - data.frame(cbind(S = s, D= d, H=h,L=l,W=w))

  sim.var - sapply(split(sim, sim$S), function(z) var(z))
 Error in var(z) : missing observations in cov/cor
 In addition: Warning message:
 NAs introduced by coercion

  sim.var - by(sim, sim$S, function(z) var(z))
 Error in var(z) : missing observations in cov/cor
 In addition: Warning message:
 NAs introduced by coercion

 Debug() and trac() the function got no further info.

 Because the error suggested missing data, I looked at the data frame and was
 surprised

  str(sim)
 `data.frame':   65 obs. of  5 variables:
  $ S: Factor w/ 3 levels A,B,C: 1 1 1 1 1 1 1 1 1 1 ...
  $ D: Factor w/ 65 levels 10.0860856437045,..: 51 12 21 11 8 15 57 44 19
 60 ...
  $ H: Factor w/ 65 levels 10.0345903489406,..: 17 2 4 52 6 21 29 9 62 10
 ...
  $ L: Factor w/ 65 levels 10.3854663209663,..: 10 6 23 55 60 8 58 65 11 2
 ...
  $ W: Factor w/ 65 levels 0.93902749732563,..: 38 13 33 12 22 39 47 31 36
 53 ...

 Why the data.frame() converts numeric vectors d, h, l, w into factors?

 Any suggestions for 1) how to compute var-cor by factor in a data frame, and
 2) why data.frame converts numeric variables into factors ?

  sessionInfo()
 R version 2.2.0, 2005-10-06, i386-pc-mingw32

 attached base packages:
 [1] methods   stats graphics  grDevices utils datasets
 base

 Thanks,

 Richard  Yang

 Northern Forestry Centre   /Centre de foresterie du Nord
 Canadian Forest Service/Service canadien des forêts
 Natural Resources Canada   /Ressources naturelles Canada
 5320-122 Street/5320, rue 122

 Edmonton Alberta Canada
 T6H 3S5



[[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-help@stat.math.ethz.ch 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 data unit root tests

2006-01-13 Thread Spencer Graves
  If replies to this post will no longer be useful for you, then please 
discregard this comment.  If not, I will start by saying that I could 
not understand enough of your question to respond directly. 
RSiteSearch(panel unit root) led me to an exchange we had following a 
related question you posted last October 
(ttp://finzi.psych.upenn.edu/R/Rhelp02a/archive/63545.html).  Did you 
try the nlme package as suggested there?  I've just now looked at that, 
and I confess I could not figure out how to do it in a few minutes.

  Do you want to perform a unit root test for a particular panel data 
set you have?  Or do you want to develop software for a particular panel 
unit root test?  If the former, I suggest you prepare a very simple toy 
example trying to do something like this using lme with perhaps corAR1, 
then send this list a question on whether it is possible to do what you 
want with lme, asking how to take the next step with the toy example. 
If rather you want to develop software for a particular unit root test, 
then I suggest you at least provide a more complete citation than just 
a la Arellano  Bond.  In either case, I also suggest you review the 
posting guide! www.R-project.org/posting-guide.html and try to make 
your post as easily understood as possible.  In general, I think that 
posts that are clear and succinct tend to get quicker, more useful 
answers.  Maybe I'm just dense, but I don't understand what you are 
asking.  For example, your code includes print(levinlin(ws, year, id, 
lags = 3)).  What is the levinlin function?  RSiteSearch(levinlin) 
produced zero hits.

  hope this helps.
  spencer graves

jukka ruohonen wrote:

 When finally got some time to do some coding, I started and stopped right 
 after. The stationary test is a good starting point because it demonstrates 
 how we should be able to move the very basic R matrices. I have a real-
 world small N data set with 
 
 rows:
 id(n=1)---t1---variable1
 ...
 id=(N=20)---T=21---variable1
 
 Thus, a good test case. For first id I was considering something like this:
 
 lag - as.integer(lags)
 lags.p - lags + 1
 id - unique(group)
 id.l - length(id)
 y.l - length(y)
 yid.l - length(y)/id.l
   if (lag  yid.l -2) 
 stop(\nlag too long for defined cross-sections.\n)
 
 #for (i in id) {
   lagy - y[2:yid.l]
   lagy.em - embed(lagy, lags)
   id.l - length(id)
   dy - diff(y)[1:yid.l-1]
   dy.em - embed(dy, lags)
 # }
 print(levinlin(ws, year, id, lags = 3))
 
 Couldn't figure the loop over units out but with N = 1 the data 
 transformation seemed to work just fine. Now we should pool the new 
 variables within the panel and regress y over yt-1 and dy-t1 ++ dy-t-j 
 with, say, BIC doing the job for d's (H0: y-1 ~ 0) for each in the panel. 
 
 Now the above example puts the right-hand on columns, and if we are dealing 
 with panel models in general, we should store the new variables together 
 with dX's, which should then give clues to IV estimator with e.g. 
 orthogonal deviations, e.g. k - y ~ yt-1 + x + as.factor(id)). So one 
 confusing part is the requirement of some big storage base for different 
 matrices doing the IV business with lags/levels - the amount of instruments 
 can be enormous with possibly calculation problems in a GMM dynamic panel 
 estimator a la Arellano  Bond. Therefore one should code the theoretically 
 relevant instruments beforehand with various transformation matrices. Thus, 
 should I start to study something that can be done with the newly added 
 SparseM package? 
 
 Regards,
 
 Jukka Ruohonen.
 
 __
 R-help@stat.math.ethz.ch 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] Rd file--latex {array} help

2006-01-13 Thread William H. Asquith
I am trying to build the notation for combination as the function 
\code{choose} in a *.Rd file; but it is not working.
To reduce to essence

\deqn{  \left( \begin{array}{c}
r-1   \\
n
 \end{array} \right)
  }

I have double checked the latex logic (without \deqn{}) in LaTexIT on 
MacOSX so it seems fine.
I've read the R-ext.pdf and down some searching in the 
archives--stumped.

R CMD Rd2dvi --pdf

renders something like this

( r-1\n )

Advice?
Thanks.

Wil

__
R-help@stat.math.ethz.ch 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] change lattice panel background color

2006-01-13 Thread Waichler, Scott R

I can't find a way to change just the panel background color in lattice.
I would like NA regions in levelplot() to appear black.  I've tried the
trellis.par.set() stuff, but it it makes the background of the whole
graphic black.

Thanks,
Scott Waichler
Pacific Northwest National Laboratory
scott.waichler _at _ pnl.gov

__
R-help@stat.math.ethz.ch 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] LaTeX slide show (Was: Re: Taking code from packages)

2006-01-13 Thread Henrik Bengtsson
Duncan Murdoch wrote:
 On 1/13/2006 2:04 AM, Ales Ziberna wrote:
 
Hello!

[snip]

 (I'm a little sensitive about dependencies now, since the LaTeX seminar 
 template I've used a few times no longer works.  It depends on too many 
 LaTeX packages, and someone, somewhere has introduced incompatibilities 
 in them.  Seems like I'll be forced to use Powerpoint or Impress.)

Try LaTeX Beamer!  It is the best thing that happend to LaTeX in a long 
time.  Simply beautiful, intuitive and very easy to use, and it's not 
yet another 'seminar' or 'prosper'.   Part of MikTeX now.  See 
http://latex-beamer.sourceforge.net/ for documentation, examples etc.

Cheers

Henrik

 Duncan Murdoch
 

[snip]

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