Home > Blockchain >  Adding operator into a string (R)
Adding operator into a string (R)

Time:02-03

for a plot in R, I am using facet_wrap and I want to change the labeling of each facet using a function to give to "labeller". Since one of my facet tiles should be a string of this type: V_>1 (with ">1" as a subscript of V), I have used this "V[>1]" but it generates an error:

Error in parse(text = as.character(values)) : <text>:1:3: unexpected '>'1: V[>

I have also tried with "V[>1]", but this doesn't work too. Can you give me any suggestions?


As an example, we can use the iris dataframe and try to rename the facets:

my_labeller <- as_labeller(c(setosa="A[0]", versicolor="B^1", virginica="Gamma"),default = label_parsed)
ggplot(iris)  
  geom_bar(aes(x=Sepal.Length))  
  facet_wrap(~Species, labeller = my_labeller)

which produces this image:

enter image description here

  •  Tags:  
  • Related