Conditional ploting with logical vector

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Conditional ploting with logical vector

Armin Goralczyk
Hi list
Maybe someone can help with the following problem (thanks in advance):

In a function I have a plot and want to add symbols/text only when
indicated by a logical vector (which was generated by the function
before, not manually like in the following example):

plot(1:10, 1:10)
lv <- c(T,T,T,F,F,F,T,T,T,F)
text(1:10, 1:10, '*', pos = 3)

In this example the asterisk is plotted at every yx-coordinate
indicated. How Can I make it appear only when 'TRUE' in the lv?

Another (statistical) question:
Actually this function generates significance levels to the plot at 10
time points of a time series by comparing the values at the single
time points by a t-test. I know this is probably not the correct way
to compare the whole series, but I have to do it this way
('constraints'). The question is: do I have to adjust for multiple
testing by e.g. Bonferroni correction?


--
Armin Goralczyk, M.D.
--
Universitätsmedizin Göttingen
Abteilung Allgemein- und Viszeralchirurgie
Rudolf-Koch-Str. 40
39099 Göttingen
--
Dept. of General Surgery
University of Göttingen
Göttingen, Germany
--
http://www.gwdg.de/~agoralc
______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Conditional ploting with logical vector

Kenneth Knoblauch
Armin Goralczyk <agoralczyk <at> gmail.com> writes:

> In a function I have a plot and want to add symbols/text only when
> indicated by a logical vector (which was generated by the function
> before, not manually like in the following example):
>
> plot(1:10, 1:10)
> lv <- c(T,T,T,F,F,F,T,T,T,F)
> text(1:10, 1:10, '*', pos = 3)
>
> In this example the asterisk is plotted at every yx-coordinate
> indicated. How Can I make it appear only when 'TRUE' in the lv?
Maybe, someone has a more elegant solution, but this
works,

plot(1:10, 1:10)
lv <- c(T,T,T,F,F,F,T,T,T,F)
lv2 <- ifelse(lv, TRUE, NA)
text(1:10, (1:10) * lv2, '*', pos = 3)

HTH

ken

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Conditional ploting with logical vector

Jim Lemon
In reply to this post by Armin Goralczyk
Armin Goralczyk wrote:

> Hi list
> Maybe someone can help with the following problem (thanks in advance):
>
> In a function I have a plot and want to add symbols/text only when
> indicated by a logical vector (which was generated by the function
> before, not manually like in the following example):
>
> plot(1:10, 1:10)
> lv <- c(T,T,T,F,F,F,T,T,T,F)
> text(1:10, 1:10, '*', pos = 3)
>
> In this example the asterisk is plotted at every yx-coordinate
> indicated. How Can I make it appear only when 'TRUE' in the lv?
>
cond.astrx<-ifelse(lv,"*",NA)
text(1:10, 1:10,cond.astrx, pos = 3)

> Another (statistical) question:
> Actually this function generates significance levels to the plot at 10
> time points of a time series by comparing the values at the single
> time points by a t-test. I know this is probably not the correct way
> to compare the whole series, but I have to do it this way
> ('constraints'). The question is: do I have to adjust for multiple
> testing by e.g. Bonferroni correction?
>
>
I vote yes.

Jim

______________________________________________
[hidden email] 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.