Learn R Programming

rlist (version 0.2.2)

list.parse: Parse an object to be a list with identical structure

Description

Parse an object to be a list with identical structure

Usage

list.parse(x, ...)

## S3 method for class 'default':
list.parse(x, ...)

## S3 method for class 'matrix':
list.parse(x, ...)

## S3 method for class 'data.frame':
list.parse(x, ...)

## S3 method for class 'character':
list.parse(x, ..., type = NULL)

Arguments

x
The object
...
Additional parameters
type
The type of data to parse. Currently json and yaml are supported. In default, NULL value will parse the character with list.parse.default. Ignored when the length of x is greater than 1.

Examples

Run this code
x <- data.frame(a=1:3,type=c("A","C","B"))
list.parse(x)

x <- matrix(rnorm(1000),ncol=5)
rownames(x) <- paste0("item",1:nrow(x))
colnames(x) <- c("a","b","c","d","e")
list.parse(x)

z <- "
a:
  type: x
  class: A
  registered: yes
"
list.parse(z,type="yaml")

Run the code above in your browser using DataLab