简体   繁体   中英

In R, How can I compare two continuous variables and indicating two categorical variables in a chart

For example, lets say I want a plot that compares cost and score of two age groups, and the plot should also indicate their gender.

What plot can I use and how can each attribute be distinguished?

You could use ggplot2 .

Eg using the mtcars data:

ggplot(mtcars, aes(x = hp, y = mpg, shape = factor(vs), size = cyl)) + geom_point()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM