Re: [R] R logo

2008-07-16 Thread Christophe Genolini



If we knew an elegant one, we'd have an R function to do it ...

The R Logo was done "manually" (using software) in several
phases IIRC.
But yes, indeed, an 'Rfont' package on CRAN would be neat...

Martin Maechler, ETH Zurich and R Core Team.

  
I am not sur of what would be neat : a police with nice letter that have 
a border ?
I do not know how to change a drawing in a police, but making the 
drawing of the police is not that hard
(well I know that I am the one who ask, but it was only to avoid to work 
on Gimp again, because I did
not for a long time and I thaught that I forget almost every thing... I 
was wrong)


With Gimp (which is the free version of photoshop) :

http://christophe.genolini.free.fr/kml/images/alphaRouge.jpg
http://christophe.genolini.free.fr/kml/images/alphaBleu.jpg
http://christophe.genolini.free.fr/kml/images/alphaVert.jpg
http://christophe.genolini.free.fr/kml/images/alphaBlanc.jpg

Christophe

__
R-help@r-project.org 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] probleme with R CMD check

2008-07-18 Thread Christophe Genolini

Hi the list,

Back on an old problem. I thaught that was ok, but it is still not 
working on my computer.
I write a toy package called packClassic. R CMD build packClassic works 
fine.

When I run R CMD CHECK packClassic, I get

--- 8< ---
* checking for unstated dependencies in R code ... WARNING
Erreur dans .find.package(package, lib.loc) :
 aucun package nommé 'packClassic' n'existe
--- 8< ---

I gess that my configuration is correct since on an other package (a 
real one), I get no problem.
The program is called "progClassic.R". Obviouly, is in a directorie 
called \packClassic\R\

The doc are in man, a data base is in data and some test are in tests

Here are the codes, the DESCRIPTION and NAMESPACE, then the file 
00install.out and 00check.log :

I also put the package (since R CMD build works fine) on
 http:\\christophe.genolini.free.fr/packClassic_1.0.tar.gz
 http:\\christophe.genolini.free.fr/packClassic_1.0.zip

Does someone know what is wrong ?

Christophe



 8< - packClassic.R 
##
###  ProgClassic.R ###
##

userA  <- function(x){x+1}
privateA   <- function(x){x+2}
.userB <- function(x){x+10}
.privateB  <- function(x){x+20}
userC  <- function(x){userA(privateA(x))}
privateC   <- function(x){.userB(.privateB(x))}


--- 8< -- testsPackClassic.R
##
### Nom du programme : testClassique.R ###
##

load("../data/dn.Rda")
source("../R/progClassic.R")

userA(1)
privsateA(2)
.userB(3)
.privateB(4)
userC(5)
privateC(6)


--- 8<  dn.Rda --
dn <- data.frame(age=c(1,2,4,8,12))
save(dn,file=dn.Rda")


---  8< --- DESCRIPTION -
Package:packClassic
Type: Package
Title: A (Not So) Short Introduction To S4
Version: 1.0
Date: 2008-07-16
Author: Christophe Genolini
Maintainer: <[EMAIL PROTECTED]>
Description: This package is a toy example used to illustrate the 
tutorial A (Not So) Short Introduction to S4.

License: GPL (>=2)
LazyLoad: ys


--- 8< --- NAMESPACE --
export("userA",
  ".userB",
  "userC"
)


--- 8<  man 
dn.Rd
packClassic-internal.Rd
packClassic-package.Rd
userAC.Rd



--- 8< - 00install.out --
installing R.css in 
C:/DOCUME~1/CHRIST~1/MESDOC~1/DOCSAR~1/R/TUTORI~1/PACKCL~1.RCH



-- Making package packClassic 
 adding build stamp to DESCRIPTION
 installing NAMESPACE file and metadata
 installing R files
 installing data files
 installing man source files
 installing indices
 not zipping data
 installing help
>>> Building/Updating help pages for package 'packClassic'
Formats: text html latex example chm
 dntexthtmllatex   example
 packClassic-internal  texthtmllatex
 packClassic-package   texthtmllatex   example
 userACtexthtmllatex   example
 adding MD5 sums

* DONE (packClassic)



--- 8< - 00check.log --
* using log directory 'C:/Documents and Settings/Christophe/Mes 
documents/Docs articles polys résumés/R/tutorial S4/packClassic.Rcheck'

* using R version 2.7.1 (2008-06-23)
* using session charset: ISO8859-1
* checking for file 'packClassic/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'packClassic' version '1.0'
* checking package name space information ... OK
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking whether package 'packClassic' can be installed ... OK
* checking package directory ... OK
* checking for portable file names ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking index information ... OK
* checking package subdirectories ... WARNING
Subdirectory 'data' contains no data sets.
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking whether the name space can be loaded with stated dependencies 
... OK

* checking for unstated dependencies in R code ... WARNING
Erreur dans .find.package(package, lib.loc) :
 aucun package nommé 'packClassic' n'existe
Calls:  -> .find.package
Exécution arrêtée
See the information on DESCRIPTION files in the chapter 'Creating R
packages' of the 'Writing R Extensions' manual.
*

[R] Sweave add code \201

2008-07-19 Thread Christophe Genolini

Hi the list,

I do not understand what change in my configuration, but Sweave add the 
code \201 before each special characters é è à ç ...

Does someone know when it come from ?

Thanks

Christophe

__
R-help@r-project.org 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] Sweave add code \201

2008-07-20 Thread Christophe Genolini

Peter Dalgaard a écrit :

Christophe Genolini wrote:

Hi the list,

I do not understand what change in my configuration, but Sweave add 
the code \201 before each special characters é è à ç ...

Does someone know when it come from ?

MULE  (multilingal environment) in Emacs used to be prone to do this, 
but I haven't seen it for a while, so I'm afraid I have forgotten the 
details (if I ever understood them).


Thanks ! I thaught I had a it was Sweave and thanks to you I start to 
search in emacs.


Christophe

__
R-help@r-project.org 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] path and R CMD check

2008-07-23 Thread Christophe Genolini

Hi the list,

When I developpe my code, I put the file that define all the functions 
in ./MyPack/R/prog.R and the tests in ./MyPack/tests/testsProg.R

The test files start by

load("../data/myData.rda")
source("../R/prog.R")
#test function number one...

But "R CMD check MyPack" does not find the file myData.rda.
Does someone knows what is wrong ?

Christophe

__
R-help@r-project.org 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] path and R CMD check

2008-07-25 Thread Christophe Genolini



Uwe Ligges-3 wrote:
> 
> 
> 
> Christophe Genolini wrote:
>> Hi the list,
>> 
>> When I developpe my code, I put the file that define all the functions 
>> in ./MyPack/R/prog.R and the tests in ./MyPack/tests/testsProg.R
>> The test files start by
>> 
>> load("../data/myData.rda")
>> source("../R/prog.R")
>> #test function number one...
>> 
>> But "R CMD check MyPack" does not find the file myData.rda.
>> Does someone knows what is wrong ?
> 
> 
> Read Writing R Extensions, learn how a package works (and yes, it works 
> without sourcing files separately since the package mechanism does the 
> job for you) and just say:
> 
> library("packagename")
> data("myData")
> 
> Best wishes,
> Uwe Ligges
> 
> 
I try but I find it very hard. Do you have more precision about the part
that explain it ? I read it several time, but I did not find that much on
tests.

So I do it on my own way. But I would love to know more about the way used
by real programmer. 

So far :
 - I am writing my code in several files /myPack/R/progA.R and
/myPack/R/progB.R
 - I am writing tests in /myPack/tests/testsProgA.R and
/myPack/tests/testsProgB.R
 - I am writing a main program in /myPack/main.R. This main program is
calling the tests.
 - Since the progB.R is an extension of progA.R, the testsB.R use some data
define in testsA.R

Before today, I was starting by
> load("../data/myData.rda")
> source("../R/prog.R")

But you tell me to do :
> library("myPack")
> data("myData")

Using this system is problematic during the development phase, since the
package is not ready and library(myPack) will not work

Any advice for a better way of working ?

Christophe
-- 
View this message in context: 
http://www.nabble.com/path-and-R-CMD-check-tp18622300p18650854.html
Sent from the R help mailing list archive at Nabble.com.

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


[R] [R-pkgs] KmL 1.1.1

2010-03-04 Thread Christophe Genolini
‘kml’ is an implementation of k-means for longitudinal data (or 
trajectories). This algorithm is able to deal with missing value
and provides an easy way to re roll the algorithm several times, varying 
the starting conditions and/or the number of clusters looked for.


KmL 1.1.1 addition:
- 7 imputations methods for longitudinal data
- Calculus of three qualities criterion (Calinski&Harabatz, Ray&Turi, 
Davies&Bouldin)

- Implementation of the Frechet distance between two trajectories
- Calculus of the Frechet path
- Optimization of the function 'dist' for trajectories
- Possibility to use three different ways to define the starting conditions
- Correction of minor bugs


Christophe Genolini

___
R-packages mailing list
r-packa...@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org 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] Dealing with an argument missing in ...

2010-03-10 Thread Christophe Genolini

Hi the list

I define a S3 function that can have a various number of argument using 
'...'
When some arguments are missing, I would like to give them some default 
value:


func.numeric <- function(x,...){
  if(missing(y)){y<-3}
}

But it does not works...

I precise that I can not put 'y' explicitly in the argument list since 
func is an S3 function, I cannot change its arguments.

Any suggestions?

Thanks
Christophe

__
R-help@r-project.org 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] aggregate without removing empty subset

2010-03-15 Thread Christophe Genolini

Hi the list,

As it is say in its doc, the aggregate function remove empty subsets. Is 
it possible to NOT remove empty subset ?

--- 8< ---
m <- matrix(1:12,4)
part <- factor(c("A","B","A","B"),levels=c("A","B","C"))
aggregate(m,list(part),mean)

### I get:
#   Group.1 V1 V2 V3
# 1   A  2  6 10
# 2   B  3  7 11
#
### I would like:
#   Group.1 V1 V2 V3
# 1   A  2  6 10
# 2   B  3  7 11
# 3   C NA NA NA
--- 8< --


Thanks
Christophe

__
R-help@r-project.org 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] aggregate without removing empty subset

2010-03-16 Thread Christophe Genolini
As I told you in private, thanks, it works perfectly.

More precisely, I am working with 3D array. Your code works well (both 
on matrix or on array).
But when part is a factor with only one value, the result has not a 
correct dimension (vector if m is a matrix, a matrix if m is an array).
Any way to fix that ?

m1 <- matrix(1:12,4)
m2 <- array(1:24,dim=c(4,3,2))
part1 <- factor(c("A","B","A","B"),levels=c("A","B","C"))
part2 <- factor(c("A","A","A","A"),levels=c("A"))


apply(m1, 2, tapply, part1, mean) ##Perfect (dim=c(3,3))
apply(m1, 2, tapply, part2, mean) ## dim=NULL...

apply(m2, c(2,3), tapply, part1, mean) ## Perfect (dim=c(3,3,2))
apply(m2, c(2,3), tapply, part2, mean) ## dim=c(3,2)


Christophe

> Try this:
>
> apply(m, 2, tapply, part, mean)
>
> On Mon, Mar 15, 2010 at 2:10 PM, Christophe Genolini
>  wrote:
>   
>> Hi the list,
>>
>> As it is say in its doc, the aggregate function remove empty subsets. Is it
>> possible to NOT remove empty subset ?
>> --- 8< ---
>> m <- matrix(1:12,4)
>> part <- factor(c("A","B","A","B"),levels=c("A","B","C"))
>> aggregate(m,list(part),mean)
>>
>> ### I get:
>> #   Group.1 V1 V2 V3
>> # 1   A  2  6 10
>> # 2   B  3  7 11
>> #
>> ### I would like:
>> #   Group.1 V1 V2 V3
>> # 1   A  2  6 10
>> # 2   B  3  7 11
>> # 3   C NA NA NA
>> --- 8< --
>>
>>
>> Thanks
>> Christophe
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>> 
>
>
>
>   


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] S4: Multiple inheritance

2010-03-23 Thread Christophe Genolini

Hi all,

Working with S4 object, I definine two class foo1 and foo2. I define '[' 
(resp. '[<-') for the two classes.

Then I define a third class foo3 that inherit from both foo1 and foo2.
Is there a way to make '[' (resp. '[<-') for foo3 inherit from '[' 
(resp. '[<-')  for foo1 and foo2?


Thanks
Christophe

__
R-help@r-project.org 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] Drawing a line with misc3d

2010-04-19 Thread Christophe Genolini

Hi the list,

I would like to draw some lines with misc3d. I find a lot of tools to 
draw surfaces, but nothing for simple line... Is it possible?
Note that I know that it is possible to draw lines with rgl (using 
lines3d), but I need to do it with misc3d to export the drawing in .asy 
format.

Any solution?

Christophe

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


Re: [R] Exporting an rgl graph

2010-04-20 Thread Christophe Genolini

Thanks a lot
Both Asymptote and  MeshLab work fine. Thanks for this article, Luke.
On my particular case, I need to export lines (1D object in a 3D space) 
and not surfaces (2D objects). Is it possible to draw lines with misc3d ?


Christophe Genolini

Luke Tierney a écrit :

  The current issue of JCGS (Vol 18 No 1,
http://pubs.amstat.org/toc/jcgs/19/1) has an editorial on including
animations, 3D visualizations, and movies in on-line PDF files
supporting JCGS articles. The online supplements to the editorial
include examples.  The 3D examples related to the misc3d packages are
also available in
http://www.stat.uiowa.edu/~luke/R/misc3d/misc3d-pdf/ 
<http://www.stat.uiowa.edu/%7Eluke/R/misc3d/misc3d-pdf/>.  At some point

the code there will be added to misc3d.  It should be possible to
adapt these ideas to other objects rendered with rgl.

luke


__
R-help@r-project.org 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] savePlot for Mac and / or Linux?

2009-12-07 Thread Christophe Genolini

Hi all,

In the package rtlu, I use the function savePlot. It is convenient since 
it let the user decide in which graphic format he wants his graph to be 
export.

But when I run R CMD check, I get the following message :

 rtlu(V1,fileOutput="First.tex",textBefore="\\section{Variable 1 to 

3}",graphName="V1")
Error in savePlot(filename = nomBarplot, type = type) : can only copy 
from 'windows' devices

Calls: rtlu ... r2lUniv -> r2lUniv.factor -> r2lBarplot -> savePlot
Execution halted

I guess this is a compatibility problem with Linux/Mac? Is there 
something close to savePlot for Mac / Linux?


Christophe

__
R-help@r-project.org 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] "time series", "longitudinal data" or "trajectories"

2009-06-05 Thread Christophe Genolini

Hi the list

Strictly speaking, this is not a "R" question, but I need the 
information for the
creation of a package. My question is about vocabulary: What is the 
difference between

"time series", "longitudinal data" and "trajectories"?

Sincerely

Christophe

__
R-help@r-project.org 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] "time series", "longitudinal data" or "trajectories"

2009-06-06 Thread Christophe Genolini

Thanks for yours answers. So if I understand:
- Trajectories are continuous, the other are discrete.
- The difference between time series and longitudinal is that time 
series are made at regular time whereas longitudinal are not ?

- Repeated measures are over a short period of time.


So if I measure the  weight of my patient daily during one week, it will 
be repeated measure ; if I measure it once a week during one year,
it will time series ; if I measure it once a week during one year but 
with some "missing week", it will longitudinal data ? 


Well I guess it is not as simple at that, but is it the idea ?

Christophe



At 04:02 PM 6/5/2009, Christophe Genolini wrote:

Hi the list

Strictly speaking, this is not a "R" question, but I need the 
information for the
creation of a package. My question is about vocabulary: What is the 
difference between

"time series", "longitudinal data" and "trajectories"?

Sincerely

Christophe


"Longitudinal" data are measurements over long periods of time, often 
at irregular periods, but consistent across subjects.


"Repeated measures" data are replicates at the same point in time, or 
over a short period of time (e.g., laboratory experiments).


"Time series" typically have constant increments of time and typically 
a stochastic character, although this term might be considered 
all-encompassing for all measurements at different times.


"Trajectory" implies a continuous curve in time, as opposed to 
discrete times. "Trajectory" also implies an underlying causal model, 
as it is a term from kinematics.


I hope this helps.


Robert A. LaBudde, PhD, PAS, Dpl. ACAFS  e-mail: r...@lcfltd.com
Least Cost Formulations, Ltd.URL: http://lcfltd.com/
824 Timberlake Drive Tel: 757-467-0954
Virginia Beach, VA 23464-3239Fax: 757-467-2947

"Vere scire est per causas scire"





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


[R] "R CMD check" does not find a mistake

2009-06-09 Thread Christophe Genolini

Hi the list,

I build a package. They was a mistake in it, but R CMD check did not 
find it. Is that normal ?


Here is what Kurt gets (which is right, I did this mistake):

--- 8< 
* checking for code/documentation mismatches ... WARNING
S4 class codoc mismatches from documentation object 'LongData-class':
Slots for class 'LongData'
 Code: id other time traj varName
 Docs: id time traj varName
--- 8< 

But here is what I get :

--- 8< 
R CMD check longitudinalData
* checking for working pdflatex ... OK
* using log directory 'C:/Documents and Settings/Christophe/Mes 
documents/Recher

che/Trajectoires/kmeal/longitudinalData.Rcheck'
* using R version 2.9.0 beta (2009-04-04 r48290)
* using session charset: ISO8859-1
* checking for file 'longitudinalData/DESCRIPTION' ... OK
* checking extension type ... Package
* this is package 'longitudinalData' version '0.5'
* package encoding: latin1
* checking package dependencies ... OK
* checking if this is a source package ... OK
* checking for .dll and .exe files ... OK
* checking whether package 'longitudinalData' can be installed ... OK
* checking package directory ... OK
* checking for portable file names ... OK
* checking DESCRIPTION meta-information ... OK
* checking top-level files ... OK
* checking index information ... OK
* checking package subdirectories ... OK
* checking R files for non-ASCII characters ... OK
* checking R files for syntax errors ... OK
* checking whether the package can be loaded ... OK
* checking whether the package can be loaded with stated dependencies ... OK
* checking for unstated dependencies in R code ... OK
* checking S3 generic/method consistency ... OK
* checking replacement functions ... OK
* checking foreign function calls ... OK
* checking R code for possible problems ... OK
* checking Rd files ... OK
* checking Rd files against version 2 parser ... OK
* checking Rd cross-references ... OK
* checking for missing documentation entries ... OK
* checking for code/documentation mismatches ... OK
* checking Rd \usage sections ... OK
* checking examples ... OK
* checking PDF version of manual ... OK


R CMD build longitudinalData
* checking for file 'longitudinalData/DESCRIPTION' ... OK
* preparing 'longitudinalData':
* checking DESCRIPTION meta-information ... OK
* removing junk files
* checking for LF line-endings in source and make files
* checking for empty or unneeded directories
* building 'longitudinalData_0.5.tar.gz'
--- 8< 

Christophe

__
R-help@r-project.org 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] Sending a function as an argument to C code.

2009-06-12 Thread Christophe Genolini

Hi the list,

I am writing a function (myFunc) that is using an other function (let 
say distance).


+++
dist1 <- function(x,y)dist(rbind(x,y))
dist2 <- function(x,y)y2

myFunc <- function(x,distance){
 cat("...\n")
 cat(distance(1,x))
}
myFunc(x=3,distance=dist1)
myFunc(x=3,distance=dist2)


In order to optimize the code, I would like to write myFunc in C. Is it 
possible, in the C code, to call a function define in R (dist1 or dist2) 
that will be send to myFunc as an argument ?


Christophe

__
R-help@r-project.org 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] Crash caused by a call to a C function

2009-06-18 Thread Christophe Genolini

Hi the list

I write a function MyFunc. To optimize it, I write a C function MyFuncC 
then a function MyFunc2 that call .C(“MyFuncC”,….)
The two functions MyFunc and MyFunc2 seem to behave exactly the same way 
(they give the same results). But when I test MyFunc2 several times 
(around 20), R crash. This is not link to a specific example since if I 
test MyFunc2 on the same example several time, I still get a crash.
Any idea of what can cause this kind of error (or even how can I 
diagnose the problem)? And how I can correct it?


Sincerely
Christophe

__
R-help@r-project.org 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] Sweave: Changing the background color, adding a border

2009-04-19 Thread Christophe Genolini

Hi all,

I am using Sweave to produce a document. Unfortunately, I have to print 
several copies and I can't print them in color. So I would like to 
change the way of printing the code. I would like to print the code in a 
box with a black borderline and a grey background (quite classic). Is it 
possible to do it by changing some Schunk options?


Christophe

__
R-help@r-project.org 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] Sweave: Changing the background color, adding a border

2009-04-19 Thread Christophe Genolini

Duncan Murdoch a écrit :

On 19/04/2009 6:03 AM, Christophe Genolini wrote:

Hi all,

I am using Sweave to produce a document. Unfortunately, I have to 
print several copies and I can't print them in color. So I would like 
to change the way of printing the code. I would like to print the 
code in a box with a black borderline and a grey background (quite 
classic). Is it possible to do it by changing some Schunk options?


It should be, if you know how to print things like that, but I don't 
Here's some code I wrote a while ago to modify the Sweave formats in a 
much simpler way:


% This removes the extra spacing after code and output chunks in Sweave,
% but keeps the spacing around the whole block.

\fvset{listparameters={\setlength{\topsep}{0pt}}}
\renewenvironment{Schunk}{\vspace{\topsep}}{\vspace{\topsep}}
% We want to avoid having examples switch us to an italic font shape.
\DefineVerbatimEnvironment{Soutput}{Verbatim}{fontshape=n}


Hi Duncan, hi Romain

Thanks for your answer. I finally succeed.
I used the listings package to define an environment that put code in a 
grey box. The command is \lstnewenvironment{Sinput}[1][]{


Then I change the Schunk, Sinput and Soutput environment.
- For the Schunk, I use \renewenvironment as Duncan suggest.
- For Sinput, I would like to use something like \lstREnewenvironment 
but it does not exist.
So I comment the line \usepackage{Sweave}, I copy the contain of file of 
Sweave.sty in the .Rwn file and I remove the definition of Sinput and 
Soutput.
Note: The line %\usepackage{Sweave} is necessary, otherwise the R 
command 'Sweave()' add the line \package{Sweave}in the LaTeX file.


--- 8< --
The final file is :
%\usepackage{Sweave}
\RequirePackage[T1]{fontenc}
\RequirePackage{graphicx,ae,fancyvrb}
\IfFileExists{upquote.sty}{\RequirePackage{upquote}}{}
\setkeys{Gin}{width=0.8\textwidth}

%\DefineVerbatimEnvironment{Sinput}{}{}
%\DefineVerbatimEnvironment{Soutput}{}{}
\DefineVerbatimEnvironment{Scode}{Verbatim}{fontshape=sl}

\newenvironment{Schunk}{}{}

\usepackage{listings}

\definecolor{gris90}{gray}{0.90}

\lstloadlanguages{R}

\lstnewenvironment{Sinput}[1][]{
 \lstset{%
   language={R},
   basicstyle=\small,% print whole listing small
   keywordstyle=\color{black}\bfseries,  % style for keyword
   emph={in},% define a list of word to 
emphasis

   emphstyle=\color{black}\bfseries, % define the way to emphase
   % emph={[2]out},% define a second list 
of word to emphasis
   % emphstyle=[2]\color{red}\bfseries,% define the way to 
emphase the list 2

   frame=single, % box arround the code
   backgroundcolor=\color{gris90},   % background color
   % commentstyle=\color{gris10},  % define the style of 
the comments
   showspaces=false, % show the space in code, 
or not
   stringstyle=\ttfamily,% style of the string 
(like "hello word")
   showstringspaces=false,   % show the space in 
string, on not

   #1
 }
}{}
\lstnewenvironment{Soutput}[1][]{
 \lstset{%
   language={R},
   basicstyle=\small,% print whole listing small
   keywordstyle=\color{black}\bfseries,  % style for keyword
   emph={in},% define a list of word to 
emphasis

   emphstyle=\color{black}\bfseries, % define the way to emphase
   % emph={[2]out},% define a second list 
of word to emphasis
   % emphstyle=[2]\color{red}\bfseries,% define the way to 
emphase the list 2

   frame=single, % box arround the code
   backgroundcolor=\color{gris90},   % background color
   % commentstyle=\color{gris10},  % define the style of 
the comments
   showspaces=false, % show the space in code, 
or not
   stringstyle=\ttfamily,% style of the string 
(like "hello word")
   showstringspaces=false,   % show the space in 
string, on not

   #1
 }
}{}

--- 8< --


Christophe

__
R-help@r-project.org 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] Bug: more information on a crash

2010-01-08 Thread Christophe Genolini

Hi the list,

In the package KmL (new version, not release yet), the main function 
seems to work correctly but once in a while, R crash (full crash, 
anything link with R is closed and windows ask if it can send a crash 
report). More precisely, when I run it in a loop on 1000 data sets, the 
crash is certain... Is there a way to get more information on what cause 
this?


Christophe

__
R-help@r-project.org 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] Number of download.

2010-01-19 Thread Christophe Genolini

Hi the list

Is there a way to know how many times an R package (on CRAN) has been 
download ?


Christophe

__
R-help@r-project.org 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] Optimizing C code

2010-01-22 Thread Christophe Genolini

Hi the list,

I need to write some efficient distances function, so I read the code 
for the Euclidean distance.
I do not understand the purpose of the line 11 : if x[i] and y[i] are 
not NA (line 9), can dev be NA ?


Christophe


#define both_FINITE(a,b) (R_FINITE(a) && R_FINITE(b))
#define both_non_NA(a,b) (!ISNAN(a) && !ISNAN(b))

1. static double R_euclidean2(double *x, double *y, int taille)
2. {
3.double dev, dist;
4.int count, i;
5.
6.count= 0;
7.dist = 0;
8.for(i = 0 ; i < taille ; i++) {
9.if(both_non_NA(x[i], y[i])) {
10.dev = (x[i] - y[i]);
11.if(!ISNAN(dev)) {
12.dist += dev * dev;
13.count++;
14.}
15.}
16.}
17.if(count == 0)return NA_REAL;
18.if(count != taille) dist /= ((double)count/taille);
19.return sqrt(dist);
20.}

__
R-help@r-project.org 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] Optimizing C code

2010-01-22 Thread Christophe Genolini

Thanks both of you.



> Inf - Inf
[1] NaN
So isn't the line 9 useless ? If either x[i] or y[i] are NA, then dev 
will be NA and !ISNAN(dev) will detect it...

Sothe loop cool be

8.for(i = 0 ; i < taille ; i++) {
10.dev = (x[i] - y[i]);
11.if(!ISNAN(dev)) {
12.  dist += dev * dev;
13.  count++;
15.  }
16. }

No ?

Christophe

Duncan Murdoch

Christophe


#define both_FINITE(a,b) (R_FINITE(a) && R_FINITE(b))
#define both_non_NA(a,b) (!ISNAN(a) && !ISNAN(b))

1. static double R_euclidean2(double *x, double *y, int taille)
2. {
3.double dev, dist;
4.int count, i;
5.
6.count= 0;
7.dist = 0;
8.for(i = 0 ; i < taille ; i++) {
9.if(both_non_NA(x[i], y[i])) {
10.dev = (x[i] - y[i]);
11.if(!ISNAN(dev)) {
12.dist += dev * dev;
13.count++;
14.}
15.}
16.}
17.if(count == 0)return NA_REAL;
18.if(count != taille) dist /= ((double)count/taille);
19.return sqrt(dist);
20.}

__
R-help@r-project.org 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@r-project.org 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] Optimizing C code

2010-01-23 Thread Christophe Genolini

Duncan Murdoch a écrit :

On 22/01/2010 12:52 PM, Christophe Genolini wrote:

Thanks both of you.

>
> > Inf - Inf
> [1] NaN
So isn't the line 9 useless ? If either x[i] or y[i] are NA, then dev 
will be NA and !ISNAN(dev) will detect it...

Sothe loop cool be

8.for(i = 0 ; i < taille ; i++) {
10.dev = (x[i] - y[i]);
11.if(!ISNAN(dev)) {
12.  dist += dev * dev;
13.  count++;
15.  }
16. }

No ?
  


That would presumably give the same answer, but there are lots of 
reasons it might not be useless:


- the author might find it clearer, or easier to generalize to integer 
data (where your version wouldn't work).

- it might be faster, because it can abort sooner.
- it might be essentially equivalent in all important respects.

Duncan Murdoch


That's 3 good reasons to keep the other code. Thanks.

Christophe
> Duncan Murdoch
>> Christophe
>>
>>
>> #define both_FINITE(a,b) (R_FINITE(a) && R_FINITE(b))
>> #define both_non_NA(a,b) (!ISNAN(a) && !ISNAN(b))
>>
>> 1. static double R_euclidean2(double *x, double *y, int taille)
>> 2. {
>> 3.double dev, dist;
>> 4.int count, i;
>> 5.
>> 6.count= 0;
>> 7.dist = 0;
>> 8.for(i = 0 ; i < taille ; i++) {
>> 9.if(both_non_NA(x[i], y[i])) {
>> 10.dev = (x[i] - y[i]);
>> 11.if(!ISNAN(dev)) {
>> 12.dist += dev * dev;
>> 13.count++;
>> 14.}
>> 15.}
>> 16.}
>> 17.if(count == 0)return NA_REAL;
>> 18.if(count != taille) dist /= ((double)count/taille);
>> 19.return sqrt(dist);
>> 20.}
>>
>> __
>> R-help@r-project.org 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@r-project.org 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] matrix to a C function

2010-01-23 Thread Christophe Genolini

Hi the list,
Is there a way to give a matrix to a C function, and then to use it as a 
matrix ?

I write a function to print a matrix, but I use it as a vector :

1. void printMatrix(double *mTraj,int *nbCol, int *nbLigne){
2. int i=0,j=0;
3. for(i=0 ;  i < *nbLigne ; i++){
4. for(j=0 ; j < *nbCol ; j++){
5. Rprintf(" %f",mTraj[i * *nbCol + j]);
6. }
7. Rprintf("\n");
8.}
9. }

I would like to use it as a matrix (line 5 changes) :

1. void printMatrix(double *mTraj,int *nbCol, int *nbLigne){
2. int i=0,j=0;
3. for(i=0 ;  i < *nbLigne ; i++){
4. for(j=0 ; j < *nbCol ; j++){
5. Rprintf(" %f",mTraj[i,j]);
6. }
7. Rprintf("\n");
8.}
9. }

It does not work, but is there an solution close to this ?

Thanks.
Christophe

__
R-help@r-project.org 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] microbenchmark

2013-09-16 Thread Christophe Genolini

Hi the list,

I am using the function microbenchmark to measure the performance of some code. But I notice that 
the first execution of the code takes much longueur than the next executions.

I compare it to several executions of the code :

--- 8< --
A <- matrix(1:9,3)
nbReroll <- 1000
temps <- matrix(NA,1000,2)
temps[,1] <- microbenchmark(colMeans(A),times=nbReroll)$time

for(j in 1:nbReroll){
temps[j,2] <- microbenchmark(colMeans(A),times=1)$time
}

--- 8< ---
Here is a plot of the result I get.
 - In red, temps[,1], that is microbenchmarck(...,times=1000)
 - In blue temps[,2], that is for(i in 1:1000)microbenchmark(...times=1)


So why is there such a bid difference? What is the correct execution time for 
my instruction?

Christophe

--
Christophe Genolini
Maître de conférences en bio-statistique
Vice président Communication interne et animation du campus
Université Paris Ouest Nanterre La Défense

__
R-help@r-project.org 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] Add axes to a 3D scene (afer makeTriangles)

2013-01-30 Thread Christophe Genolini

Hi David,

Thanks for your answer.
Here is my (simplified) code :

 8< -
library(misc3d)

#
### Fonction that draw a point A=(x,y,z), with radius r

misc3dPoint <- function(A,r,color="black",alpha=1){
   t1 <- c(A[1]+r,A[2],A[3],A[1],A[2]+r,A[3],A[1],A[2],A[3]+r)
   t2 <- c(A[1]+r,A[2],A[3],A[1],A[2]+r,A[3],A[1],A[2],A[3]-r)
   t3 <- c(A[1]+r,A[2],A[3],A[1],A[2]-r,A[3],A[1],A[2],A[3]+r)
   t4 <- c(A[1]+r,A[2],A[3],A[1],A[2]-r,A[3],A[1],A[2],A[3]-r)
   t5 <- c(A[1]-r,A[2],A[3],A[1],A[2]+r,A[3],A[1],A[2],A[3]+r)
   t6 <- c(A[1]-r,A[2],A[3],A[1],A[2]+r,A[3],A[1],A[2],A[3]-r)
   t7 <- c(A[1]-r,A[2],A[3],A[1],A[2]-r,A[3],A[1],A[2],A[3]+r)
   t8 <- c(A[1]-r,A[2],A[3],A[1],A[2]-r,A[3],A[1],A[2],A[3]-r)
return(data.frame(rbind(t1,t2,t3,t4,t5,t6,t7,t8),color=color,alpha=alpha))
}

#
### Fonction that draw several points MA=(A,B,C,D,...)

misc3dPoints <- function(MA,r,color="black",alpha=1){
   dataV <- data.frame()
   if(length(r)==1){r <- rep(r,ncol(MA))}else{}
   if(length(color)==1){color <- rep(color,ncol(MA))}else{}
   if(length(alpha)==1){alpha <- rep(alpha,ncol(MA))}else{}
   for(i in 1:ncol(MA)){
   dataV <- 
rbind(dataV,misc3dPoint(MA[,i],r[i],color=color[i],alpha=alpha[i]))
   }
   return(dataV)
}

### Some points (points are in colomn)
MA <- 
cbind(c(3.5,3.5,3.5),c(3,2,1),c(1.5,1,0.5),c(0.3,0.3,0.3),c(0,0,0),c(4,4,4))[3:1,]

### The radius of the points
r = 0.3

### Building the list of triangle3d from the points
listOfTriangles <- misc3dPoints(MA,r,color=c(1:4,1,1),alpha=c(1,1,1,1,0,0))

### Making the scene
myScene <- makeTriangles(
  v1=as.matrix(listOfTriangles[,1:3]),
  v2=as.matrix(listOfTriangles[,4:6]),
  v3=as.matrix(listOfTriangles[,7:9]),
  color=listOfTriangles$color,alpha=listOfTriangles$alpha
)

### Drawing the scene
drawScene.rgl(myScene,xlim=c(0,4),ylim=c(0,4),zlim=c(0,4))

### Then, I export the triangles into an asy file (with is the final pupose of 
all this)
library(longitudinalData)
saveTrianglessASY(myScene)

 8< -

So I rewrite my question: is it possible to add some axes to the "myScene" 
object?

Christophe



On Jan 30, 2013, at 3:09 AM, cgenolin wrote:


Hi all,

I am drawing some 3D surfaces using the Triangle tools (package misc3) and
drawScene.rgl. Do you know if it is possible to add axes and graduation on
the scene?



You offer no code or data,  so a specific answer is not called for. Certainly the specific answer 
to the possibility of labels in rgl graph is is "yes". You might learn something by looking at the 
work that Ben Bolker and I put into a question requesting labels on the scatter3d function in 
package "car";


http://stackoverflow.com/questions/8204972/carscatter3d-in-r-labeling-axis-better/8206320#8206320




--
Christophe Genolini
Maître de conférences en bio-statistique
Vice président Communication interne et animation du campus
Université Paris Ouest Nanterre La Défense

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


Re: [R] Problem with a submission to jss

2012-10-14 Thread Christophe Genolini

Le 14/10/2012 00:00, Duncan Murdoch a écrit :

On 12-10-13 3:20 PM, Christophe Genolini wrote:

Hi the list,

I am about to submit an article describing an R package to the Journal of 
Statistical Software but I
encounter a strange behavior of LaTeX: the numbering of the figure is correct 
(1. 2. 3. ...), but
when I make a reference to a figure, the section (or the subsection) number 
appears instead of the
figure number.
I check if this behavior occurs with the file example provide in the jss 
package style: it does (I
joint the example to this mail). So does someone know what is wrong?

Sincerely
Christophe



This body part will be downloaded on demand.



I would guess you put the \label in the wrong place.  Put it in the \caption 
and it should be fine.

Duncan Murdoch


It works, thanks.
But it looks surprising for me. I use LaTeX for quite a long time and I always put the \label after 
the \caption (and I find several website that advice to do so). Is it something specific to the jss 
style?


Christophe

--
Christophe Genolini
Maître de conférences en bio-statistique
Vice président Communication interne et animation du campus
Université Paris Ouest Nanterre La Défense

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


[R] exporting 3D dynamic graph

2012-11-05 Thread Christophe Genolini
Hi the list,

Using misc3d, we can export 3d dynamic graph in pdf format.

Is it also possible to export these graph into a format that we can publish on 
the web?

Christophe



-- 
Christophe Genolini
Maître de conférences en bio-statistique
Vice président Communication interne et animation du campus
Université Paris Ouest Nanterre La Défense


[[alternative HTML version deleted]]

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


Re: [R] exporting 3D dynamic graph

2012-11-05 Thread Christophe Genolini
Perfect, thanks a lot !
> On 11/5/2012 8:23 AM, Christophe Genolini wrote:
>> Hi the list,
>>
>> Using misc3d, we can export 3d dynamic graph in pdf format.
>>
>> Is it also possible to export these graph into a format that we can publish 
>> on the web?
>>
>> Christophe
> You don't provide enough information to know exactly what your needs are,  
> but writeWebGL() in the 
> rgl function may be of some use in doing what you want.  I don't think that 
> it can handle the 
> "dynamic" part on its own yet, but perhaps with some creative JavaScript 
> additions you can get there.
>
> Rob
>>
>>
>>
>> __
>> R-help@r-project.org  mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>
>
> -- 
> __
> Robert W. Baer, Ph.D.
> Professor of Physiology
> Kirksille College of Osteopathic Medicine
> A. T. Still University of Health Sciences
> Kirksville, MO 63501 USA


-- 
Christophe Genolini
Maître de conférences en bio-statistique
Vice président Communication interne et animation du campus
Université Paris Ouest Nanterre La Défense


[[alternative HTML version deleted]]

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


