Message-ID: <97c3c207-ed2e-95df-5c9a-1f01598bb92b@sapo.pt>
Date: 2020-10-21T14:24:22Z
From: Rui Barradas
Subject: AES spesification
In-Reply-To: <CAMUSX8qUddfST1j-66XapFaGb0XKHUEZgOxsNO=9eF01fWcxjg@mail.gmail.com>
Hello,
You can subset the data argument.
And if you are plotting one year only, there's no point in color = year.
ggplot(subset(mpg, year == 1999), aes(displ, hwy)) +
geom_point()
If you are loading package dplyr, you can filter directly to ggplot:
library(dplyr)
mpg %>%
filter(year == 1999) %>%
ggplot(aes(displ, hwy)) +
geom_point()
Hope this helps,
Rui Barradas
?s 14:37 de 21/10/20, Engin Y?lmaz escreveu:
> Dear
>
> I use dataset , as called "mpg"
>
> This is code
>
> ggplot(data=mpg)+ geom_point(mapping = aes(x=displ, y=hwy, colour=year))
>
> But I would like to see only "year of 1999" in this relationship between x
> and y variables
>
> How could I change the code in this direction?
>
> I found the following code
>
> library(dplyr)year_1999 <- filter(mpg, year=="1999")ggplot(year_1999,
> aes(x=displ, y=hwy)) + geom_point()
>
>
> I found other code
>
> ggplot(data = mpg, mapping = aes(x = displ, y = hwy)) +
>
> geom_point(
>
> data = filter(mpg, year == "1999")
>
> )
>
>
> Is there more compact code ?
>
>
> sincerely
> Engin YILMAZ
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>