cluster2plot: Convert a grid of clusters into a C4R grid for plotting

Description Usage Arguments Value Author(s) See Also Examples

Description

This function allows to prepare a grid of clusters (included in 'time' dimension) for plotting. A subset of a variable and/or member is also performed in multimember or multigrid objects.

Usage

1
cluster2plot(cluster, members = 1, var = getVarNames(cluster)[1])

Arguments

cluster

A grid (gridded or station dataset), multigrid, multimember grid or multimember multigrid object, as returned by clusterGrid, with clusters in the 'time' dimension.

members

(optional) Integer value indicating the position of the member to be subset. Default: 1. If input grid has no member dimension, this argument is ignored.

var

(optional) Character vector indicating the variable name to be extracted. Default: first variable. See subsetGrid.

Value

A new C4R grid object that contains the clusters from the specified variable and/or member. This subset grid of clusters is ready to be plotted with C4R plotting tools, e.g. spatialPlot, since clusters are intrepreted as variables (see makeMultiGrid).

Author(s)

J. A. Fernandez

See Also

makeMultiGrid, subsetGrid, subsetDimension.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
#Example 1: 'cluster' is a 3D grid of clusters.
data(NCEP_Iberia_psl, package = "transformeR")
clusters<- clusterGrid(NCEP_Iberia_psl, type="kmeans", centers=10)
mg <- cluster2plot(clusters)
spatialPlot(mg, backdrop.theme = "coastline", rev.colors = T, layout = c(2,ceiling(attr(clusters, "centers")/2)), as.table=TRUE)

Example 2: 'cluster' is a grid of clusters with two variables (same for members). 
data(NCEP_Iberia_ta850, package = "transformeR")
clusters<- clusterGrid(makeMultiGrid(NCEP_Iberia_psl, NCEP_Iberia_ta850), type="kmeans", centers=10, iter.max=1000)
mg <- cluster2plot(clusters, members=1, var="psl") #To obtain first member and variable called "psl"
spatialPlot(mg, backdrop.theme = "coastline", rev.colors = T, layout = c(2,ceiling(attr(clusters, "centers")/2)), as.table=TRUE)

juanferngran/test documentation built on June 29, 2020, 3:11 a.m.