sinc = function(x) {

return(sin(pi * x) / (pi * x))

}

curve(sinc, -7, +7, main = "Using curve")

s = sort.int(mpg$cty, index.return = T)

plot(s$x,

main = "Using plot",

type = "l",

lty = 2,

xlab = "sample number (sorted by city mpg)",

ylab = "mpg")

lines(mpg$hwy[S$ix] ,lty = 1)

legend("topleft", c("highway mpg", "city mpg"), lty = c(1, 2))

x = seq(-2, 2, length.out = 30)

y = x ^ 2

qplot(x, y, geom = "line", main = "Using qplot")

qplot(x, y, geom = c("point", "line"))

x = seq(-2, 2, length.out = 30)

y = x ^ 2

dataframe = data.frame(x = x, y = y)

ggplot(dataframe, aes(x = x, y = y)) + geom_line() + geom_point() +

ggtitle("Using ggplot")