[R] r-help or r-devel ?

2012-11-05 Thread Christophe Genolini
Hi the list,

I have some basic questions about "writing a package". On which list shall I 
post them? 
Theoretically, I am supposed to post them on r-devel, but all the questions on 
this list are very 
advance questions, not basic ones... So I don't know what to do.

Christophe

-- 
Christophe Genolini
Maître de conférences en bio-statistique
Vice président Communication interne et animation du campus
Université Paris Ouest Nanterre La Défense


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Is it possible to be sponsored by R?

2012-11-19 Thread Christophe Genolini
Hi the list,

I am a member of the organizing comity of the French Statistics Association 
(SFdS)'s conference. We 
are looking for sponsors. Some software (SAS, RITME, ...) are represented. Do 
you know if there is 
any possibility to be sponsored by R (or by an association close to R)? Do you 
think I can ask to 
the R fondation?

Sincerely
Christophe



-- 
Christophe Genolini
Maître de conférences en bio-statistique
Vice président Communication interne et animation du campus
Université Paris Ouest Nanterre La Défense


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] How fast is the JSS reviewing process?

2014-01-14 Thread Christophe Genolini

Hi all,

I thought I read somewhere that the reviewing process of the Journal of Statistical Software was 
quite fast (arround 3 month). Is that correct?


--
Christophe Genolini
Maître de conférences en bio-statistique
Vice président Communication interne et animation du campus
Université Paris Ouest Nanterre La Défense

__
R-help@r-project.org 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] Petit traité de programmation orienté obje t sous R

2010-10-04 Thread Christophe Genolini
  Bonjour (English below)

J'ai le plaisir de vous annoncer la naissance de :
"Petit traité de programmation orienté objet sous R", aux éditions De Boeck.

J'y raconte comment faire de la programmation orienté objet S4, mais aussi 
comment construire un 
package.
Le style est volontairement léger, l'ouvrage se veut pédagogique et simple à 
comprendre... A vous de 
me dire si j'ai réussi...

Vous cherchiez une bonne résolution pour la rentrée 2010 ? Mettez-vous à 
l'objet...

Christophe

--- 8< --

Hi the list,

I am pleased to announce the release of :
"Petit traité de programmation orienté objet sous R", published by De Boeck.

It is about object-oriented programming (S4), but also how to build a package.
The style is intentionally light, the book is educational and easy to 
understand ... To you tell me 
if I succeeded ...

You were looking for a good resolution for the 2010 academic year? Try S4 !

Christophe

-- 
-
Christophe Genolini
Maitre de conférences
INSERM U669, Equipe Biostatistiques
UFR STAPS, Université de Paris Ouest-Nanterre-La Défense
Web: http:\\christophe.genolini.free.fr
-


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] package under unix

2008-06-15 Thread Christophe Genolini



Generally, I like to use a pdf device which can have any number of
pages.
I am proposing a graphical way a selecting a clusterization based a 
quality criterion. In order to avoid local maximum, you can build 
something like 10 000 clusterization. Exporting all of them has no 
sence. So I open two graph, on the left you can see all the quality 
criterion. On the rigth, you can see the clusterization that you are 
curently selecting on the left graph. The idea is not to export all the 
clusterization but to chose one. So you can change the selected 
clusterization by using the arrow. This is possible only on a screen.



But an X11 device will also work for single plots and there's no need
to specifically set it in the package.
  

Thanks a lot.
Is there a way to set the position at which the x11 windows shall open ? 
I do not want to be very precise, I just want the two windows to not 
open one on the top of the other...




Why not let users set the device they wish to use?
The function that is calling windows(5,5,xpos=0) is called "choice()". 
So users that do not like the output that I propose are free to not call 
"choice()", others are free to use it...



 Requests to the maintainer gets no response.

  
Lol ! I am so proud when someone is using one of my two package that I 
answer very fast... ;-)

May be it will change when I will have ten to maintain ?


Christophe

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


[R] A (not so) Short Introduction to S4

2008-07-12 Thread Christophe Genolini

Hi the list,
After months of keen work (!), thousands of questions on the R-help (and 
on the French R forum GuR), I am pleased to announce the birth of new a 
tutorial on S4:


 *** A (Not So) short Introduction to S4 ***

http://christophe.genolini.free.fr/webTutorial/index.html
It probably remains English faults. Moreover, my English translator was 
not a programmer at all. So all comments / corrections / suggestion of 
improvement are welcomes.


Christophe

PS : Am I allow to put the R logo on my web site or is it only for 
officials R core team tutorial / website?


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


[R] R logo

2008-07-15 Thread Christophe Genolini

Hi the list,

I like the R logo (grey C and blue R) very much, specialy the drawing of 
the letter with border and shadow. I would like to make something closed 
with some other letters. Does anyone know how to get a similar result ?


Christophe

__
R-help@r-project.org 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] S4 : package creation

2008-03-20 Thread Christophe Genolini
Hi the list,

Using S4, how can we create a package? In "S4 Classes in 15 pages, more 
or less", they put all the classes definition in a function that will be 
called at the opening of the library and they add "by hand" a Rd file. 
Is it the only way ? Is there something like "S4.package.skeleton"?

Thanks

Christophe

__
R-help@r-project.org 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] Sweave and printing error

2008-03-25 Thread Christophe Genolini
Hi the list.

I am writing a tutorial for my student using LaTeX and sweave. I include 
some example that work (obiously) but I would also like to include some 
example that do NOT work (for pedagogie)...
Is it possible ?

At this point, I find that :
 - if there is a error in the code, Sweave stop
 - if I put the error in try(), Sweave compile but does not print the 
error as output.

Any solution ?

Thanks a lot

Christophe

__
R-help@r-project.org 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] S4 : the list of all the object

2008-03-29 Thread Christophe Genolini
Hi the list,

Is it possible to get the list of all the S4 user define classes? I 
would like to set up a "package.skeleton.S4" but for that, I need the 
list of the classes...

Thanks

Christophe

__
R-help@r-project.org 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] Journal for R

2008-03-30 Thread Christophe Genolini
Hi the list

I made up a new statistical procedure. I will publish it in a medical 
journal, but there will be only the way of using it, no calculation or 
algorithme detail.
So is there a journal (I mean scientific journal) with selection commity 
to submit an article describing the detail of a package?

Christophe

__
R-help@r-project.org 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] tests Rin Rout

2008-03-30 Thread Christophe Genolini
Hi the list,

Some rumour (!) say that is it possible to prepare some tests for 
checking our code using .Rin and .Rout. It seems to be a very good 
practice, but I did not manage to find information on it.
So does someone know how it works ? What are we suppose to write in Rin ?

More precisely :
 - I have a package myPack.r in directories ~/myR/myPack/R/
 - I create the directory ~/myR/myPack/tests

myPack.r is :

`f1` <- function(x){cat("\nXXX F1 = ",x,"XXX\n")}
`f2` <- function(x){cat("\nXXX F2 = ",f1(x^2),"XXX\n")}

What am I suppose to do to test it? Create myPack.Rin, but what in it?

Thanks for your help.

Christophe

__
R-help@r-project.org 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] tests Rin Rout

2008-03-30 Thread Christophe Genolini

>
> See the paragraph in Writing R Extensions which explains this
Well, I saw it again and again (before asking on the r-help) but I do 
not understand. Same for the Kurt Hornik slides on the web.

>
> Create tests/myPack.R with those lines in it plus lines to actually 
> run the code.
Does it mean that each time I change the code, I will have to change it 
twice, once in R/ and once in tests/
>   If the code generates errors, your test will fail.  If you want to 
> see reports of changes to the output, also include 
> tests/myPack.Rout.save with the known correct versions of the output.
>
What should the Rout.save looks like ? I mean, what is the syntax of 
this file ?

Christophe

__
R-help@r-project.org 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] findGlobals on apply

2008-04-07 Thread Christophe Genolini
Hi the list,

Considere the following:

f <- function(x){apply(x,2,mean)}
findGlobals(f)

findGlobals consideres mean as a global variable, which it is not.
Is there a way to tell to findGlobals that mean is a function ?

Thanks

Christophe

__
R-help@r-project.org 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] findGlobals on apply

2008-04-07 Thread Christophe Genolini

> > f <- function(x){apply(x,2,mean)}
> > findGlobals(f)
> mean is a global variable, so findGlobals gets it right. 
That sound strange to me: a "variable" is something that vary... mean 
does not vary. maen will ge an argument that is a line of x and will 
make some calculous on it, that is the comportement of a function.
Of course, mean is an argument of an other function, but I do not think 
this is a reason good enouth to say that mean is a variable.

Furthemore, I use findGlobals to detect some typo. In

f <- function(myObject){return(mObject^2)}

findGlobals will detect that mObject is a global so I know there is a 
typo somewhere.
Considering mean as a globals do not let us use findGlobals this way.

Christophe

__
R-help@r-project.org 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] findGlobals on apply

2008-04-08 Thread Christophe Genolini
Hi Luke

Thanks for all these explanation, things are clearer.

Let me go back on my initial problem, that was, as a programmer, I would 
like to have a tool to detect typo by detecting globals variables:
I get that findGlobals is not design for that.

I did not realy understand the use of checkUsage (sorry for that, I am 
not a high level programmer).
But I find an example on which checkUsage does not detect the typo either:

mObjBis <- 3
f <- function(myOb){
myObBis <- myOb^2
plot(myObBis)
return(mObjBis)
}
checkUsage(f,all=TRUE)

So, my question is a more general question : is there a function that 
can detect global variable with exclusion of the function and the 
reserved word?

For example:
g <- function(x)return(x+pi)
we don't want pi to be considere as a global variable since it is a 
constant...

Is there a function that can deal with that ?

Christophe

> On Tue, 8 Apr 2008, Christophe Genolini wrote:
>
>>
>>>> f <- function(x){apply(x,2,mean)}
>>>> findGlobals(f)
>>> mean is a global variable, so findGlobals gets it right.
>> That sound strange to me: a "variable" is something that vary... mean
>> does not vary. maen will ge an argument that is a line of x and will
>> make some calculous on it, that is the comportement of a function.
>> Of course, mean is an argument of an other function, but I do not think
>> this is a reason good enouth to say that mean is a variable.
>
> You are missing some points about R and findGlobals.
>
> In R, functions are first class values: they can be assigned to
> variables, passed as arguments, and returned as results, just like
> vectors. In contrast to many other languages there is not special
> mechanism for defining functions and associating them with a name --
> the way you define a function is
>
> foo <- function(...) ...
>
> which creates a function value and assigns it to a variable.
>
> findGlobals just looks at the function body and arguments and
> determines which of the variables used would have their definitions
> looked up in the global environment if this code is run. It does not
> try to detect which of these have values or not, never mind what the
> types of those falues are.
>
> The result returned by findGlobals with merge=FALSE separates into
> variables that are explicitly used as funcitons, i.e foo in foo(x) and
> ones that are not. One could argue that findGlobals should know
> enough about apply() to realize that the FUN argument is implicitly
> used as a function; if this change were made then
>
> apply(x, 2, pi)
>
> pi would be listed as a function because it is _used_ that way.
>
>> Furthemore, I use findGlobals to detect some typo. In
>>
>> f <- function(myObject){return(mObject^2)}
>>
>> findGlobals will detect that mObject is a global so I know there is a
>> typo somewhere.
>> Considering mean as a globals do not let us use findGlobals this way.
>
> You need to do some extra work to get this -- checking which globals
> have values, and maybe whether those that are used as functions have
> values that are functions. checkUsage does this, among other things.
> For this example checkUsage produces
>
> > checkUsage(f)
> : no visible binding for global variable ‘mObject’
>
> luke
>
>> Christophe
>>
>> __
>> R-help@r-project.org 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@r-project.org 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] cls.attrib and integer

2008-04-10 Thread Christophe Genolini
Hi the list,

Is it a bug? The function cls.attrib seems to not work with integer :

values <- round(runif(50,1,10))
dim(values) <- c(10,5)
valuesBis <- as.integer(values)
dim(valuesBis) <- c(10,5)
cluster <- rep(1:2,5)
library(clv)
cls.attrib(values,cluster)
cls.attrib(valuesBis,cluster)

Christophe

__
R-help@r-project.org 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] Clean programming with R

2007-11-22 Thread Christophe Genolini
Hi all

Is there any compiler for R ? By compiler, I mean something that check 
the cleanliness of the code : if we declare all the variables we use, if 
we don't use external variable from a function and so on...
For exemple, something that will ring a bell on the following code 
(saying "line 4 : 'pp' undefine in function 'power' ")

1. pp <- 3
2. power <- function(x){
3.p <- 2
4.return(2^pp)
5. }

thanks

Christophe

__
R-help@r-project.org 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] Oriented object programming

2007-12-09 Thread Christophe Genolini
Hi all

Two questions:
 - I would like to learn more on oriented object programming with R. Is 
