R language Access Menu

Title Text Both  

Multiple variable plot

Different variables can be shown on a single plot using options of 
•    color
•    shape
•    size
•    facets

For example, 7 variables of bwdf are shown in following single graph: 
    > bwdf$ht2 = with(bwdf, ifelse(ht==0, 'ht_0', 'ht_1'))
    > bwdf$ui2 = with(bwdf, ifelse(ui==0, 'ui_0', 'ui_1'))
    > ggplot(bwdf, aes(age, lwt, col=race, shape=low, size=ptl))+ facet_grid(ht2~ui2)+ geom_point()

Output graph:


New variables ht2 and ui2 variables are created to clearly depict them clearly on the graph


    Comments & Feedback