say for example i'm using the iris data-set as you illustrated above. i want to plot the sepal.width vs sepal.length with respect to the species column. But instead of color coding each species on the plot, i want the plot to display only the data from the setosa species alone
for me to plot it by color it would be
ggplot(iris, aes(x=sepal.length, y= sepal.width), col= species )+ geom_point()
but in my case i want to draw a specific specie from the species column. what i have tried was:
ggplot(iris, aes(x=sepal.length[species=="setosa], y= sepal.width[species=="setosa]))+ geom_point()
after running the code, it produces the error:
Error: Must subset columns with a valid subscript vector.
i Logical subscripts must match the size of the indexed input.
x Input has size 12 but subscript gender == "male" has size 1296.
Run rlang::last_error() to see where the error occurred
in my case,"gender" and "male" represents the variable and subset category similar to"species" and "setosa" in the iris dataframe