there any tutorial for that?
-  Without waking up a troll, I am not very familiar with diffusion 
list, I am more use to forum. On a diffusion list, how can I check if 
someone already asks a question? I mean, I went on CRAN-R website, I 
find the R mailing list archive. But is there a way to search some key 
word like "object programming"?

Thanks for your help


Christophe

__
R-help@r-project.org 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] Rerolling k-means

2007-12-10 Thread Christophe Genolini
Hi all

I am working on k-means algorithm (in R: kmeans( ) ). The R-help advice 
us to try several random start in order to avoid local minimum. Does one 
know if there is a procedure that automaticly run this rerolling and 
select the best partition ? Or any studies that gives clues on the 
number of rerolling ?

Thanks for helping.

Christophe

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


[R] R to LaTeX Univariate Analysis

2007-12-31 Thread Christophe Genolini
Hi all

Well, first: happy new year...

Second: I write a function in R that might interest some other people. 
On the other hand, I am closer to beginners than experts; I don't know 
how valuable my code is. I don't know how long it will take to me to 
create a library and I don't know if it's worth to. So before starting 
this long process, I would like some advices, both on the interest it 
present, on the way of using it and on the inner R code...

My function is called "r2lUniv" for "R to LaTeX, Univariate analysis". 
Given a variable, it performs some basic analysis in R and generates 
LaTeX code to include in a document that print the analysis in a clean 
LaTeX way. The basic analysis depends of the variable type. 4 types are 
considered:
  - Nominal: modality, size, barplot
  - Ordinal: modality, size, quartile, barplot
  - Discrete: modality, size, mean, var, quartile, boxplot, barplot
  - Continuous: mean, var, quartile, boxplot, barplot

A generalization of r2lUniv deals with data.frame by runnig the basic 
analysis on every column. So to use it:
 > dataFrame <- read.csv("myData.csv")
 > r2lUniv(dataFrame,"fileOut.tex")

It performs the basic analysis and creates all graphs. Then I add 
\input{fileOut.tex} in my main.tex file.

My source file is available at: 
http://christophe.genolini.free.fr/r2lUniv/mySource/
It is definitely NOT a code ready for a library, there is probably bugs 
in it, all comments and all variables used for testing are in. But 
still, any advices will be welcome...

Christophe

PS: Does the  manual "Writing R Extensions" exists in French? Or 
anything equivalent?

__
R-help@r-project.org 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] bug in mmlcr ?

2008-01-13 Thread Christophe Genolini
Hi the list.

Is there a bug in mmlcr package ?
The following code does not compile:

mmlcrTest <- function(dataW){
  dataL <- 
reshape(dataW,idvar="id",timevar="T",varying=list(paste("T",0:10,sep="")),direction="long",v.names="score")
 

  resultR <- mmlcr(outer= ~ 1 | id,
   components = list(list(formula = formul,class= 
"normlong")),   
   n.groups=3,
   data=dataL,
   max.iter=500
   )
  plot(resultR)
}
mmlcrTest(dataW)

The error is (translate from french):
"Error in inherits(x, "data.frame") : objet "dataL" not find"

It seems that mmlcr does not look for the data at the right place since 
it did find dataL if we set it a a global variable but it does not find 
it if we define it in a function.

Christophe

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


[R] [R-pkgs] New package: R to LaTeX Univariate Analyses

2008-01-21 Thread Christophe Genolini
Hi the list

*** New package ***
R to LaTeX : Univariate analyses
r2lUniv
*URL:*http://www.r-project.org, http://christophe.genolini.free.fr/r2lUniv

*** Description ***
r2lUniv performs some basic analyses, then generates a code to be 
included in a LaTeX document
to print the analyses in a (so nice!) LaTeX way.
r2lUniv performs the analyses automatically according to the classical 
statistics
type definition that are nominal, ordinal, discrete and continuous. The 
analysis performed are:
- Nominal : modality, size, barplot
- Ordinal: modality, size, quartile, barplot
- Discrete: modality, size, mean, var, quartile, boxplot, barplot
- Continuous: mean, var, quartile, boxplot, barplot

*** I am a Rookie... ***
Well, I know that. This is my first package and I am almost a beginner in R.
So any comment on any subject (programming style, way of writing the 
man, use of S3) are welcome
("You did a nice job, but classical usage is to..." or "Hmmm, that would 
be more practical if...").

*** Other project ***
Well, Univariate Analysis is the first step, the second is Bivariate 
analysis.
Also, before posting here, I submit this package on a French forum.
The first suggestion is to extend this package to HTML. I will not have 
time to do it alone.
So if some people are interested, two other project are almost open :
- R to LaTeX Bivaraite Analysis
- R to HTML Univariate Analysis

Thanks

Christophe Genolini

Junior statistician
"PSIGIAM: Paris Sud Innovation Group in Adolescent Mental Health"
INSERM U669 / Maison de Solenn / Paris

___
R-packages mailing list
[EMAIL PROTECTED]
https://stat.ethz.ch/mailman/listinfo/r-packages

__
R-help@r-project.org 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] package manual in pdf

2008-01-23 Thread christophe . genolini
Hi all,

I am trying to write a pdf manual for my package. I create a file
inst\doc\myDoc.tex. I taught that R CMD build will call latex on this file (like
it is said in Writing R extension), but it does not happen.

I also notice that a pdf manual is produce automatically but with a not so good
presentation (very long lines that step outside the page for example). Where can
I find the source code of this .pdf ? Is there a way to modify it?

Sorry to ask these questions, but writing R extension is not that clear on the
topic...

Christophe

__
R-help@r-project.org 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] Contributed Documentation

2009-01-06 Thread Christophe Genolini

Hi the list,

I wrote a tutorial about S4. Is it possible to have a link to it in the 
page "Contributed Documentation" or "R Documentation" on the CRAN web 
site ? Who shall I contact ?


Christophe

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


[R] A (Not So) Short Introduction to S4 (ex Contributed Documentation)

2009-01-07 Thread Christophe Genolini

Here is the link :

http://christophe.genolini.free.fr/webTutorial/index.php

Any comments are welcome.

Christophe





On Tue, Jan 6, 2009 at 8:17 PM, Ben Bolker  wrote:


> Christophe Genolini  u-paris10.fr> writes:
>
  

>>
>> Hi the list,
>>
>> I wrote a tutorial about S4. Is it possible to have a link to it in the
>> page "Contributed Documentation" or "R Documentation" on the CRAN web
>> site ? Who shall I contact ?
>>
>> Christophe


>
>  Try c...@r-project.org .  Posting to the development list
> (r-de...@r-project.org) might also be appropriate.
>  I would be curious to see the tutorial myself.
>
>  Ben Bolker
>
> _


I would too.

On Tue, Jan 6, 2009 at 8:17 PM, Ben Bolker  wrote:


> Christophe Genolini  u-paris10.fr> writes:
>
  

>>
>> Hi the list,
>>
>> I wrote a tutorial about S4. Is it possible to have a link to it in the
>> page "Contributed Documentation" or "R Documentation" on the CRAN web
>> site ? Who shall I contact ?
>>
>> Christophe


>
>  Try c...@r-project.org .  Posting to the development list
> (r-de...@r-project.org) might also be appropriate.
>  I would be curious to see the tutorial myself.
>
>  Ben Bolker
>
> _


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


Re: [R] R-help Digest, Vol 71, Issue 7

2009-01-07 Thread Christophe Genolini

Thanks for your answer
Here it is :

http://christophe.genolini.free.fr/webTutorial/index.php

Any comments are welcome...

Christophe

__
R-help@r-project.org 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] Strange behavior of savePlot

2009-02-25 Thread Christophe Genolini

Hi all,

I am using savePlot in a loop for saving several graph but I get some 
graph in 553x552, some other in 1920x1119. How comes ?
My data are almost all the same (same label, same xlim / ylim, almost 
same data. Only the color changes).  I save them in bmp.

Thanks for your help.

Christophe

__
R-help@r-project.org 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] Strange behavior of savePlot

2009-02-26 Thread Christophe Genolini

Uwe Ligges a écrit :



Christophe Genolini wrote:

Hi all,

I am using savePlot in a loop for saving several graph but I get some 
graph in 553x552, some other in 1920x1119. How comes ?
My data are almost all the same (same label, same xlim / ylim, almost 
same data. Only the color changes).  I save them in bmp.

Thanks for your help.



Rather than using a Windows Device and copying the contents, just use 
the bmp() device directly if you really want bitmaps.


Uwe Ligges
I do not want a bitmaps. I use savePlot in a library, so I let the user 
decide whith export he wants.

Christophe

__
R-help@r-project.org 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] Strange behavior of savePlot

2009-02-26 Thread Christophe Genolini

Uwe Ligges a écrit :



Christophe Genolini wrote:

Uwe Ligges a écrit :



Christophe Genolini wrote:

Hi all,

I am using savePlot in a loop for saving several graph but I get 
some graph in 553x552, some other in 1920x1119. How comes ?
My data are almost all the same (same label, same xlim / ylim, 
almost same data. Only the color changes).  I save them in bmp.

Thanks for your help.



Rather than using a Windows Device and copying the contents, just 
use the bmp() device directly if you really want bitmaps.


Uwe Ligges
I do not want a bitmaps. I use savePlot in a library, so I let the 
user decide whith export he wants.



Then, why not let the user choose a proper device?
Because I program a graphical interface that let the user to chose the 
graph he want to export (that can be one but also 50). Then he sets 
dynamicaly the parameters for all the graphics he wants to export. Then 
all the graphs are exported at once.
Anyway, the resulting bitmap is copied from the screen device, that 
means the size is also copied.
That means if you have some 1600x1200 screen and your windows device 
is resized to fullscreen, than you will almost get 1600x1200 pixels in 
your bitmap...
Ok, the "strange behevior" was occuring because I change the size of the 
windows during the export...

Thanks a lot

Christophe


Uwe Ligges



Christophe

__
R-help@r-project.org 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@r-project.org 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] probleme with savePlot (to eps)

2009-03-01 Thread Christophe Genolini

Hi the list,

I used savePlot to export some eps graph but it seems that the graph 
file hold a bug. I include the graph.eps in a LaTeX file. Running latex 
is ok. But the dvi file contain some mistake, the graph overprint on 
some text and hide it. Then, when I try to convert it to another format, 
I get :


Ignoring remaining special text following unkown PS operator: "SDict"

Remainder of line unparsed
Current input buffer is --> begin /product where{pop 
product(Distiller)search{...<--


Any idea to correct that ?

Christophe

__
R-help@r-project.org 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] probleme with savePlot (to eps)

2009-03-01 Thread Christophe Genolini

Thanks for your answer.

Use the postscript device to save .ps or .eps files.
Unfortunatly, I can't. I am using savePlot in a package. Several graphs 
(up to 100) are exported at the same time and I would like the user to 
chose the extension. It is why I need savePlot.


Beside, I did not find any warning again postscript in the help page for 
savePlot. Where did you get this information ? I am using R 2.8.1


Christophe
The help page for savePlot does not suggest that it would be of any 
value in saving plots as postscript files.


?postscript
?Devices



__
R-help@r-project.org 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] probleme with savePlot (to eps)

2009-03-02 Thread Christophe Genolini
I am using windows XP pack3 and R 2.8.1 so I guess this is savePlot for 
Windows.

As Gabor say, savePlot offer to export graph also in eps.


If you want to copy a screen device to postscript portably, use 
dev.copy2eps().


I am exporting graph in a package, so I don't want to copy screen device 
to postscript, I want to copy screen device to postscript OR to any 
other type that the user may want...
It is why I can not use a specific function (postscrip(), dev.copy2eps() 
) but I need a generic one.


Christophe


On Sun, 1 Mar 2009, David Winsemius wrote:

Unfortunately your burning desire to use savePlot for this purpose is 
not going to reconfigure the capabilities of that function. Just read 
the help page of savePlot:


savePlot {grDevices}
R Documentation
Save Cairo X11 Plot to FileDescription
Save the current page of a cairo X11() device to a file.

Usage
savePlot(filename = paste("Rplot", type, sep="."), type = c("png", 
"jpeg", "tiff", "bmp"), device = dev.cur())


Do you see "ps" or "eps" in the supported types? I do not. Why would 
you expect be a warning not to use a type of device that was not 
documented as possible.
Have you looked at dev.copy or dev.print as a method of getting the 
user choice of screen displayed graphics to an output file?

--
David Winsemius



On Mar 1, 2009, at 6:02 PM, Christophe Genolini wrote:


Thanks for your answer.

Use the postscript device to save .ps or .eps files.
Unfortunatly, I can't. I am using savePlot in a package. Several 
graphs (up to 100) are exported at the same time and I would like 
the user to chose the extension. It is why I need savePlot.


Beside, I did not find any warning again postscript in the help page 
for savePlot. Where did you get this information ? I am using R 2.8.1


Christophe
The help page for savePlot does not suggest that it would be of any 
value in saving plots as postscript files.


?postscript
?Devices





