Re: [R] eMail results out of R

2007-07-13 Thread Stéphane Dray
I did it a long time ago, so I do not remember why I have to use 
exim4... sorry. mail did not work alone.. that is why I use exim4.  
Perhaps a simpler solution exists.

Cheers

(Ted Harding) wrote:
 On 12-Jul-07 16:10:46, Stéphane Dray wrote:
   
 Here is a small function that I used on Debian. It requires exim4 :

 send.mail-function(addr='[EMAIL PROTECTED]',subject='A 
 message from R',
 text=paste(I have finished to work 
 ,Sys.time(),coll=)){
 # send an email
 # it requires the reconfiguration of exim4
 # you have to connect as root and
 # then type dpkg-reconfigure exim4config
 

 I'm a bit puzzled by this. On any Unix/Linux system (unless
 something has changed very recently which I haven't heard about),
 the 'mail' command simply works, for any user (without having
 to become root); does not require exim4 (or any particular version
 of any particular mail agent--so long as something has to be set up
 so that email can be sent at all), and (for the purpose of using
 'mail' from R) does not require exim4 or any other mail agent to
 be re-configured. The email will be sent From: the user who
 is running R.

 In the example I posted just now, I just used 'mail' in R's
 system() command without doing anything special. The mail transfer
 agent in my case is 'sendmail', but it's a standard configuration
 and nothing special has been done.



   
 mail.cmd-paste(mail ,
 -s \,subject,\ ,
 addr,
   EOT \n,
 text,\n,
 EOT,
 sep=,collapse=)
  system(mail.cmd,intern=FALSE)
   }

 Cheers,

 Romain Francois wrote:
 
 Hi,

 There is a paper in the April 2007 issue of R News that might be of
 help 
 here.
 http://##cran mirror##/doc/Rnews/Rnews_2007-1.pdf

 Romain

 Duncan Murdoch wrote:
   
   
 On 7/12/2007 9:52 AM, [EMAIL PROTECTED] wrote:
   
 
 
 Hi everyone,

 I did my homework and read the posting guideline :-)

 I want to eMail the results of a computing automatically. So I get
 the results (the parameters of a garch process) and I want to eMail
 them to another person. How can I do that?
 
   
   
 This will depend on the system you're using.  If the command
 emailit 
 would work from the command line on your system, then

 system(emailit)

 should work from within R.  Writing that command is the hard part, of
 course.

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

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

 
 E-Mail: (Ted Harding) [EMAIL PROTECTED]
 Fax-to-email: +44 (0)870 094 0861
 Date: 12-Jul-07   Time: 18:03:20
 -- 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
 and provide commented, minimal, self-contained, reproducible code.



   


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

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


Re: [R] eMail results out of R

2007-07-12 Thread Stéphane Dray
Here is a small function that I used on Debian. It requires exim4 :

send.mail-function(addr='[EMAIL PROTECTED]',subject='A 
message from R',
text=paste(I have finished to work 
,Sys.time(),coll=)){
# send an email
# it requires the reconfiguration of exim4
# you have to connect as root and
# then type dpkg-reconfigure exim4config
   
mail.cmd-paste(mail ,
-s \,subject,\ ,
addr,
  EOT \n,
text,\n,
EOT,
sep=,collapse=)
 system(mail.cmd,intern=FALSE)
  }

Cheers,

Romain Francois wrote:
 Hi,

 There is a paper in the April 2007 issue of R News that might be of help 
 here.
 http://##cran mirror##/doc/Rnews/Rnews_2007-1.pdf

 Romain

 Duncan Murdoch wrote:
   
 On 7/12/2007 9:52 AM, [EMAIL PROTECTED] wrote:
   
 
 Hi everyone,

 I did my homework and read the posting guideline :-)

 I want to eMail the results of a computing automatically. So I get the 
 results (the parameters of a garch process) and I want to eMail them to 
 another person. How can I do that?
 
   
 This will depend on the system you're using.  If the command emailit 
 would work from the command line on your system, then

 system(emailit)

 should work from within R.  Writing that command is the hard part, of 
 course.

 Duncan Murdoch
   
 


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

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


[R] acf and na.pass

2007-06-29 Thread Stéphane Dray
Hello,
I would like to have some information about acf with missing values.
Let us consider this example:
x=rnorm(100)
x2=x
x2[sample(100,10)]=NA
acf1=acf(x)
acf2=acf(x2,na.action=na.pass)

The computation of the acf is different for the two data sets. Looking 
at the the code reveals that with missing values, the computation of acf 
takes into account the number of pairs of non-NA values (i.e. the number 
of pairs of data that are used to compute the acf, and this number is 
different for each lag). This makes sense for me. Where I have more 
problems, concern the computation of confidence intervall. Here, the 
plot.acf function compute the values using x$n.used, which is equal for 
these two cases to 100. Is there some explanation for this choice ?  I 
would think that the computation of CI would also take into account the 
number of pairs of non-NA values. Is there some references on the topic ?

Thanks in advance,
Sincerely.


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

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


Re: [R] Randomising matrices

2007-04-27 Thread Stéphane Dray
Your solution is not suitable for quite large matrices.

There are several papers on the subject :

e.g. :
@ARTICLE{SD751,
  author = {Gotelli, N.J. and Entsminger, G.L.},
  title = {Swap and fill algorithms in null model analysis:rethinking 
the knight's
tour},
  journal = {Oecologia},
  year = {2001},
  volume = {129},
  pages = {281-291},
  endnotereftype = {Journal Article},
  keywords = {null model},
  pdf = {/home/stephane/Biblio/Articles/SD751.pdf},
  shorttitle = {Swap and fill algorithms in null model 
analysis:rethinking the knight's
tour}
}

There are different algorithms to solve the question but I am really not 
sure that they are implemented in R.

Sincerely,


Finny Kuruvilla wrote:
 Hi Nick,

 This way isn't the most elegant but works well, especially if the
 matrices aren't too large:

 # This function works on 2x2 arrays, randomizing them, but
 # preserving row and column totals
 shuffle_matrix - function(x) {
nrow = dim(x)[1]
ncol = dim(x)[2]
rmargins - apply(x,1,sum)
cmargins - apply(x,2,sum)

while(1) {
  shuffled - array(sample(x,length(x),replace=TRUE),dim=c(nrow,ncol))
  if(all(apply(shuffled,1,sum) == rmargins)) {
if(all(apply(shuffled,2,sum) == cmargins)) {
  break
}
  }
}
shuffled
 }

 Example:

   
 a=array(sample(c(0,1),10,replace=TRUE),dim=c(5,2))
 a
 
   [,1] [,2]
 [1,]01
 [2,]11
 [3,]01
 [4,]01
 [5,]10
   
 shuffle_matrix(a)
 
   [,1] [,2]
 [1,]01
 [2,]11
 [3,]10
 [4,]01
 [5,]01

 Best,
 Finny Kuruvilla

 *
 Finny Kuruvilla, MD, PhD
 Harvard Medical School Fellowship Program in Transfusion Medicine
 Broad Institute of MIT and Harvard
 Homepage: http://www.people.fas.harvard.edu/~kuruvill/home/


 On Fri, 27 Apr 2007, Nick Cutler wrote:

   
 I would like to be able to randomise presence-absence (i.e. binary)
 matrices whilst keeping both the row and column totals constant. Is
 there a function in R that would allow me to do this?

 I'm working with vegetation presence-absence matrices based on field
 observations. The matrices are formatted to have sites as rows and
 species as columns. The presence of a species on a site is indicated
 with a 1 (absence is obviously indicated with a 0).

 I would like to randomise the matrices many times in order to construct
 null models. However, I cannot identify a function in R to do this, and
 the programming looks tricky for someone of my limited skills.

 Can anybody help me out?

 Many thanks,

 Nick Cutler

 Institute of Geography
 School of Geosciences
 University of Edinburgh
 Drummond Street
 Edinburgh EH8 9XP
 United Kingdom

 Tel: 0131 650 2532
 Web: http://www.geos.ed.ac.uk/homes/s0455078

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

 

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


   


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

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


Re: [R] MAFA and DFA for short time series

