View source: R/list-simplify.R

list_simplify | R Documentation |

Simplification maintains a one-to-one correspondence between the input
and output, implying that each element of `x`

must contain a one element
vector or a one-row data frame. If you don't want to maintain this
correspondence, then you probably want either `list_c()`

/`list_rbind()`

or
`list_flatten()`

.

```
list_simplify(x, ..., strict = TRUE, ptype = NULL)
```

`x` |
A list. |

`...` |
These dots are for future extensions and must be empty. |

`strict` |
What should happen if simplification fails? If |

`ptype` |
An optional prototype to ensure that the output type is always the same. |

A vector the same length as `x`

.

```
list_simplify(list(1, 2, 3))
# Only works when vectors are length one and have compatible types:
try(list_simplify(list(1, 2, 1:3)))
try(list_simplify(list(1, 2, "x")))
# Unless you strict = FALSE, in which case you get the input back:
list_simplify(list(1, 2, 1:3), strict = FALSE)
list_simplify(list(1, 2, "x"), strict = FALSE)
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.