ggplot2.lineplot: Easy line plot plot with R package ggplot2

Description Usage Arguments Value Author(s) References See Also Examples

View source: R/ggplot2.lineplot.R

Description

Draw a line plot using ggplot2

Usage

1
2
3
4
ggplot2.lineplot(data, xName, yName, groupName = NULL, addPoint = FALSE,
  pointSize = 1.5, pointShape = 19, pointFill = NULL,
  pointColor = "black", arrow = NULL, xAxisType = c("categorical",
  "continuous"), groupColors = NULL, brewerPalette = NULL, ...)

Arguments

data

data.frame or a numeric vector. Columns are variables and rows are observations.

xName

The name of column containing x variable (i.e groups).

yName

The name of column containing y variable.

groupName

The name of column containing group variable. This variable is used to color plot according to the group.

addPoint

If TRUE, points are added to the plot. Default value is FALSE.

pointSize, pointShape, pointFill, pointColor

Modify point size, shape, fill and color.

arrow

arrow is function from package grid. This function Describe arrows to add to a line. See ?grid::arrow for more details. Usage : arrow=arrow(). Default value is NULL.

xAxisType

Indicate the type of x-axis. Possible values =c("categorical", "continuous"). Default value is "categorical". When the variable on the x-axis is numeric, it is sometimes useful to treat it as continuous, and sometimes useful to treat it as categorical.

groupColors

Color of groups. groupColors should have the same length as groups.

brewerPalette

This can be also used to indicate group colors. In this case the parameter groupColors should be NULL. e.g: brewerPalette="Paired".

...

Other arguments passed on to ggplot2.customize custom function or to geom_line functions from ggplot2 package.

Value

a ggplot

Author(s)

Alboukadel Kassambara <alboukadel.kassambara@gmail.com>

References

http://www.sthda.com

See Also

ggplot2.barplot

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#data
df <- data.frame(time = factor(c("Lunch","Dinner"), levels=c("Lunch","Dinner")),
                 total_bill = c(14.89, 17.23))

#plot
ggplot2.lineplot(data=df, xName="time", yName='total_bill',
                mainTitle="Plot of total bill\n per time of day",
                xtitle="Time of day", ytitle="Total bill")

#Or use this
plot<-ggplot2.lineplot(data=df, xName="time", yName='total_bill')
plot<-ggplot2.customize(plot,  mainTitle="Plot of total bill\n per time of day",
                      xtitle="Time of day", ytitle="Total bill")
print(plot)

kassambara/easyGgplot2 documentation built on May 20, 2019, 7:39 a.m.