simplePlot: Simple Plot of 2 columns (Plot)

Description Usage Arguments See Also Examples

View source: R/Plots.R

Description

Generate a plot of 2 columns of data set using ggplot. You must indicate which columns you want in the graph.

Usage

1
2
simplePlot(data, DependentVariable, x_axis, y_axis, dependentVariableName,
  pointSize, alphaPoint, colours)

Arguments

data

an object of class data frame with the data.

DependentVariable

an object of class "numeric", "factor" or "integer" is a list of values containig the dependent variable.

x_axis

an integer that represent the number of the column that you want in your x axis.

y_axis

an integer that represent the number of the column that you want in your y axis.

dependentVariableName

is an optional parameter. It's an string that contains the name of your dependent variable.

pointSize

is an optional parameter of class numeric with a single value that represent the point size of plot.

alphaPoint

is an optional parameter of class numeric with a single value that represent the alpha of points in the plot.

colours

is an optional parameter of class character with a list of colours to use in the plot. The default value for continuos dependent variable is c("darkred", "yellow", "darkgreen") and for categorical dependent variable are the default colours defined by ggplot.

See Also

elbowPlot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#Example 1
iris.x <- iris[,1:4] # These are the independent variables
Species <- iris[,5] # This is the dependent variable

# Plot of first 2 columns of data set
simplePlot(iris.x, Species, 1, 2, "Species", 2, 0.9)
# A plot with a different colours palette
myPalette <- c("darkolivegreen4", "goldenrod1", "dodgerblue4")
simplePlot(iris.x, Species, 1, 2, "Species", 2, 0.9, colours = myPalette)


#Example 2
iris.x <- iris[,1:4] # These are the independent variables
Species <- iris[,5] # This is the dependent variable

ir.pca <- prcomp(iris.x, center = TRUE, scale. = TRUE) #performing prcomp

# Plot of first 2 columns of principal components
simplePlot(as.data.frame(ir.pca$x), Species, 1, 2, "Species", 2, 0.9)
# A plot with a different colours palette
myPalette <- c("darkolivegreen4", "goldenrod1", "dodgerblue4")
simplePlot(as.data.frame(ir.pca$x), Species, 1, 2, "Species", 2, 0.9, colours = myPalette)


#Example 3
# Getting a clean data set (without missing values)
cars <- read.csv("https://dl.dropboxusercontent.com/u/12599702/autosclean.csv", sep = ";", dec = ",")
cars.x <- cars[,1:16] # These are the independent variables
cars.y <- cars[,17] # This is the dependent variable

cars.pca <- prcomp(cars.x, center = TRUE, scale. = TRUE) #performing prcomp

# Plot of first 2 columns of principal components
simplePlot(as.data.frame(cars.pca$x), cars.y, 1, 2, "Price", 2, 0.9)
# A plot with a different colours palette
myPalette <- c("darkolivegreen4", "goldenrod1", "dodgerblue4")
simplePlot(as.data.frame(cars.pca$x), cars.y, 1, 2, "Price", 2, 0.9, colours = myPalette)

mariytu/RegressionLibs documentation built on May 21, 2019, 11:47 a.m.