Hello,
I wanted to make a plot that would consist of x= to gender and y= consisting of all the years (4 columns putted together)
I tired to to it by making an y=sum(a$00,a$01, etc) but it didn't work out.
Could someone help me with this please
Hello,
I wanted to make a plot that would consist of x= to gender and y= consisting of all the years (4 columns putted together)
I tired to to it by making an y=sum(a$00,a$01, etc) but it didn't work out.
Could someone help me with this please
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!
Hi Karina,
I second what @kmprioli said, above. One more tip: if you edit your question title to make it more informative, it will help get more eyes on your question!
Mara