Hi Karina - welcome to RStudio Community! It's hard to see from your screenshot what the variables of interest look like.
To help you get the right help for your question, can you please turn it into a reprex (reproducible example)? This will ensure we're all looking at the same data and code. A guide for creating a reprex can be found here.
For plotting, I'd recommend using ggplot2
, which is part of the tidyverse
set of packages. You will need to install tidyverse
via install.packages("tidyverse")
. Then, assuming you wanted to plot FY00Giving
against Gender
for type = "p"
, syntax would be something like the following:
library(tidyverse)
a_df <- a %>% filter(type == "p")
plot1 <- ggplot(data = a_df, aes(x = Gender, y = FY02Giving)) + geom_point()
plot1
This ignores the parts of your syntax pertaining to FY00Giving:
because it's unclear to me what you're attempting to do. Are you trying to pull in multiple years of data and plot against gender
? If this is the case, you'll want to use gather()
to reshape your data from wide to long format.
I hope this is enough to get you started in the right direction!