Learn R Programming

figuRes2 (version 1.0.0)

gcurve: gcurve

Description

A function to exploit base R's curve function. This returns a data.frame holding x and y values returned from a call to curve, but suppress the plotting of that function

Usage

gcurve(
  expr,
  from = NULL,
  to = NULL,
  n = 101,
  add = FALSE,
  type = "l",
  xname = "x",
  xlab = xname,
  ylab = NULL,
  log = NULL,
  xlim = NULL,
  category = NULL,
  ...
)

Value

A data.frame is returned. Columns include x, y, and optionally category.

Arguments

expr

inherited from curve

from

inherited from curve

to

the range over which the function will be plotted.

n

inherited from curve

add

inherited from curve

type

inherited from curve

xname

inherited from curve

xlab

inherited from curve

ylab

inherited from curve

log

inherited from curve

xlim

inherited from curve

category

option to add a column populated with a factor (by gcurve)

...

inherited from curve

Author

Greg Cicconetti

See Also

graphics::curve

Examples

Run this code
{
require(ggplot2)
curve(dnorm(x, mean=0, sd=1), from=-4, to = 4, n= 1001)
ggplot(gcurve(expr = dnorm(x, mean=0, sd=1),from=-4, to = 4, n= 1001,
category= "Standard Normal"), aes(x=x, y=y)) + geom_line()
}

Run the code above in your browser using DataLab