Useful R commands and techniques

A collection of some frequently used R commands.

Creating column for categorical group assignment. Shown below is to assign A/B/C according to some existing values.
R-Technique1-grouping

Similarly for new column for derived values from existing column.
R-Technique2-new-dependent-column

Sampling using the sampling package with strata.
R-Technique5a-sampling

With R Studio, view command can be invoked from clicking the variable under the Environment tab, and the frame will then be listed nicely in a tabular format in the data frame window.
R-Technique4-view

Data frame at a glance – head, str, summary.R-Technique3-head-str-summary

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s