In [1]:
# Criando funções
myfunc <- function(x) { x + x }
myfunc(10)
class(myfunc)
Out[1]:
Out[1]:
In [2]:
# Definindo os dados
dados = cars$speed
# Construindo um histograma
hist(dados)
In [3]:
# Construção do boxplot
attach(sleep)
sleepboxplot = boxplot(data = sleep, extra ~ group,
main = "Duração do Sono",
col.main = "red")
In [4]:
# Usando o ggplot2
library(ggplot2)
ggplot(data = mtcars,
aes(x = disp, y = mpg,
colour = as.factor(am))) + geom_point()
In [5]:
# Usando o lattice
library(lattice)
xyplot(data = iris, groups = Species, Sepal.Length ~ Petal.Length)