A page to serve as guidelines for helping us create a good resource at Stack Overflow's new documentation feature. Visit the R Public chatroom to discuss more about the documentation.
Most of the guidance for creating good examples for Q&A carries over here. Make it minimal and get to the point. Overcomplicated example data and digressions are probably counterproductive. Make it self-contained to the extent possible. If linking to external resources for reference, make sure that the example stands on its own. If linking to external resources for data, well, um, try not to; and then try some more; and then try to link only to data sources that will be around with the API you're using for a very, very long time.
Some new considerations come up for documentation:
?seq
whenever relevant. We are not trying to replace those docs and want to make sure people new to R know that they are there and how to find them. R>
, >
or +
at the beginning of each line of code. These make it harder for readers to copy your code, try it out and iterate on it to learn how it works.#
or ##
starting each line.[1]
to make the output stand out from the input.As of July 2016, early in the public beta, it's still TBD what does and does not make a good example. If you want to write a tutorial rather than a simple, concise illustration, go ahead, understanding that new norms for what fits may develop.
SO has given no guidance on how they envision topics being organized, and have explained that they don't really care, since readers will come directly from search engines to a page anyways. For our own purposes, as maintainers and editors of the docs, we want to organize it so that we minimize duplication and have plenty of internal links to related examples and topics. We can figure that out as we go.