2007-04-11 Thread Stéphane Dray
Not sure about mafa and brodgar but ade4 has multispati. This performs a 
multivariate analysis which maximizes the product of autocorrelation by 
variance. I have a manuscript submitted to JVS (in revision) where the 
method is presented that I could send;



Chabot Denis wrote:
 Hi,

 recently I heard a talk where MAFA (min/max autocorrelation factor  
 analysis) and DFA (dynamic factor analyses) were used to analyse  
 short time series typical of fisheries data.

 I searched on internet to learn more about these techniques and  
 (hopefully) to learn how to perform them in R.

 The articles I found actually all used a commercial software called  
 Brodgar (www.brodgar.com). Interestingly, the later can link to R for  
 graphical output and some analyses (like GAM) (i.e. Brodgar produces  
 R scripts from choices users make in their GUI and sends them to R).

 I would prefer to do the time series analysis in R. As there is no  
 Mac version of Brodgar, I have even more incentive to do MAFA and DFA  
 in R.

 Does anyone know of a package to do such analyses? Maybe other names  
 are used for these techniques, which would explain why I always end  
 up at Brodgar when searching for MAFA?

 Or maybe someone has written his/her own functions for such analyses  
 and would agree to share them?

 Sincerely,

 Denis Chabot

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


   


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

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


Re: [R] Standardization Range

2007-03-28 Thread Stéphane Dray
Hi sergio,
Sergio Della Franca wrote:
 Dear R-Helpers,


 I want to perform a standardization of a variable with range method.

 i.e.:

  Standardization (range) == (var-min(var))/(max(var)-min(var))


 Do you konw how can i develop this?

   
As you do ... but don't use var which is the name of the function to 
compute variance.

Try something like :

  stdrange - function(x) {(x-min(x))/(max(x)-min(x))}
  var=1:10 # not a good idea, just for fun
  stdrange(var)
 [1] 0.000 0.111 0.222 0.333 0.444 0.556 0.667
 [8] 0.778 0.889 1.000

 Thank you in advance.


 Sergio Della Franca

   [[alternative HTML version deleted]]

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


   


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

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


Re: [R] RDA and trend surface regression

2007-03-01 Thread Stéphane Dray
Dear All,

PCNM and more general MEM can be found in the package spacemakeR
available here (http://biomserv.univ-lyon1.fr/~dray/). As said by Jari,
I do not want to put the package on CRAN. I have no no problems to
include it in another package (vegan or spdep). It has a vignette which
can be interesting for spdep.  However, I have some problems with this
vector approach for selection of variables in multivariate analysis.
spdep has some function to select these eigenvectors in univariate
regression, we have to find some rules for selecting in the multivariate
case. I use AIC for the paper but it is quite sure that it is not
correct (see comments of Jari in the vegan help page).
multispati is a spatially constrained multivariate analysis. I think
that this approach is more clean in a 'statistical sense' but quite
different: we do not have variance but autocorrelation and so negative
eigenvalues in multivariate analysis !

I have see that Roger has send an announce for a spatial-R meeting in
R-Geo List. I am interested to participate to the Bergen session (I love
rain ;-) ). It could be nice to speak about this subject in Bergen.


Cheers,




