Skip to content

Scatter Plot Command Syntax Using Data.Frame Source

1 message · Baptiste Auguie

#
Hi,

Below are a couple of options using a standard dataset,

str(iris)

## using base graphics
d <- split(iris, iris$Species)
str(d) # list of 3 data.frames

par(mfrow=n2mfrow(length(d))) # split the device in 3 plotting regions
b.quiet <- lapply(names(d), function(x) { # loop over the list names
  with(d[[x]], plot(Sepal.Length, Petal.Length))
  title(x)
})

library(ggplot2)
# using facetting
ggplot(iris) + facet_wrap(~Species) +
  geom_point(aes(Sepal.Length, Petal.Length))

library(lattice)
# using facetting
xyplot(Petal.Length ~ Sepal.Length | Species, data=iris )

HTH,

baptiste
On 1 September 2011 08:50, Rich Shepard <rshepard at appl-ecosys.com> wrote: