Learn R Programming

Momocs (version 1.4.1)

bridges: Convert between different classes

Description

Convert between different classes

Usage

l2m(l)

m2l(m)

d2m(d)

m2d(m)

l2a(l)

a2l(a)

a2m(a)

m2a(m)

m2ll(m, index = NULL)

Value

the data in the required class

Arguments

l

list with x and y coordinates as components

m

matrix of (x; y) coordinates

d

data.frame with two columns

a

array of (x; y) coordinates

index

numeric, the number of coordinates for every slice

See Also

Other bridges functions: as_df(), complex, export()

Examples

Run this code
# matrix/list
wings[1] %>% coo_sample(4) %>%
   m2l() %T>% print %>%        # matrix to list
   l2m()                       # and back

# data.frame/matrix
wings[1] %>% coo_sample(4) %>%
   m2d() %T>% print %>%        # matrix to data.frame
   d2m                         # and back

 # list/array
 wings %>% slice(1:2) %$%
 coo %>% l2a %T>% print %>%    # list to array
 a2l                           # and back

 # array/matrix
 wings %>% slice(1:2) %$%
 l2a(coo) %>%                  # and array (from a list)
 a2m %T>% print %>%            # to matrix
 m2a                           # and back

 # m2ll
m2ll(wings[1], c(6, 4, 3, 5)) # grab slices and coordinates

Run the code above in your browser using DataLab