Jari Oksanen wrote:
 On 27 Feb 2007, at 20:55, Gavin Simpson wrote:

   
 On Tue, 2007-02-27 at 13:13 -0500, Kuhn, Max wrote:
 
 Helene,

 My point was only that RDA may fit a quadratic model for the terms
 specified in your model. The terms that you had specified were already
 higher order polynomials (some cubic). So a QDA classifier with the
 model terms that you specified my be a fifth order polynomial in the
 original data. I don't know the reference you cite or even the
 subject-matter specifics. I'm just a simple cave man (for you SNL 
 fans).
 But I do know that there are more reliable ways to get nonlinear
 classification boundaries than using x^5.
   
 I doubt that Helene is trying to do a classification - unless you
 consider classification to mean that all rows/samples are in different
 groups (i.e. n samples therefore n groups) - which is how RDA
 (Redundancy Analysis) is used in ecology.

 You could take a look at multispati in package ade4 for a different way
 to handle spatial constraints. There is also the principle coordinates
 analysis of neighbour matrices (PCNM) method - not sure this is coded
 anywhere in R yet though. Here are two references that may be useful:

 
 Stéphane Dray has R code for finding PCNM matrices. Google for his 
 name: it's not that common. I also have a copy of his function and can 
 send it if really needed, but it may be better to check Dray's page 
 first. Stéphane Dray says think that not all functions need be in CRAN. 
 May be true, but I think it might help many people.

 There are at least three reasons why not use polynomial constraints in 
 RDA. Max Kuhn mentioned one: polynomials typically flip wildly at 
 margins (or they are unstable in more neutral speech). Second reason is 
 that they are almost impossible to interpret in ordination display. The 
 third reason is that RDA (or CCA) avoid some ordination artefacts 
 (curvature, horseshoe, arc etc.) just because the constraints are 
 linear: allowing them to be curved allows curved solutions. These 
 arguments are not necessarily valid if you only want to have variance 
 partitioning, or if you use polynomial conditions (partial out 
 polynomial effects in Canoco language). In that case it may make sense 
 to use quadratic (or polynomial) constraints or conditions.

 cheers, Jari Oksanen

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


   


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

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


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

