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