Re: [R] tcl/tk problem with tklistbox,the " " character and Rcmdr.

2012-11-20 Thread Yves Reecht
Hi Vincent,

This is probably because Rcmdr redefine the tclvalue command (check the 
message frame of the Rcmdr window).
You can try:

tcltk::tclvalue(tkget(levels.list2,"4"))

HTH,
Yves


Le 20/11/2012 11:25, vincent guyader a écrit :
> I everyone,
>
> i have a little problem with tklistbox,the " " character and Rcmdr.
>
> Please look at this code
>
> require(tcltk)
> tt<-tktoplevel()
> levels.list2 <-tklistbox(tt,selectmode="multiple",exportselection="FALSE",
> height=4, yscrollcommand=function(...)tkset(levels.list2.scroll,...))
> levels.list2.scroll<-tkscrollbar(tt,repeatinterval=5,command=function(...)tkyview(levels.list2,...))
>
> tkgrid(levels.list2,levels.list2.scroll)
>
> vec<-c("a","b",""," ","   ")
> tkdelete(levels.list2,"0","end")
> for (var in vec) {tkinsert(levels.list2, "end", var)}
>
>
>
> tclvalue(tkget(levels.list2,"0"))# a
> tclvalue(tkget(levels.list2,"1"))# b
> tclvalue(tkget(levels.list2,"2"))# ""
> tclvalue(tkget(levels.list2,"3"))# " "   it's ok
> tclvalue(tkget(levels.list2,"4"))# "  "  it's ok
>
>
> library(Rcmdr)
> #same command :
> tclvalue(tkget(levels.list2,"0"))# a
> tclvalue(tkget(levels.list2,"1"))# b
> tclvalue(tkget(levels.list2,"2"))# ""
> tclvalue(tkget(levels.list2,"3"))# ""   instead of " "
> tclvalue(tkget(levels.list2,"4"))# ""  instead of "  "
>
>
> it's crazy!?
> any idea
>
> Thank you
>
>   [[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.


[[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] Expression: +/-sigma

2011-07-27 Thread Yves REECHT
  Hi,

You may try something like:

plot(rnorm(10), rnorm(10), main=expression("" %+-% 2*sigma))

HTH,
Yves

Le 27/07/2011 14:57, ogbos okike a écrit :
> Dear List,
> I am trying to label a plot with the symbol +/- sigma. Using something like
> - expression (2*sigma) gives me the symbol 2ó. However, adding +/- to it
> beats me.
> The code I am using is:  plot(x,y,type="l",main=" expression(paste("±",
> plain(2*ó)),sep="").
> Any suggestion will be appreciated.
> Best
> Ogbos
>
>   [[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.

[[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] Console output

2011-02-21 Thread Yves REECHT
  Hi,

You may try

invisible(sapply(1:10, print))

Yves


Le 21/02/2011 11:21, Antje Niederlein a écrit :
> Hi there,
>
> I though there has been a possibility to force the output on the
> console with one element per line. Instead of this:
>
>> 1:10
>   [1]  1  2  3  4  5  6  7  8  9 10
>
> something like this
>
>> 1:10
> [1]   1
> [2]   2
> [3]   3
> [4]   4
> [5]   5
> [6]   6
> [7]   7
> [8]   8
> [9]   9
> [10]   10
>
> Can anybody help?
>
> Antje
>
> __
> 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.


Re: [R] How to compute "yaxp" and "usr" without plotting ?

2011-02-15 Thread Yves REECHT
  Thank you very much Greg,

This was helpful.
With yaxs="r" I can easily obtain the Y-axis labels with :

rg <- range(y) + 0.04 * diff(range(y)) * c(-1, 1)
pt <- pretty(y)

axTicks(side=2,
 usr=c(0, 1, rg),
 axp=c(min(pt),
   max(pt[pt <= max(rg)]),
   length(pt[pt <= max(rg)]) - 1))

*y* being either the values to plot or the ylim parameter.

Your remark on the use of strwidth is absolutely true. Thus I'll simply 
assess linear parameters to get correct mgp values as a function of 
maximum character numbers within the axis labels, using standard font size.

All the best,
Yves

Le 12/02/2011 00:56, Greg Snow a écrit :
> The usr parameter is either ylim or ylim plus 4 percent on either side (see 
> yaxs/xaxs), see the pretty function for possible ways to get the yaxp 
> information.  Note that strwidth is based on the current coordinate system 
> and will not give you the proper values unless the plot region has already 
> been set up.
>

[[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 to compute "yaxp" and "usr" without plotting ?

2011-02-11 Thread Yves REECHT
  Dear all,

I'd like to know how I could compute the parameters "yaxp" and (the y 
components of) "usr" without having to plot the data first. Note that 
"ylim" is /a priori/ fixed.

The aim is to automatically adjust the parameter "mgp" without having to 
make the plot twice. Then, with "yaxp" and "usr" known, it should be 
easy to calculate a suitable "mgp" with the axTicks and strwidth functions.

Many thanks in advance,
Yves

[[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] force apply not to drop the dimensions of FUN results ?

2010-11-10 Thread Yves . Reecht

Thank you very much Claudia,

That (the first form) works perfectly.
Easily made generic using head and tail on the dim attribute.

All the best,
Yves


Claudia Beleites  a écrit :


Dear Yves,

You may not need to do more than set the dim attribute correctly:

dim (test) <- c (dim (myArray) [c (3 : 4, 1 : 2)]
or
dim (test) <- c (dim (myArray) [c (4 : 3, 1 : 2)]

Claudia


--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Università degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste

phone: +39 0 40 5 58-37 68
email: cbelei...@units.it



__
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] force apply not to drop the dimensions of FUN results ?

2010-11-10 Thread Yves REECHT
  Dear R users,

Here is my problem:

I have an array with at least four dimensions:

 > dim(myArray)
[1] 20 17  3  6

I'd like to apply a function to each occurrence of the matrix (3x6) 
defined by the last two dimensions. This interpolation function always 
return a matrix of the same dimensions as its argument:

 > interpSecteurs.f(myArray[1, 1, , ])
 secteur
rotation 1 2  3 4 5 6
1 3  5.25 10 6 6 3
2 3 10.00 10 7 7 3
3 3  0.50 10 8 8 3

But when applying this function with apply, these matrices are coerced 
in vectors of length 18:

 > test <- apply(myArray,
+   c(1, 2),
+   interpSecteurs.f)
 > dim(test)
[1] 18 20 17

I read in the help that this is the normal behaviour in apply.
However, I really need to keep the same dimension as the input data.

Do you know any function or method which allows bypassing this behaviour ?
(unfortunately my function seems not suitable for a vectorization using 
sweep)

Alternatively, a method to recover the wished array dimensions afterward 
would be also acceptable.

Many thanks in advance.
Yves

-- 
-------
  Yves REECHT

   Dpt STH (Sciences et Technologies Halieutiques)
   IFREMER, BP 70
   29280 PLOUZANE
   FRANCE

   tel. +33 (0)2 98 22 43 69
--)><°>


[[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] calculate area between intersecting polygons

2010-10-26 Thread Yves Reecht
Dear Jonas,

I already had to deal with such an issue.
Your can use the joinPolys function from the package PBSmapping, with "INT"
as operation.

The maptools package has functions SpatialPolygons2PolySet and
PolySet2SpatialPolygons to switch between formats suitable for sp or
PBSmapping.

Hope this helps.
Yves


On 26 October 2010 10:18, jonas garcia wrote:

> Thanks for your reply,
>
> My main issue is that I don't have any equations to generate the data, just
> a bunch of points, each corresponding to a polygon.
>
> I was looking in package "sp" and there is a function to calculate areas (
> areapl()), but not for intersecting polygons. Is there any other package
> that does this?
> Thanks
> On Tue, Oct 26, 2010 at 3:38 AM, Remko Duursma  >wrote:
>
> >
> > Dear Jonas,
> >
> > if you can write the difference in y-values between your polygons as a
> > function, you can use
> > integrate() to get the area between the polygons.
> >
> > It sounds like perhaps your x-values will not match between the polygons
> > because they come from different sources, so you probably have to do some
> > interpolating (with ?approx).
> >
> >
> > hope that helps,
> > Remko
> > --
> > View this message in context:
> >
> http://r.789695.n4.nabble.com/calculate-area-between-intersecting-polygons-tp3012980p3013059.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<
> 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.
>

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