Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Personally, I prefer "one" liners. Something along the lines:</p> <pre><code>my.df &lt;- data.frame(col1 = sample(c(1,2), 10, replace = TRUE), col2 = as.factor(sample(10)), col3 = letters[1:10], col4 = sample(c(TRUE, FALSE), 10, replace = TRUE)) my.list &lt;- list(list1 = my.df, list2 = my.df[3], list3 = letters) </code></pre> <p>The data structure should mimic the idea of writer's problem and not the exact verbatim structure. I really appreciate it when variables don't overwrite my own variables or god forbid, functions (like <code>df</code>).</p> <p>Alternatively, one could cut a few corners and point to a pre-existing data set, something like:</p> <pre><code>library(vegan) data(varespec) ord &lt;- metaMDS(varespec) </code></pre> <p>Don't forget to mention any special packages you might be using.</p> <p>If you're trying to demonstrate something on larger objects, you can try</p> <pre><code>my.df2 &lt;- data.frame(a = sample(10e6), b = sample(letters, 10e6, replace = TRUE)) </code></pre> <p>If you're working with spatial data via the <code>raster</code> package, you can generate some random data. A lot of examples can be found in the package vignette, but here's a small nugget.</p> <pre><code>library(raster) r1 &lt;- r2 &lt;- r3 &lt;- raster(nrow=10, ncol=10) values(r1) &lt;- runif(ncell(r1)) values(r2) &lt;- runif(ncell(r2)) values(r3) &lt;- runif(ncell(r3)) s &lt;- stack(r1, r2, r3) </code></pre> <p>If you're in need of some spatial object as implemented in <code>sp</code>, you can get some datasets via external files (like ESRI shapefile) in "spatial" packages (see the Spatial view in Task Views).</p> <pre><code>library(rgdal) ogrDrivers() dsn &lt;- system.file("vectors", package = "rgdal")[1] ogrListLayers(dsn) ogrInfo(dsn=dsn, layer="cities") cities &lt;- readOGR(dsn=dsn, layer="cities") </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload