In [ ]:
num = 200
# Create a normal variable
a = 1:num
b = rnorm(num,6)
# Another vector, by mixing from two random variables
c1 = c( rnorm(num/2,5,3), rnorm(num/2,9,4) )
c2 = as.factor( c( rep('A',num/2), rep('B',num/2) ) )
c = data.frame( dvalue2=c1, vtype=c2 )
c = c[ sample(num), ]
In [ ]:
summary(c)
In [ ]:
exdf = data.frame( dnum=a, dvalue1=b )
exdf <- cbind( exdf, c )
In [ ]:
class(exdf)
In [ ]:
head(exdf)
In [ ]:
summary(exdf)
In [ ]:
# Load the ggplot graphics library
library('ggplot2')
# A density plot
qplot( dvalue1, data=exdf, geom="density" )
In [ ]:
# Change default plot size (values in inches)
options(repr.plot.width = 10, repr.plot.height = 5)
# A scatterplot, discriminating by the factor in the 'vtype' column
qplot( dvalue1, dvalue2, color=vtype, data=exdf )
In [ ]:
?Lognormal