Grokbase Groups R r-help April 2016
You never did provide a reproducible example or say how you wanted to
plot. Here is a way to get a subset of t1 or t2, and you can then use it
as input to ggplot:

your_subset <- df %>%
           mutate(key = grep(".*(t1|t2).*", "\\1", Command, value = TRUE))
           filter(!(Command %in% c('t1', 't2')))

This will give you a subset with just t1/t2 and you can use 'key' as the
colour option for ggplot.

Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.

On Sat, Apr 23, 2016 at 4:16 PM, ch.elahe via R-help wrote:

I have the following df and I created two subsets but I don't know how to
use these subsets as the colors of my plot.

data.frame': 36919 obs. of 162 variables
$TE :int 38,41,11,52,48,75,.....
$TR :int 100,210,548,546,.....
$Command :factor W/2229 levels

and the subsets are names in Command which has t1 or t2 letters:

hast1=grepl("t1", df$Command, fixed=TRUE)
hast2=grepl("t2", df$Command, fixed=TRUE)

the colors I want in my plot are : hast1 and hast2
Thanks for any help.

R-help at mailing list -- To UNSUBSCRIBE and more, see
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.

  [[alternative HTML version deleted]]

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 6 | next ›
Discussion Overview
groupr-help @
postedApr 23, '16 at 8:16p
activeApr 25, '16 at 12:50a

2 users in discussion

Chalabi Elahe: 3 posts Jim holtman: 3 posts



site design / logo © 2018 Grokbase