__
R-help@r-project.org 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@r-project.org 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] Redefining [ using next method

2009-03-20 Thread Christophe Genolini

Hi all,

I would like to use an object and to add some definition to the [ 
function, but I do not manage...
My objet is a "trajectories", a matrix whose columne name does contain 
information :


-
trajectories <- function(traj,varName,time){
 colnames(traj) <- paste(varName,time,sep="")
 class(traj) <- c("trajectories","matrix")
 return(traj)
}
x <- trajectories(traj=matrix(1:12,4),varName="T",time=c(1,2,4))
--

Then I would like to define the [ operator in the following way :

---
> x["varName"]
[1] "T"
> x["time"]
[1] 1 2 4
> x[1,]
1 5 9
> x[,1]
1 2 3 4


For that, I write:


"[.trajectories" <- function(traj,slot,...){
   
if(slot=="varName"){return(gsub("(\\d+)$","",colnames(traj)[1],perl=T))}else{}
   
if(slot=="time"){return(as.numeric(gsub("(^.+\\D)(\\d+$)","\\2",colnames(traj),perl=T)))}else{}

   NextMethod()
}


The ["varName"],["time"] and [1,] work fine, but not [,1]
Any idea of what is wrong and how to correct?

Thanks
Christophe

__
R-help@r-project.org 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] Integer vs numeric

2008-01-28 Thread Christophe Genolini
Hi the list.

I do not understand the philosophy behind numeric and integer.
 - 1 is numeric (which I find surprising)
 - 2 is numeric.
 - 1:2 is integer.
Why is that ?

Christophe

__
R-help@r-project.org 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] Integer vs numeric

2008-01-28 Thread Christophe Genolini

> Further to the above: The help
>
>   ?":"
>
> says:
>
> Value:
>   For numeric arguments [as opposed to factors],
>   a numeric vector. This will be of type 'integer'
>   if 'from' and 'to' are both integers and
>   representable in the integer type, otherwise of
>   type 'numeric'
???

This is very surprising since with a "to" numeric, the result is integer :

 > str(1:4.5)
 int [1:4] 1 2 3 4

Anyway, if I understand, 'integer' in R is not realy the math type 
integer. I am a bit confuse...

Christophe

__
R-help@r-project.org 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] Integer vs numeric

2008-01-29 Thread Christophe Genolini
x[c(2,4)] work as well

Henrik Bengtsson a écrit :
> x[1:n]
>
> /H
>
> On Jan 29, 2008 5:07 AM,  <[EMAIL PROTECTED]> wrote:
>   
>> Seems strange to me to define an operator relatively to a very special case.
>> I have to admit that I do not use 1:1e7 every day :-)
>>
>> Wouldn't it be more appropriate to define a a:b operator numeric (that
>> is preserving the initial class of a and b) and in specific case that
>> need optimization, changing the type?
>>
>> for i in as.integer(1:1e7)
>>
>> That might appears as a minor point, but when using S4, for what I
>> know, if you define a class that can take either 1:3 or c(1,3,4), one
>> is integer, the other numeric, one of those will not be accepted by the
>> class...
>>
>> Christophe
>>
>>
>>
>> 
>>> On 28-Jan-08 22:40:02, Peter Dalgaard wrote:
>>>   
 [...]
 AFAIR, space is/was more of an issue. If you do something like

 for i in 1:1e7
 some.silly.simulation()

 then you have 40 MB sitting there doing nothing, and 80 MB if
 it had been floating point.
 
>>> Hmmm ... there's something to be said for good old
>>>
>>>  for(i=1,i<=1e7,i++){}
>>>
>>> As pointed out in ?"for", when you do
>>>
>>>  for(i in X){...}  #(e.g. X=(1:1e7))
>>>
>>> the object X is created (or is already there) in full
>>> at the start and sits there, as you say doing nothing,
>>> until you end the loop. Whereas the C code just keeps
>>> track of i and of the condition.
>>>
>>> At least on a couple of my machines (64MB and 184MB RAM)
>>> knocking out 40MB would inflict severe trauma! Let alone 80MB.
>>> Mind you, the little one is no longer allowed to play with
>>> big boys like R, though the other one is still used for
>>> moderate-sized games.
>>>
>>> Would there be much of a time penalty in implementing
>>> a 'for' loop, C-style, as
>>>
>>>  i<-1
>>>  while(i<=1e7){
>>>...
>>>i<-i+1
>>>  }
>>>
>>> ??
>>>
>>> It looks as though there might be:
>>>
>>>  system.time(for(i in (1:1e7)) x<-cos(3) )
>>>  #[1] 13.521  0.132 13.355  0.000  0.000
>>>  system.time({i<-1;while(i<=1e7){x<-cos(3);i<-i+1}})
>>>  #[1] 38.270  0.076 37.629  0.000  0.000
>>>
>>> which suggests that the latter is about 3 times as slow.
>>> (And no, this wasn't done on either of my puny babes).
>>>
>>> (And this isn't the first time I've wished for an R
>>> implementation of "++" as a CPU-level incrementation,
>>> as opposed to the R-arithmetic implementation which
>>> treats "adding 1 to a variable" as a full-dress
>>> arithmetic parade!
>>>
>>> Best wishes,
>>> Ted.
>>>
>>> 
>>> E-Mail: (Ted Harding) <[EMAIL PROTECTED]>
>>> Fax-to-email: +44 (0)870 094 0861
>>> Date: 28-Jan-08   Time: 23:34:52
>>> -- XFMail --
>>>
>>>   
>>
>> 
>> Ce message a ete envoye par IMP, grace a l'Universite Paris 10 Nanterre
>>
>>
>> __
>> R-help@r-project.org 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@r-project.org 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] learning S4

2008-02-13 Thread Christophe Genolini
Robin Hankin a écrit :
> Christophe
>
> you might find the Brobdingnag package on CRAN helpful here.
>
Yep, I read it and I find it very usefull. A question anyway:

Is there a way to change a slot without using the <- ?

Instead of
 > new("obj")
 > [EMAIL PROTECTED] <- 3

I would like to have
 > new("obj")
 > setSlotA(obj,3)

In your vignette, 'Section 8 : Get and Set methods', you define 4 Gets, 
but no Set...

Christophe

__
R-help@r-project.org 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] Hiding a function

2008-02-23 Thread Christophe Genolini
Hi the list

Is it possible to 'hide' a function  from the user ? I cut a big 
fonction in sub
function and I would like to hide the sub function, just like if I 
declare them
in the big function :

--
a <- function(x){
  b <- function(y){y^2}
  d <- function(y){y^3}
  b(x)+d(x)+2
}
a(2)
# [1] 14
b(2)
# Error :


I would like the same, but with external declaration (for readability) :


b <- function(y){y^2}
d <- function(y){y^3}
a <- function(x){
  b(x)+d(x)+2
}
a(2)
# [1] 14
b(2)
# Error


Is it possible ?

Thanks

Christophe

__
R-help@r-project.org 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] Hiding a function

2008-02-23 Thread Christophe Genolini
Duncan Murdoch a écrit :
> On 23/02/2008 5:15 AM, Christophe Genolini wrote:
>> Hi the list
>>
>> Is it possible to 'hide' a function  from the user ? I cut a big 
>> fonction in sub
>> function and I would like to hide the sub function, just like if I 
>> declare them
>> in the big function :
>>
>> --
>> a <- function(x){
>>   b <- function(y){y^2}
>>   d <- function(y){y^3}
>>   b(x)+d(x)+2
>> }
>> a(2)
>> # [1] 14
>> b(2)
>> # Error :
>> 
>>
>> I would like the same, but with external declaration (for readability) :
>>
>> 
>> b <- function(y){y^2}
>> d <- function(y){y^3}
>> a <- function(x){
>>   b(x)+d(x)+2
>> }
>> a(2)
>> # [1] 14
>> b(2)
>> # Error
>> 
>>
>> Is it possible ?
>
> Yes, as long as you're using a package with a NAMESPACE, just don't 
> export b and d.  There are other ways too, but they don't improve 
> readability.
>
> Duncan Murdoch
If I understand, it is possible only in a package, not in a programme 
(unless the "other ways"), is that it ?
Ok, thanks.

Christophe

__
R-help@r-project.org 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] Set without argument

2008-02-23 Thread Christophe Genolini
Hi the list,

I am defining S4 objet. Is it possbile to define a method that change 
the slot of an object without using <- ?
My object contain a numeric and a matrix. At some point, I would like to 
impute the missing value in the matrix. So I would like to use something 
like :

-
setClass("MyObj",representation(time="numeric",traj="matrix"))
a <- new("MyObj",time=3,traj=matrix(c(1:6,NA,8:12),ncol=3))
imputeMyObj(a)
-

I find 'setTime<-' to change le slot time, but it can not work in the 
case of imputeMyObs since this mehod does not need a value...

Any solution ?

Thanks

Christophe

__
R-help@r-project.org 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] Hiding a function

2008-02-23 Thread Christophe Genolini
Gabor Csardi a écrit :
> It depends what you mean by 'hiding',
Well, the main idea was the to limit the existance of a function.
a( ) need b( ) but no other function will need b(). So I would have like 
to let b( ) exists localy only when a( ) is called, not elsewhere.

Christophe
>  you can start the function 
> names with a dot and then they are not listed by ls(), so this
> is kind of hiding.
>
>   
>> .a <- function() TRUE
>> ls()
>> 
> character(0)
>   
>> .a
>> 
> function() TRUE
>
> Personally i would not do this though.
>
> G.
>
> On Sat, Feb 23, 2008 at 11:58:57AM +0100, Christophe Genolini wrote:
> [...]
>   
>> If I understand, it is possible only in a package, not in a programme 
>> (unless the "other ways"), is that it ?
>> Ok, thanks.
>>
>> 
> [...]
>
>   


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Hiding a function

2008-02-23 Thread Christophe Genolini
Ok, I saw FUNx
So, I reformulate my question : is there a way, without nesting b( ) in 
a( ), to make b( ) available only in a( ) ?
> Just to clarify, what Duncan was referring to as the
> alternative was nesting the definition of one function
> in another, e.g. look at FUNx in by.data.frame --
> FUNx is available to by.data.frame but is not
> visible outside of by.data.frame .
>
> On Sat, Feb 23, 2008 at 6:09 AM, Duncan Murdoch <[EMAIL PROTECTED]> wrote:
>   
>> On 23/02/2008 5:58 AM, Christophe Genolini wrote:
>> 
>>> Duncan Murdoch a écrit :
>>>   
>>>> On 23/02/2008 5:15 AM, Christophe Genolini wrote:
>>>> 
>>>>> Hi the list
>>>>>
>>>>> Is it possible to 'hide' a function  from the user ? I cut a big
>>>>> fonction in sub
>>>>> function and I would like to hide the sub function, just like if I
>>>>> declare them
>>>>> in the big function :
>>>>>
>>>>> --
>>>>> a <- function(x){
>>>>>   b <- function(y){y^2}
>>>>>   d <- function(y){y^3}
>>>>>   b(x)+d(x)+2
>>>>> }
>>>>> a(2)
>>>>> # [1] 14
>>>>> b(2)
>>>>> # Error :
>>>>> 
>>>>>
>>>>> I would like the same, but with external declaration (for readability) :
>>>>>
>>>>> 
>>>>> b <- function(y){y^2}
>>>>> d <- function(y){y^3}
>>>>> a <- function(x){
>>>>>   b(x)+d(x)+2
>>>>> }
>>>>> a(2)
>>>>> # [1] 14
>>>>> b(2)
>>>>> # Error
>>>>> 
>>>>>
>>>>> Is it possible ?
>>>>>   
>>>> Yes, as long as you're using a package with a NAMESPACE, just don't
>>>> export b and d.  There are other ways too, but they don't improve
>>>> readability.
>>>>
>>>> Duncan Murdoch
>>>> 
>>> If I understand, it is possible only in a package, not in a programme
>>> (unless the "other ways"), is that it ?
>>>   
>> Yes, that's right.  Here's one of the other ways:
>>
>> a <- local( {
>>   b <- function(y){y^2}
>>   d <- function(y){y^3}
>>   function(x){
>> b(x)+d(x)+2
>>   }
>>  })
>>
>> I don't find that more readable than if b and d had been defined locally
>> within a.
>>
>> Duncan Murdoch
>>
>>
>> __
>> R-help@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
>> 
>
>   


[[alternative HTML version deleted]]

__
R-help@r-project.org 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] Standard method for S4 object

2008-02-23 Thread Christophe Genolini
Hi the list,

I am defining a new class MyClass. Shortly, I will submit a package with 
it. Before, I would like to know if there is a kind of "non official 
list" of what method a new S4 object have.
More precisely, personnaly, I use 'print', 'summary' and 'plot' a lot. 
So for my new class, I define these 3 methods. Is there some other 
method that a R user can raisonnably expect ? Some "minimum basic tools"...

Thanks

Christophe

__
R-help@r-project.org 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] Set without argument