2007-01-09 Thread Stéphane Dray
Not sure to really understand 1) . The makefile (available at 
http://cran.r-project.org/doc/contrib/Makefile-rcb) use  wget 
--passive-ftp 
http://www.stats.ox.ac.uk/pub/Rtools/mingw-cross5.tar.bz2;  This version 
seems to be the current, I am correct ? Note that :

[EMAIL PROTECTED]:~/Rdev/CrossCompileBuild$ cross-tools/bin/i586-mingw32-ld -v
GNU ld version 2.16.91 20050827
[EMAIL PROTECTED]:~/Rdev/CrossCompileBuild$ cross-tools/i586-mingw32/bin/ld -v
GNU ld version 2.16.91 20050827


However, I have use R-2.4.1 and everything seems ok.

Thanks.


Prof Brian Ripley wrote:
 There are two problems here:

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

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

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

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

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

 Hello list,

 I would like to cross-compile R packages using R 2.4.0. I am working on
 Linux Debian and cross-compiled (windows binaries) without problems with
 older R version.
 I have used the doc of Yan and Rossini in the contributed section of the
 R documentation (same version of MinGW...).
 When I try to cross-compile R (make R), the procedure stopped and 
 returns :
 
 i586-mingw32-windres  --include-dir ../include -i dllversion.rc -o
 dllversion.o
 i586-mingw32-gcc  -shared -s -mwindows -o R.dll R.def console.o
 dataentry.o dynl oad.o edit.o editor.o embeddedR.o extra.o opt.o pager.o
 preferences.o psignal.o rhome.o rui.o run.o shext.o sys-win32.o system.o
 e_pow.o malloc.o ../main/libmai n.a ../appl/libappl.a
 ../nmath/libnmath.a graphapp/ga.a getline/gl.a ../extra/xd r/libxdr.a
 ../extra/zlib/libz.a ../extra/pcre/libpcre.a ../extra/bzip2/libbz2.a
 ../extra/intl/libintl.a ../extra/trio/libtrio.a dllversion.o -L. -lg2c
 -lRblas - lcomctl32 -lversion
 ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1703):
 undefin ed reference to `__pcre_ucp_findprop'
 ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1740):
 undefin ed reference to `__pcre_ucp_findprop'
 ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1848):
 undefin ed reference to `__pcre_ucp_findprop'
 ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x187f):
 undefin ed reference to `__pcre_ucp_findprop'
 ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1966):
 undefin ed reference to `__pcre_ucp_findprop'
 ../extra/pcre/libpcre.a(pcre_dfa_exec.o):pcre_dfa_exec.c:(.text+0x1f2a):
 more un defined references to `__pcre_ucp_findprop' follow
 collect2: ld returned 1 exit status
 make[4]: *** [R.dll] Erreur 1
 make[3]: *** [../../bin/R.dll] Erreur 2
 make[2]: *** [rbuild] Erreur 2
 make[1]: *** [all] Erreur 2
 make[1]: quittant le répertoire «
 /home/stephane/Rdev/CrossCompileBuild/WinR/R-2 .4.0/src/gnuwin32 »
 
 I have read (http://www.murdoch-sutherland.com/Rtools/) that a bug
 exists for ld version 2.16.91 20050827 and that Prof Ripley produced a
 patched version. It seems that my problem is also related to ld (and I
 have the same version). So I wonder if the same bug could be responsible
 of the error in the cross-compiler.
 Two questions:
 - Are they other people which have the same problem when cross-compiling
 R on Linux
 - Is it possible that the problem is related to ld. If yes, is it
 possible to obtain a patched version ?

 Thanks in advance.
 Sincerely,





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

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


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

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

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

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

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

Thanks in advance.
Sincerely,

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

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


Re: [R] Cummulative Variance in Correspondence Analysis (ADE4)

2006-12-05 Thread Stéphane Dray
Dear Antonio,
if you have questions on the ade4 package, please  send email to adelist 
(http://listes.univ-lyon1.fr/wws/info/adelist).
The total inertia (variance) of CA is equal to the sum of all eigenvalues :

  data(rpjdl)
  rpjdl.coa - dudi.coa(rpjdl$fau, scannf = FALSE, nf = 4)
  sum(rpjdl.coa$eig)
[1] 4.468333

This is equal to the chi2 stat divided by the number of individuals:

  chisq.test(rpjdl$fau)$statistic/sum(rpjdl$fau)
X-squared
 4.468333

One can obtain the inertia associated to i-th axis by dividing the i-th 
eigenvalue by the total inertia. Here are percentages:

  round(rpjdl.coa$eig/sum(rpjdl.coa$eig)*100,2)
 [1] 16.86  6.56  5.13  4.58  3.52  3.39  3.37  3.12  2.87  2.72  2.63  2.56
[13]  2.49  2.43  2.34  2.21  2.09  2.00  1.86  1.76  1.61  1.48  1.45  1.43
[25]  1.38  1.26  1.23  1.15  1.14  1.08  1.07  1.01  0.94  0.92  0.89  0.83
[37]  0.77  0.71  0.65  0.61  0.59  0.49  0.47  0.46  0.38  0.36  0.35  0.32
[49]  0.29  0.19

The cumulative inertia is obtained by :

  round(cumsum(rpjdl.coa$eig)/sum(rpjdl.coa$eig)*100,2)
 [1]  16.86  23.41  28.55  33.13  36.65  40.03  43.41  46.53  49.39  52.11
[11]  54.75  57.31  59.79  62.23  64.57  66.78  68.87  70.87  72.73  74.49
[21]  76.10  77.58  79.02  80.45  81.83  83.09  84.32  85.47  86.61  87.69
[31]  88.76  89.77  90.71  91.63  92.53  93.36  94.13  94.84  95.49  96.10
[41]  96.69  97.19  97.66  98.12  98.49  98.85  99.20  99.52  99.81 100.00

Antonio Punzon wrote:
 Hi all:
 How can I calculate the cumulative variance (or variance for each component)
 in correspondence analysis?
 If were possible in ADE4 package
 Thank you



  -- Antonio Punzón Merino
  O__ Instituto Español de Oceanografía
 c/ /'_ --- Centro Oceanográfico de Santander
  (*) \(*) -- Promontorio de San Martín S/N
 ~~ 39004-Santander; Spain
  PO BOX: 240
  Tlf: +34 942 29 10 60
 Fax: +34 942 27 50 72
 e-mail: [EMAIL PROTECTED]
 web: www.ieo.es www.ieo.es 
 web: www.sap-ieo.wikispaces.com www.sap-ieo.wikispaces.com
 



 La información contenida en este e-mail y sus ficheros adjuntos es totalmente 
 confidencial y no debería ser usado si no fuera usted alguno de los 
 destinatarios. Si ha recibido este e-mail por error, por favor avise al 
 remitente y bórrelo de su buzón o de cualquier otro medio de almacenamiento.  
  This email is confidential and should not be used by anyone who is not the 
 original intended  recipient. If you have received this e-mail in  error 
 please inform the sender and delete it from  your mailbox or any other 
 storage mechanism.
   [[alternative HTML version deleted]]

   
 

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


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

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


Re: [R] Simplifying Sweave graphics

2006-11-10 Thread Stéphane Dray
Hi.
One guy of my team (Thibaut Jombart) wrote a driver to sweave in png 
(see http://tolstoy.newcastle.edu.au/R/devel/06/03/4599.html). The 
driver works very nice and is very useful for plots with many points, 
raster images... I thought that Friedrich Leisch would include it in the 
Sweave distribution, but it is not in the current distribution.
I am sure that you can ask Thibaut (jombart_at_biomserv.univ-lyon1.fr) 
for the function.

Sincerely.

ONKELINX, Thierry wrote:
 Dear all,

  

 I was wondering if it's possible to simplify graphs created with Sweave.
 I'm using in a document several plots with each about 4000 points
 (qqnorm(rnorm(4000))). It looks likes the information of each points is
 maintained in the graph. As a result of that the pdf filesize get's
 quite large (about 4,2 MB for a 23 page document.) Is there a way to
 reduce the complexity of these graphs? Like creating the graphs in a
 bitmap format instead of a vector format?

  

 Thanks,

  

 Thierry

  

 
 

 ir. Thierry Onkelinx

 Instituut voor natuur- en bosonderzoek / Reseach Institute for Nature
 and Forest

 Cel biometrie, methodologie en kwaliteitszorg / Section biometrics,
 methodology and quality assurance

 Gaverstraat 4

 9500 Geraardsbergen

 Belgium

 tel. + 32 54/436 185

 [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] 

 www.inbo.be http://www.inbo.be/  

  

 Do not put your faith in what statistics say until you have carefully
 considered what they do not say.  ~William W. Watt

 A statistical analysis, properly conducted, is a delicate dissection of
 uncertainties, a surgery of suppositions. ~M.J.Moroney

  


   [[alternative HTML version deleted]]

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


   


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

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


Re: [R] PCA with not non-negative definite covariance

2006-07-27 Thread Stéphane Dray
As said by Pierre Bady,
an answer to your question is NIPALS analysis.
PCA is usually obtained by the diagonalization of a variance-covariance 
matrix. But it can also be obtained by an iterative proedure which 
consists in two regressions. NIPLAS is an implementation of this 
iterative procedure and is strictly equivalent to PCA when there is no 
missing values.
The adavantage of NIPALS is that it can be used with missing values. 
However, note that the convergence is not always obtained (it depends of 
the number and distribution of missing values).
You can find a description of the method and the algorithm here:

http://biomserv.univ-lyon1.fr/~dray/articles/SD165.html

Sincerely,


Quin Wills wrote:

My apologies (in response to the last 2 replies). I should write sensibly -
including subject titles that make grammatical sense.

(1) By analogous, I mean that using classical MDS with Euclidian distance is
equivalent to plotting the first k principle components.
(2) Agreed re. distribution assumptions.
(3) Agreed re. the need to use some kind of imputation for calculating
distances. I'm thinking pairwise exclusion for correlation.

Re. why I want to do this is simply for graphically representing my data.

Quin



-Original Message-
From: Berton Gunter [mailto:[EMAIL PROTECTED] 
Sent: 26 July 2006 05:10 PM
To: 'Quin Wills'; [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Subject: RE: [R] PCA with not non-negative definite covariance

Not sure what completely analagous means; mds is nonlinear, PCA is linear.

In any case, the bottom line is that if you have high dimensional data with
many missing values, you cannot know what the multivariate distribution
looks like -- and you need a **lot** of data with many variables to usefully
characterize it anyway. So you must either make some assumptions about what
the distribution could be (including imputation methodology) or use any of
the many exploratory techniques available to learn what you can.
Thermodynamics holds -- you can't get something for nothing (you can't fool
Mother Nature).

-- 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 Quin Wills
Sent: Wednesday, July 26, 2006 8:44 AM
To: [EMAIL PROTECTED]
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] PCA with not non-negative definite covariance

Thanks.

I suppose that another option could be just to use classical
multi-dimensional scaling. By my understanding this is (if based on
Euclidian measure) completely analogous to PCA, and because it's based
explicitly on distances, I could easily exclude the variables 
with NA's on a
pairwise basis when calculating the distances.

Quin

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: 25 July 2006 09:24 AM
To: Quin Wills
Cc: r-help@stat.math.ethz.ch
Subject: Re: [R] PCA with not non-negative definite covariance

Hi , hi all,



Am I correct to understand from the previous discussions on 
  

this topic (a


few years back) that if I have a matrix with missing values 
  

my PCA options


seem dismal if:
(1) I don’t want to impute the missing values.
(2) I don’t want to completely remove cases with missing values.
(3) I do cov() with use=”pairwise.complete.obs”, as 
  

this produces


negative eigenvalues (which it has in my case!).
  

(4) Maybe you can use the Non-linear Iterative Partial Least Squares
(NIPALS)
algorithm (intensively used in chemometry). S. Dray proposes 
a version of
this
procedure at http://pbil.univ-lyon1.fr/R/additifs.html.


Hope this help :)


Pierre



--

Ce message a été envoyé depuis le webmail IMP (Internet 
Messaging Program)

-- 
No virus found in this incoming message.


 

--

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




  



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

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


Re: [R] mca id numbers

2006-05-04 Thread Stéphane Dray
Please send your emails related to ade4 to the ade4 list and not to 
RHelp (see mailing list address in):

packageDescription(ade4)

a solution to your problem:

  scatter.dudi(dat.acm,clab.row=0)
  scatter.dudi(dat.acm,clab.col=0)


Carlos Mauricio Cardeal Mendes wrote:

Is it possible to make disappear the id numbers from scatter.dudi (mc 
analysis)  ?

a - as.factor(c(1, 2, 3, 2, 1))
b - as.factor(c(3, 2, 3, 1, 1))
x - as.factor(c(1, 2, 2, 1, 3))
y - as.factor(c(2, 2, 3, 1, 1))

dat - data.frame(a=a, b=b,x=x,y=y)
summary(dat)
dat
require(ade4)
dat.acm - dudi.acm(dat, scann = FALSE, nf = 2)
scatter.dudi(dat.acm)

Thank you very much !
Mauricio

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


  



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

__
R-help@stat.math.ethz.ch 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] Contingency table and zeros

2006-03-06 Thread Stéphane Dray
something like:

 cumsum(table(factor(myvector,levels=1:5)))

will do the job.


Nicolas Perot wrote:

Hello,

Let's assume I have a vector of integers :
  myvector -  c(1, 2, 3, 2, 1, 3, 5)

My purpose is to obtain the cumulative distribution of these numerical 
data, i.e. something like :

value  nb_occur.
=12
=24
=36
=46
=57

For this, I create a table with ;
  mytable - table(myvector)

1 2 3 5
2 2 2 1

However, table() returns an array of integers, mytable[4] returns the 
occurence number of the 5 item, which makes this table hard to index.
I would prefer to have a data structure where mytable[4] could return 0, 
as there is no 4 in my vector.

table() may not be the proper way to do it.

For the moment, I use a loop which scans the vector from its lowest 
value to its highest, and counts the number of times each value appears.

Is there a built-in function, or a table() option to do such a task ?

Thanks.

Regards,
Nicolas

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


  



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

__
R-help@stat.math.ethz.ch 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] A 'sweave' strange problem !!!

