You have to create the sample dataframe in the reprex itself, and paste the output of reprex()
here directly not with screenshots, see this example:
- If you run
reprex()
like this
reprex({
# Create the sample dataset with the output of datapasta::df_paste()
sample_data <- data.frame(
Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, 5.4),
Sepal.Width = c(3.5, 3, 3.2, 3.1, 3.6, 3.9),
Petal.Length = c(1.4, 1.4, 1.3, 1.5, 1.4, 1.7),
Petal.Width = c(0.2, 0.2, 0.2, 0.2, 0.2, 0.4),
Species = as.factor(c("setosa", "setosa", "setosa", "setosa", "setosa",
"setosa")))
# Now you can use the dataset in your reprex
summary(sample_data)
})
- You get this result ready to be posted in the forum.
# Create the sample dataset with the output of datapasta::df_paste()
sample_data <- data.frame(
Sepal.Length = c(5.1, 4.9, 4.7, 4.6, 5, 5.4),
Sepal.Width = c(3.5, 3, 3.2, 3.1, 3.6, 3.9),
Petal.Length = c(1.4, 1.4, 1.3, 1.5, 1.4, 1.7),
Petal.Width = c(0.2, 0.2, 0.2, 0.2, 0.2, 0.4),
Species = as.factor(c("setosa", "setosa", "setosa", "setosa", "setosa",
"setosa")))
# Now you can use the dataset in your reprex
summary(sample_data)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width
#> Min. :4.600 Min. :3.000 Min. :1.300 Min. :0.2000
#> 1st Qu.:4.750 1st Qu.:3.125 1st Qu.:1.400 1st Qu.:0.2000
#> Median :4.950 Median :3.350 Median :1.400 Median :0.2000
#> Mean :4.950 Mean :3.383 Mean :1.450 Mean :0.2333
#> 3rd Qu.:5.075 3rd Qu.:3.575 3rd Qu.:1.475 3rd Qu.:0.2000
#> Max. :5.400 Max. :3.900 Max. :1.700 Max. :0.4000
#> Species
#> setosa:6
#>
#>
#>
#>
#>
Created on 2019-06-23 by the reprex package (v0.3.0)