2008-02-23 Thread Christophe Genolini
Thanks a lot
> The 'usual' way to write the above code is
>
>   
>> a <- imputeMyObj(a)
>> 
:-(
I was hopping something like the use of the superassignator <<- inside 
imputeMyObj (I was hoping even if I did not find it myself)...
To bad.

But thanks for teaching me 'usual' pratice. It is something that is not 
so easy to find in toturial, and as medium level programmer, it is not 
always clear to pick the good way when we hesitate between two...

Christophe

__
R-help@r-project.org 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] Hiding a function

2008-02-23 Thread Christophe Genolini
After some private email with some high level programmer (Gabor), I have 
the solution and I can answer to my own question :-)

The problem was 1° to define a function B( ) available only in a 
function A( ) (for code safeness) and 2° to define B( ) elsewhere than 
in A( ) (for code readability)


The solution is the following

# Definition of an environment that will be use in A() (a list will work as 
well)
envA <- new.env()

# Definition of B(), in environment envA :
envA$b <- function(x) x2

# Definition of A :
A <- function(x) with(envA, {
  B(3)
})

Thanks

Christophe

> On 23/02/2008 5:15 AM, Christophe Genolini wrote:
>> Hi the list
>>
>> Is it possible to 'hide' a function  from the user ? I cut a big 
>> fonction in sub
>> function and I would like to hide the sub function, just like if I 
>> declare them
>> in the big function :
>>
>> --
>> a <- function(x){
>>   b <- function(y){y^2}
>>   d <- function(y){y^3}
>>   b(x)+d(x)+2
>> }
>> a(2)
>> # [1] 14
>> b(2)
>> # Error :
>> 
>>
>> I would like the same, but with external declaration (for readability) :
>>
>> 
>> b <- function(y){y^2}
>> d <- function(y){y^3}
>> a <- function(x){
>>   b(x)+d(x)+2
>> }
>> a(2)
>> # [1] 14
>> b(2)
>> # Error
>> 
>>
>> Is it possible ?
>
> Yes, as long as you're using a package with a NAMESPACE, just don't 
> export b and d.  There are other ways too, but they don't improve 
> readability.
>
> Duncan Murdoch
>

__
R-help@r-project.org 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] Standard method for S4 object

2008-02-24 Thread Christophe Genolini

> /I think your question should be more relevant on Rdev./
ok, I will
> Personnally I would find stuff like "names",  "$", "$<-", or "[" 
> useful as these are usual operation with S3 objects.
Is it possible in S4 to define "$<-" ? If there is a slot name 'a' in 
object 'B', I find (in "S4 in 15 pages more or less")

setGeneric("a<-", function(x, value) standardGeneric("a<-"))
setReplaceMethod("a", .

Then we can use

obj <- new("B")
a(obj)<- 3

But I did not find how to define

obj$a <- 3

Is it possible ? Is it the 'usual' way ?


Christophe

__
R-help@r-project.org 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] S4 : Signature

2008-02-24 Thread Christophe Genolini
Hi the list

Is it possible to define a method with a signature that will have more 
argument than the generic method?
For exemple, print has only one argument, plot has two, can I do 
something like :

setMethod("print",signature=c(x="numeric",y="character"),function(x,y,...) 
..
setMethod("plot",signature=c(x="numeric",y="character",z="numeric"),function(x,y,z,...)
 
..

Thanks

Christophe

__
R-help@r-project.org 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] Set without argument

2008-02-26 Thread Christophe Genolini
Hi Martin

What do you think of the following code ?

A <- 1

imputeMyObj <- function(x){
  xImp <- 3 #Calcul for Imputation of x
  nam<-deparse(substitute(x))
  assign(nam,xImp,envir=parent.frame())
}
imputeMyObj(A)
A

I guess it is not usual, but do you think it is 'bad' programming or 
will have side effect that I do not see ?

Christophe

> Christophe Genolini <[EMAIL PROTECTED]> writes:
>
>   
>> Hi the list,
>>
>> I am defining S4 objet. Is it possbile to define a method that change 
>> the slot of an object without using <- ?
>> My object contain a numeric and a matrix. At some point, I would like to 
>> impute the missing value in the matrix. So I would like to use something 
>> like :
>>
>> -
>> setClass("MyObj",representation(time="numeric",traj="matrix"))
>> a <- new("MyObj",time=3,traj=matrix(c(1:6,NA,8:12),ncol=3))
>> imputeMyObj(a)
>> -
>> 
>
> Hi Christophe --
>
> The 'usual' way to write the above code is
>
>   
>> a <- imputeMyObj(a)
>> 
>
> with imputeMyObj designed to take a 'MyObj' as it's argument, and
> return a modified 'MyObj' (that the user can assign to 'a', if they
> like). Inside imputeMyObj, the developer would, in the end, write
> something like
>
> impuateMyObj <- function(obj) {
># calculate imputed values 'imp'
>slot(obj, "traj") <- imp
>obj
> }
>
> A better design would have a 'setter' method, minimally
>
>   
>> setGeneric("traj<-",
>> 
> +function(object, ..., value) standardGeneric("traj<-"))
> [1] "traj<-"
>   
>> setReplaceMethod("traj",
>> 
> +  signature=signature(
> +object="MyObj",
> +value="matrix"),
> +  function(object, ..., value) {
> +  slot(object, "traj") <- value
> +  object
> +  })
> [1] "traj<-"
>
> and then the impute code would have
>
> impuateMyObj <- function(obj) {
># calculate imputed values 'imp'
>traj(obj) <- imp
>obj
> }
>
> It's possible to design 'MyObj' so that it can be modified in-place
> (e.g., storing data in a slot of class 'environment', which has
> reference-like behavior) but this will probably surprise both you and
> the user.
>
> Martin
>
>   
>> I find 'setTime<-' to change le slot time, but it can not work in the 
>> case of imputeMyObs since this mehod does not need a value...
>>
>> Any solution ?
>>
>> Thanks
>>
>> Christophe
>>
>> __
>> R-help@r-project.org 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@r-project.org 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] tutorial on codetools

2008-02-28 Thread Christophe Genolini
Hi the list 

Is there any tutorial to learn codetools ? It seems to be a very 
interesting pacakge, but the help gives not that much detail, and there 
is not that much examples provided...

Christophe

__
R-help@r-project.org 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] inheritence in S4

2008-03-03 Thread Christophe Genolini
Thanks Martin

Well it works except that "as" seems to not like the "initialize" method 
: the following code (that is the same than yours with some initialize 
for A B and C) does not compile. It seems that as(c,"A") does not work 
if we definie a initialize for A...

--- 8< --
setClass("A", representation(x="numeric"))
setMethod("initialize","A",function(.Object,value)[EMAIL PROTECTED] <- 
value;return(.Object)})
a <- new("A",4)

setClass("B", representation(y="numeric"))
setMethod("initialize","B",function(.Object,value)[EMAIL PROTECTED] <- 
value;return(.Object)})
b <- new("B",5)

setClass("C", contains=c("A", "B"))
setMethod("initialize","C",function(.Object,valueA, valueB){
[EMAIL PROTECTED] <- valueA
[EMAIL PROTECTED] <- valueB
return(.Object)
})
c <- new("C",valueA=10,valueB=12)

setMethod("show", "A", function(object) cat("A\n"))
setMethod("show", "B", function(object) cat("B\n"))
setMethod("show", "C", function(object) {
callGeneric(as(object, "A"))
callGeneric(as(object, "B"))
cat("C\n")
})
c
--- 8< 

Is there something wrong with the use of 'as' between class and father 
class?

Christophe
> Hi Christophe -- 
>
> I don't know whether there's a particularly elegant way. This works
>
> setClass("A", representation(x="numeric"))
> setClass("B", representation(y="numeric"))
> setClass("C", contains=c("A", "B"))
>
> setMethod("show", "A", function(object) cat("A\n"))
> setMethod("show", "B", function(object) cat("B\n"))
> setMethod("show", "C", function(object) {
> callGeneric(as(object, "A"))
> callGeneric(as(object, "B"))
> cat("C\n")
> })
>
>   
>> new("C")
>> 
> A
> B
> C
>
> but obviously involves the developer in making explicit decisions
> about method dispatch when there is multiple inheritance.
>
> Martin
>
> [EMAIL PROTECTED] writes:
>
>   
>> Hi the list
>>
>> I define a class A (slot a and b), a class C (slot c and d) and a class 
>> E that inherit from A and B.
>> I define print(A) and print(B). For print(C), I would like to use both 
>> of them, but I do not see how...
>>
>> Thanks for your help...
>>
>> Christophe
>>
>> 
>> Ce message a ete envoye par IMP, grace a l'Universite Paris 10 Nanterre
>>
>> __
>> R-help@r-project.org 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@r-project.org 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] inheritence in S4

2008-03-05 Thread Christophe Genolini
Hi Martin

I was not that much speaking about what we can do, but more about what 
we can't. We can't decide that object will be 'never empty', we have to 
allow empty oject, otherwise new("A") will not work and that will be 
problematic.

So, at this point, I see :
  - it is necessary to allow the creation of empty object (otherwise, we 
are in trouble with 'as')
  - so 'new' will have to create object either empty or valid.
  - 'initialize' can check if an object is valid but has first to check 
if the object is non empty
  - I create an object Ccc containing an object Aaa : If Ccc is calling 
the constructor of Aaa, then initialize of Aaa ic called. If Ccc is 
setting the Aaa slot one bu one, the initialize of Aaa is not caller.
  - In addition, I did not speak about the setteur, but the 'setSlotX 
<-' does not call the initialize. So we have to check the validity of 
the object after any 'setSlot' again.

In consequence, to program as safe as possible:
  - for checking if an object is valid or not, I am thinking of setting 
a method checkCoherance
  - 'initialize' will just set slot to either empty or some value, then 
call checkCoherance
  - 'setSlotX<-' will change slot X, then call checkCoherance
  - If I create a C object, its checkCoherance method will call 
checkCoherance(as(object,"A"))

Here is an example (still the same stupid example with a single slot. 
Obviously, it has no interest on so small object, it is just to simplify)

--- 8< --
setGeneric("checkCoherance",function(object){standardGeneric("checkCoherance")})

setClass("A", representation(x="numeric"))
setMethod("checkCoherance","A",
function(object){
cat("*** checkCoherance A ***\n")
if(length([EMAIL PROTECTED])>0){
if([EMAIL PROTECTED]<0){stop("Object incoherance : x should be 
positive")}else{}
}else{}
return(TRUE)
}
)

setMethod("initialize","A",
function(.Object,value=numeric(0)){
cat("*** initialize A ***\n")
[EMAIL PROTECTED] <- value
checkCoherance(.Object)
return(.Object)
}
)

setGeneric("setX<-",function(object,value){standardGeneric("setX<-")})
setReplaceMethod("setX","A",
  function(object,value){
[EMAIL PROTECTED] <- value
checkCoherance(object)
return(object)
  }
)
 
a1 <- new("A")
a2 <- new("A",value=4)
try(a3 <- new("A",value=-4))

A <- function(val=numeric(0)){
  new("A",value=val)
}
A()
A(val=4)
A(val=-4)

setClass("C", representation(y="numeric"),contains="A")
setMethod("checkCoherance","C",
function(object){
cat("*** checkCoherance C ***\n")
if(length([EMAIL PROTECTED])>0){
if([EMAIL PROTECTED]>0){stop("Object incoherance : y should be 
négative")}else{}
}else{}
checkCoherance(as(object,"A"))
return(TRUE)
}
)
setMethod("initialize","C",
function(.Object,valueX=numeric(0), valueY=numeric(0)){
cat("*** initialize C ***\n")
[EMAIL PROTECTED] <- valueX
[EMAIL PROTECTED] <- valueY
checkCoherance(.Object)
return(.Object)
}
)

c <- new("C",valueX=10,valueY=12)
new("C")

C <- function(valX=numeric(0),valY=numeric(0)){
   new("C",valueX=valX,valueY=valY)
}
C()
C(valX=5)
try(C(valX=-5))
C(valY=-3)
c1 <- C(valX=4,valY=-6)
as(c1,"A")

--- 8< --
> You're partly misunderstanding...
>
>   
Lol. I guess so, and unfortunatly, it is not over ...
> setClass("A", representation(x="numeric"),
> prototype=prototype(x=0))
>
>   
I do not understand the difference with

setClass("A", representation(x="numeric"),
prototype(x=0)
)


> If you have an initialize
> method on "A" then it will be called. 
Only if you call the A constructor, right ? Not if you set the slot that 
C has heritate from A one by one, right ?

Christophe

__
R-help@r-project.org 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] Sweave and extra line

2008-03-06 Thread Christophe Genolini
Hi the list,

I am using Sweave. Between the Sinput and the Soutput, there is always 
an extra line:

 > 2+2

[1] 4

Is it possible to remove it ?

 > 2+2
[1] 4

Thanks

Christophe

__
R-help@r-project.org 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] Sweave and the prompt

2008-03-06 Thread Christophe Genolini
Hi the list

I would also like to remove the prompt, in order to let the reader 
cut-and-paste from pdf to R. So I set the prompt to " " with

options(prompt=" ",continue=" ")

But it add an extrat space at the start of each line. I also try some code
options(prompt="\a",continue="\a")
After a big figth in my office (my college did not like my new prompt 
:-) ), I gave up since it does not let the user cut-and-paste either...

Is there any possibility to completly remove the prompt ?

Thanks

Christophe

__
R-help@r-project.org 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] Sealed for setGeneric