2005-11-11 Thread Stéphane Dray
Hello list,
I have found a problem (bug?) with Sweave. I hope that someone could 
help me.
Try this little example :
\documentclass[a4paper]{article}

\title{toto}
\author{toto}

\begin{document}

\maketitle



ni1, fig=T, eval=TRUE, echo=TRUE, debug=TRUE, results=verbatim, 
include =FALSE, width=7, height=7=
a-rnorm(1)+1
a
plot(1:10)
@
patati


ni2, fig=F, eval=TRUE, echo=TRUE, debug=TRUE, results=verbatim, 
include =FALSE, width=7, height=7=
a
@
\end{document}

The value of 'a' has change between the two Schunks. It seems that the 
problem only appear when there are plot (fig=T) in the first one. 
Without plot, there are no problems: a remains unchanged. Is it a bug or 
have I misundertsood something ?

Thanks a lot !
R version 2.1.0 (Debian).

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

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

2005-10-26 Thread Stéphane Dray
Hello list,
I would like to know if it is possible to get output of help(foo) with 
Sweave.
If I insert ?foo in a chunk, the console give me the help but no output 
is obtained in the tex file.
Perhaps something to do with options ?

Thanks in advance !

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

__
R-help@stat.math.ethz.ch 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] Pb with function taxo2phylog (package ade4)

