Can someone please help me with some use case of List data structure. I know that its a collection of elements with different types. My confusion started with the below example. I know its a basic questions but still want to have clarity on this.
I think you've shown only that data.frames, becaues each column can support a different type, has similar flexibility to list, with respect to grouping things together of different types; Similar can be said for environments.
lists do well in representing non tabular heirarchies.
Try the following code (which runs a simple linear regression using a built-in data set).
> m <- lm(wt ~ cyl, mtcars)
> str(m)
The fitted regression model is stored in variable m. The str() command displays the structure of m, which is a list with 12 components. The disparate nature of those components (numeric vectors, character vectors, scalars, a formula ...) makes a list the natural way to store it.