as.data.frame.curve: Conversion to data frame

View source: R/cspline.R

as.data.frame.curveR Documentation

Conversion to data frame

Description

Method function to convert an object inheriting from class "curve" to a data.frame

Usage

## S3 method for class 'curve'
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

Arguments

x

An object inheriting from class "curve"

row.names, optional, ...

as for as.data.frame.

Value

A data frame object

Examples

library(ggplot2)
set.seed(1234)
z <- complex(real = runif(5), imaginary = runif(5))
z <- z[order(Arg(z - mean(z)))]
cz <- closed_curve(z)
oz <- open_curve(z)
ggplot() + geom_path(data = as.data.frame(cz), aes(x,y), colour = "#DF536B") +
    geom_path(data = as.data.frame(oz), aes(x,y), colour = "#2297E6") +
    geom_point(data = as.data.frame(z), aes(x = Re(z), y = Im(z))) +
    geom_segment(data = as.data.frame(z), aes(x = Re(mean(z)),
                                              y = Im(mean(z)),
                                              xend = Re(z),
                                              yend = Im(z)),
                 arrow = arrow(angle=15, length=unit(0.125, "inches")),
                 colour = alpha("grey", 1/2)) +
    theme_bw()


frenchCurve documentation built on June 18, 2022, 9:05 a.m.