How do I load example datasets in R?

export, r, structure

Solution

Here's one handy option:

site.data <- read.table(textConnection(
"        site year     peak
1  ALBEN    5 101529.6
2  ALBEN   10 117483.4
3  ALBEN   20 132960.9
8  ALDER    5   6561.3
9  ALDER   10   7897.1
10 ALDER   20   9208.1
15 AMERI    5  43656.5
16 AMERI   10  51475.3
17 AMERI   20  58854.4"))

Problem

Let's say I want to reproduce an example posted on StackOverflow. Some have suggested posters use `dput()` to help streamline this process or one of the datasets available in the base package. In this case, however, suppose I have only been given the output of the dataframe: ``` > site.data site year peak 1 ALBEN 5 101529.6 2 ALBEN 10 117483.4 3 ALBEN 20 132960.9 8 ALDER 5 6561.3 9 ALDER 10 7897.1 10 ALDER 20 9208.1 15 AMERI 5 43656.5 16 AMERI 10 51475.3 17 AMERI 20 58854.4 ``` Do I have other options besides saving this as a text file and using `read.table()`?

Original source

Related problems