| Learn | R - Lists - Reasons for using lists |
|---|
| Reasons for using lists To the average R user, the list structure may appear to be the one of the more complicated data structures to manipulate. There are no guarantees that all the elements within it are of the same type; There is no guaranteed structure of how complicated/non-complicated that the list would be (An element in a list could be a list) However, one of the main reasons when to use lists to use it to pass parameters between functions. In the above example, the returned results are just simple numeric vectors. There is no issues to pass over such simple vectors. It is important to note at this point that generally, R functions only return 1 result at a time (You can use if conditions to return different results). However, if you intend to create a function which takes a set of parameters and returns several type of results such a numeric vector(settings value) and a data frame (from the calculation), you would need to dump all these results in a list before returning it. |
Read Article
https://develop.horje.com/learn/1434/reference