Check the size of df_both. It would be that there are no Command fields
that contain both a 't1' and 't2'.
You can so do:
sum(grepl("t1", df$Command) & grepl("t2", df$Command))
to see how many Command fields contain both.
Jim Holtman
Data Munger Guru
What is the problem that you are trying t
now after this:
df_both <- subset(df, grepl("t1", Command) & grepl("t2", Command))
I use factor to apply the subset to df but then the Command level becomes 0
df_both$Command=factor(df_both$Command)
str(df_both)
$ Protocol : Factor w/ 0 levels:
Do you know what is the r
'grepl' returns a logical vector; you have to use this to get your subset.
You can use:
df_tq <- subset(df, grepl("t1", Command))
df_t2 <- subset(df, grepl("t2", Command))
# if you want to also get a subset that has both, use
df_both <- subset(df, grepl("t1", Command) & grepl("t2", Command))
my problem is that in Command I have 2229 levels and I want to do subsets based
on the names I have in Command. for example if the name has t1 or t2 in it or
if it has both of them.and then I need to plot in a way that colors are names
with t1,names with t2 and names with both. But now even t
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:
library(dplyr)
your_subset <- df %>%
mutate(key = grep(".*(t1|t2).*", "\\1", Command, value = TRUE))
%>%
filter(!(
Hi
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
6 matches
Mail list logo