The paste FunctionMegan KressOctober 18, 2016
paste {base}The paste function takes in R objects as arguments. It converts those objects to character vectors (strings) and concatenates them together. By default, a space character separates the two terms. See the CRAN page for more information.
Example 1This example shows a simple pasting of a string object and numeric object.
Example 2This example shows how you can use paste to customize strings in plot labels (in this case, the title of each plot). The data set used is the built-in chickwts data frame, which has columns “weight” and “feed.” The code produces histograms of weight at different feed treatments.
Thus, paste allows us to create correctly-labeled and descriptive plots.
0 Comments
R Tip: Customizing R PlotsAnonymousOctober 18, 2016R Plots can be customized in a variety of ways. This tip focuses on changing the font. This R Tip is modified from http://www.statmethods.net/advgraphs/parameters.html
Changing color settings, Note: you can view the list of available colors
Let’s make a multicolored plot
Let’s explore different plotting symbols:
font can also be customized easily to an extent
Other family font options are “mono”, “sans”, and “symbol”, although I was unable to get symbol to work. While LoopsOctober 12, 2016Occasionally you may wish to carry out a function or operation until a certain condition if filled. This can be done with a while loop.
Once n has reached 6 the loop no longer continues to operate. This may be a simple example, but it can be applied in many complex situations. |
Spatial Ecology @ MSUClick on "Category" below to search for R code compiled by the Zarnetske Spatial & Community Ecology Lab and students in MSU's Spatial Ecology graduate course (FOR870/FW870) Category
All
Archive
October 2016
|