2005-10-24 Thread Stéphane Dray
Christophe,
please send emails related to this package to the ade4 list :

http://pbil.univ-lyon1.fr/ADE-4/adelist.html

Merci.

Christophe Girod wrote:

Hello

  I'm using the package ade4 to obtain classification from a .txt file. I 
use the following commands:
cronquist - read.table(cronquist.txt, h = T, row.names = 8)
cronquist - as.taxo(cronquist[7:1])
cro.phy - taxo2phylog(cronquist)

in which cronquist.txt is a file with a classification of 218 genus of tree 
species from french Guiana.
We I try to use the function taxo2phylog, I obtain the following error 
message (in French) :
Erreur dans newick2phylog.addtools(res) : la longueur de 'dimnames' [2] 
n'est pas égale à l'étendue du tableau
Error in newick2phylog.addtools(res) : length of dimnames[2] is not equal to 
length of frame

newick2phylog.addtools is a function that is called when taxo2phylog is 
called

when I want to know what is in dimnames[2] I obtain the names of my columns 
: none is missing.

I don't understand what's happening because I've already been using this 
function with other files and I  had no problem
Can someone help me?

Thanks

Christophe Girod

_
Apprenez à lutter contre le spam !

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


  



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

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

2005-10-17 Thread Stéphane Dray
Please,
send your question to the ade4 list. Be more precise on your problem.

http://pbil.univ-lyon1.fr/ADE-4/adelist.html

Miguel Ribeiro wrote:

Hi, i'm having trouble using Statis in ADE4 package.
I want to study a matrix with 18x414...could any body help me?!?!'

Urgent

Thanks

Miguel Ribeiro
Portugal
   [[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


  



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

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

2005-10-11 Thread Stéphane Dray
Hello list,

I am writing a paper for Rnews. I use Sweave to do it. I did not find 
information about writing a paper for Rnews using Sweave and have some 
questions:
- Is there a problem to use the environment 'Sinput' in the place of 
'example' or 'smallexample'. It works fine but perhaps there are some 
technical/editorial problems ?
- I have some long lines of code in schunk. I did not find any way to 
cut them in the Rnw file and they appear out of the column in the dvi 
file. The only solution I found is to cut these lines in the tex file 
generated by Sweave. Is there a more elegant and automatic solution to 
this problem?

Thanks in advance.

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

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

2005-07-20 Thread Stéphane Dray
apply transorm your data.frame into a matrix which can contains only one 
type of values (character or numeric or logical).
data.frame are list, so they can contain various kind of data, and a 
solution to your problem is given by lapply:

  b=lapply(df, function(r) print(class(r['a'])))
[1] numeric
[1] factor

Numeric data that is part of a mixed type data frame is converted into
character. How can I tell apply to maintain the original class of a
column and not convert it into character. I would like to do this of
the vector and not inside the apply function individually over each
element. Consider the following two scenarios, in the second column
'a' maintained its class while it lost its numeric type in the first
case.

  

df = data.frame(a=c(1,2), b=c('A','B'))
df


  a b
1 1 A
2 2 B
  

a=apply(df, 1, function(r) print(class(r['a'])))


[1] character
[1] character
  

a=apply(df, 1, function(r) print(class(r['b'])))


[1] character
[1] character


  

df = data.frame(a=c(1,2))
df


  a
1 1
2 2
  

a=apply(df, 1, function(r) print(class(r['a'])))


[1] numeric
[1] numeric

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


  



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

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