2008-03-13 Thread Christophe Genolini
Hi the list

When two setGeneric occurs on the same function, the second erage the 
first and erase all the function previously define.
Is it possible to prevent that ? Is it possible to declare a setGeneric 
that can not be erased later ?
Something like the |sealed for setMethod...|
||
|Thanks|
||
Christophe

__
R-help@r-project.org 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] Sealed for setGeneric

2008-03-13 Thread Christophe Genolini

> an unusual strategy would be to use lockBinding to make the symbol
> associated with the generic unchangeable.
>   
This sounds nice, thanks. Why is it unusual ? Any side effect or just 
the practice?

__
R-help@r-project.org 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] alias for a class

2008-03-14 Thread Christophe Genolini
Hi the list

Is it possible to give two names for a class ? One long name for using 
in programmation, and one short name for the "quick and durty" uses ?

With function, we can do

mcf <- myCoolFunction <- function(x)

With class, I define "clusterizedLongData", I want to use it with the 
full name when I am writing my code, but I would like something like cld 
when I make a demo, or when I try things on console... Is it possible ?

Thanks

Christophe

__
R-help@r-project.org 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] changing the quote

2008-03-15 Thread Christophe Genolini
Hi the list,

I am using R2.6.2. I don't now why, the quote used in the output of 
'new' seams not compatible with Sweave. Is there a way to change them ?
Is it something link with R, or link with my computer configuration ?

 > setClass("E",list(e="factor"))
[1] "E"
 > new("E")
An object of class “E”

Thanks

Christophe

__
R-help@r-project.org 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] empty array

2008-03-15 Thread Christophe Genolini
Hi the list

Is it possible to create an empty matrix ? I do not mean an matrix with 
a single value that is NA (which is not empty) but a real empty one, 
with length=0.

I do not understand why we have length(numeric()), length(factor()) and 
length(character()) to zero, and length(array()) to one... Any rason for 
that ?

Thanks

Christophe

__
R-help@r-project.org 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] empty array

2008-03-15 Thread Christophe Genolini
John Kane a écrit :
> Will
> mymatrix <- NULL do what you want?
>   
Well, in your code, 'mymatrix' is not a matrix :

a<-array(dim=c(0,0))  # Solution of Gabor Csardi
<0 x 0 matrix>
class(a)
[1] "matrix"
b<-NULL
class(b)
[1] "NULL"

Your definition will probably works in most case, but in S4, the uses of 
type is an important point, so I need to use matrix where I shall use 
matrix, even if it is an empty one.

Christophe

> --- Christophe Genolini <[EMAIL PROTECTED]> wrote:
>
>   
>> Hi the list
>>
>> Is it possible to create an empty matrix ? I do not
>> mean an matrix with 
>> a single value that is NA (which is not empty) but a
>> real empty one, 
>> with length=0.
>>
>> I do not understand why we have length(numeric()),
>> length(factor()) and 
>> length(character()) to zero, and length(array()) to
>> one... Any rason for 
>> that ?
>>
>> Thanks
>>
>> Christophe
>>
>> __
>> R-help@r-project.org 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.
>>
>> 
>
>
>
>   Be smarter than spam. See how smart SpamGuard is at giving junk email 
> the boot with the All-new Yahoo! Mail.  Click on Options in Mail and switch 
> to New Mail today or register for free at http://mail.yahoo.ca 
>
>

__
R-help@r-project.org 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] length of S4

2008-03-15 Thread Christophe Genolini
Hi the list,

With basic type, length gives the length of the vector
Wtih list, length gives the number of item
With S4 object, length gives...one. Even with an objet with empty slot.

setClass("E",representation(e="numeric"))
[1] "E"
 length(new("E"))
[1] 1
setClass("E",representation(e="matrix"))
[1] "E"
length(new("E"))
[1] 1

Is there a way to get the real length of an S4 objet ? Furthermore, is 
there a simple way to detect that an object is has all its slot to 
object of size zero ?

Thanks

Christophe

__
R-help@r-project.org 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] setAs vs setIs

2008-03-16 Thread Christophe Genolini
Hi the list

I am fighting with the twins setAs and setIs...

Here are some questions and comments (comments to myself but that migth 
be wrong, it is why I am posting them)
1. Very surprising : using setIs define 'is', 'as<-' but not 'as' ???
2. Using setAs define 'as', 'as<-' but not 'is'...
What surprise me is that as<- can be define by both. I would have thing 
that setis is for 'is', setAs is for 'as' and 'as<-'...
Since it is not the case, is there a possibility to set with only one 
function 'as', 'is' and 'as<-'

Last point, I get a warning using setAs. I did not manage to find the 
name of the variable it want me to use...

### Data
setClass("B",representation(b="numeric"))
setClass("C",representation(c="numeric"))
setClass("D",representation(d="numeric"))
b <- new("B",b=3)
c <- new("C",c=4)
d <- new("D",d=5)

### using setIs
setIs("C","B",
test=function(object){return([EMAIL PROTECTED]>0)},
replace=function(from,values){
[EMAIL PROTECTED] <- [EMAIL PROTECTED]
return(from)
}
)
is(c,"B") #Ok
as(c,"B") #not ok
as(c,"B") <- b#ok (!)

### using setAs
setAs("D","B",
function(from,to){to<-new("B",[EMAIL PROTECTED]);return(to)},
replace=function(from,values){
[EMAIL PROTECTED]<[EMAIL PROTECTED];
return(from)
}
)
is(d,"B") # not ok
as(d,"B") # ok
as(d,"B")<-b  # ok


Thanks

Christophe

__
R-help@r-project.org 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] setAs vs setIs

2008-03-17 Thread Christophe Genolini
I works, great !
So using your code, we can define 'as','as<-' and 'is' with setIt. Is 
there still any interest using setAs ?

Christophe
>
> It seems to me your problem here is simply that you did not define a 
> coerce cal in setIs, so it does not know how to turn a C object into a 
> B object, which is what you ask it to do here. It knows how to test if 
> C object is also a B object, because of the test function you 
> provided, and it can do the replacement you ask it in as(c,"B") <-b 
> because of the replace command you provided, but the third part is 
> missing. Perhaps something like this:
> setIs("C","B",
> test=function(object){return([EMAIL PROTECTED]>0)},
> replace=function(from,values){
> [EMAIL PROTECTED] <- [EMAIL PROTECTED]
> return(from)
> },
> coerce=function(from) {
> new("B",[EMAIL PROTECTED](1/3))
> }
> )

__
R-help@r-project.org 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] S4 : dumpMethod

2008-03-18 Thread Christophe Genolini
Hi the list,

I almost finished the green book (chapter 7 and 8 on S4), this is 
probably one of my last question :-)
I hope you will not miss them to much !

Here is my today nighmare: I do not manage to use dumpMethod :

setClass("A",representation(a="numeric"))
setMethod("plot","A",function(x,y,...){cat("A\n")})
dumpMethod("plot","A",file="")
#setMethod("plot", "A",
#NULL
#)
#[1] ""


Anything wrong in my code?

Christophe

__
R-help@r-project.org 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] legend at fixed distance form the bottom

2008-12-05 Thread Christophe Genolini

Hi the list

I would like to add a legend under a graph but at a fixed distance from 
the graphe. Is it possible ?

More precisely, here is my code :

--- 8< 
symboles <- c(3,4,5,6)
dn <- rbind(matrix(rnorm(20),,5),matrix(rnorm(20,2),,5))
listSymboles <- rep(symboles,each=2)
matplot(t(dn),pch=listSymboles,type="b")
legend("bottom", pch = unique(listSymboles), legend = c("ane", "cheval", 
"poney", "mule"), inset = c(0,-0.175), horiz = TRUE, xpd = NA)

--- 8< 

But when I change the size of the graph, the legend is misplaced.

Instead, I try to put some text in xlab, but I do not know how to get 
the +, x , V and other symbol.

Does anyone got a solution ?

Thanks a lot.

Christophe

__
R-help@r-project.org 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] legend at fixed distance form the bottom

2008-12-06 Thread Christophe Genolini

Thanks for your answer.

Unfortunatly, I can not create the graphice with the final size since I 
am writing a package in wich the user will have to chose between several 
graphics, and then he will have to export one. And they might be one 
graph, or 2x2, or 3x3...


I check the grconvertY but I did not understand what you suggest. To me, 
the use of legend can not work since every length in the legend box 
(xlength, ylength, distance to axes) will change when resizing the 
graph. I was more expecting something like introduce the symbols used in 
the graph *in* the xlab. Is it possible ?


Christophe


It is best to create the graphics device at the final size desired, then do the 
plotting and add the legend.  For getting a fixed distance, look at the 
function grconvertY for one possibility.

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[EMAIL PROTECTED]
801.408.8111


  

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
project.org] On Behalf Of Christophe Genolini
Sent: Friday, December 05, 2008 6:40 AM
To: r-help@r-project.org
Subject: [R] legend at fixed distance form the bottom

Hi the list

I would like to add a legend under a graph but at a fixed distance from
the graphe. Is it possible ?
More precisely, here is my code :

--- 8< 
symboles <- c(3,4,5,6)
dn <- rbind(matrix(rnorm(20),,5),matrix(rnorm(20,2),,5))
listSymboles <- rep(symboles,each=2)
matplot(t(dn),pch=listSymboles,type="b")
legend("bottom", pch = unique(listSymboles), legend = c("ane",
"cheval",
"poney", "mule"), inset = c(0,-0.175), horiz = TRUE, xpd = NA)
--- 8< 

But when I change the size of the graph, the legend is misplaced.

Instead, I try to put some text in xlab, but I do not know how to get
the +, x , V and other symbol.
Does anyone got a solution ?

Thanks a lot.

Christophe

__
R-help@r-project.org 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@r-project.org 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] legend at fixed distance form the bottom

2008-12-06 Thread Christophe Genolini

Thanks to answering me Gabor

I am not sur I understand : I had your line to my graph. Then I resize 
my graph but the legend is still moving. In "inset = c(0,1.1)",
1.1 means "110% of the y length of the plot region". So when the plot 
region change, the distance between the legend and the top axe is sitll 
110%, that means that the distance between the legend and the bottom axe 
is 10%...


Christophe



inset= is measured from the margin so the trick is to inset it relative to the
top even if you want it at the bottom:

legend("top", pch = unique(listSymboles), legend = c("ane", "cheval",
"poney", "mule"),
  inset = c(0,1.1), horiz = TRUE, xpd = NA)

On Fri, Dec 5, 2008 at 8:39 AM, Christophe Genolini
<[EMAIL PROTECTED]> wrote:
  

Hi the list

I would like to add a legend under a graph but at a fixed distance from the
graphe. Is it possible ?
More precisely, here is my code :

--- 8< 
symboles <- c(3,4,5,6)
dn <- rbind(matrix(rnorm(20),,5),matrix(rnorm(20,2),,5))
listSymboles <- rep(symboles,each=2)
matplot(t(dn),pch=listSymboles,type="b")
legend("bottom", pch = unique(listSymboles), legend = c("ane", "cheval",
"poney", "mule"), inset = c(0,-0.175), horiz = TRUE, xpd = NA)
--- 8< 

But when I change the size of the graph, the legend is misplaced.

Instead, I try to put some text in xlab, but I do not know how to get the +,
x , V and other symbol.
Does anyone got a solution ?

Thanks a lot.

Christophe

__
R-help@r-project.org 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@r-project.org 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] legend at fixed distance form the bottom

2008-12-06 Thread Christophe Genolini

Lol.
To me, a "fixed amount" that depends on the size of the graph is not 
much fixed...


--- 8< ---

symboles <- c(3,4,5,6)
dn <- rbind(matrix(rnorm(20),,5),matrix(rnorm(20,2),,5))
listSymboles <- rep(symboles,each=2)

layout(matrix(c(1,1,1,2,2,3),3))
for(i in 1:3){
 plot(dn)
 legend("top", pch = unique(listSymboles), legend = c("a", "b","c","d"),inset = 
c(0,1.1), horiz = TRUE, xpd = NA)
}

--- 8< ---
On this example, it is easy to see that index is at a fixed distance 
from the bottom but that Legend is at a distance "porportional"




I would like to add a legend under a graph but at a fixed distance from the 
graphe"



The top of the legend is always a fixed amount below the graph (which is
what you asked for).




__
R-help@r-project.org 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.


  1   2   >