draw x-y plot using the ggplot package where the size of the scatter is by size of column z in r in r

main.r
# assuming a dataframe named `df` with columns `x`, `y`, and `z`

library(ggplot2)

ggplot(data = df, aes(x = x, y = y)) +
  geom_point(aes(size = z)) 
152 chars
7 lines

The ggplot() function initializes the ggplot object, and specifies the dataset df and the aesthetic mappings defined inside aes(). The function geom_point() creates the scatter plot, and the size aesthetic specifies the column z for which the point sizes should be proportional.

This code will create a scatter plot with the x values on the x-axis, y values on the y-axis and the size of the points represented by the values in column z.

gistlibby LogSnag