Learn R Programming

funcy (version 1.0.1)

plotFuncy: Plot functional data.

Description

Plot functional data, color curves according to cluster labels and add center curves.

Usage

# S4 method for matrix
plotFuncy(data, regTime=NULL, col=NULL,
          ctr=NULL, ctrOnly=FALSE, ctrCols=NULL, showLegend=TRUE,
          legendPlace="bottomleft", lty=3, lwd=NULL, xlim=NULL,
ylim=NULL, xlab=NULL, ylab=NULL, …)

# S4 method for sampleFuncy plotFuncy(data, regTime=NULL, col=NULL, ctr=NULL, ctrOnly=FALSE, ctrCols=NULL, showLegend=TRUE, legendPlace="bottomleft", lty=3, lwd=NULL, xlim=NULL, ylim=NULL, xlab=NULL, ylab=NULL, …)

Arguments

data

For irregular time measurements, a matrix consisting of curveID in first column, curve evaluations in second and time evaluation points in third column (Format1). For regular time measurements, a matrix consisting of curves in rows and time evaluations in columns (Format2). Alternatively an object created by sampleFuncy.

regTime

If Format2, optional vector representing the evaluation time points. If regTime=NULL equidistant time points from 1 to number of curves are used.

col

Numeric vector of cluster labels.

ctr

Numeric matrix of cluster centers

ctrOnly

Plot only centers, no curves?

ctrCols

Numeric vector specifying the color of the center curves.

showLegend

Whether to show cluster legend.

legendPlace

Where to place cluster legend.

lty

Line type of the functional data.

lwd

Line width of the functional data.

xlim

Range of x-axis.

ylim

Range of y-axis.

xlab

A title for the x axis.

ylab

A title for the y axis.

Further plotting parameters.

Examples

Run this code
# NOT RUN {
##cluster the data with methods for regular sets
##sample a regular dataset
set.seed(2001)
ds <- sampleFuncy(obsNr=40, k=4, timeNr=20, reg=TRUE)
data <- Data(ds)
clusters <- Cluster(ds)

##plot sampled functions. 
plotFuncy(data, col=clusters, lty=1, showLegend=TRUE, legendPlace="topleft")

##sample an irregular dataset
set.seed(2001)
ds <- sampleFuncy(obsNr=40, k=4, timeNrMin=2, timeNrMax=10, reg=FALSE)
data <- Data(ds)
clusters <- Cluster(ds)

##plot sampled functions. 
plotFuncy(data, col=clusters, lty=1, showLegend=TRUE, legendPlace="topleft")


##cluster functions with method fitfclust
res <- funcit(data=data, clusters=clusters,
              methods="fitfclust",
              k=4)

##plot including the centers
plotFuncy(data, col=clusters, ctr=Center(res), showLegend=TRUE, legendPlace="topleft")

# }

Run the code above in your browser using DataLab