1) Using Numeric Functions to create a Horizontal Abstraction.

This Blog entry is from the Loading, Shaping and Merging Data section in Learn R.

As introduced R has a plethora of Blog entries that facilitate the creation of Vectors and Matrices, furthermore there are base numeric operators which facilitate:

·         + Addition.

·         - Subtraction.

·         * Multiplication.

·         / Division.

·         %% Exponent.

·         ^ Power Of.

Functions also provide the ability to perform mathematical operations.  In this example, a vector of double values will be created then rounded.  Create a new script and start by creating a vector containing double values:

Double <- c(1.22341,5.889988,6.9999890)
a-script-to-create-a-float-double-vector-in-r.png

Run the line of script to console:

a-float-double-vector-having-been-created-in-r-console.png

Use the round() function,  which takes two arguments of value and digits, to round the Double vector to two decimal places assigning that vector:

round(Double,2)
a-script-to-use-the-round-function-on-a-float-vector-in-r.png

Run the line of script to console:

a-float-double-vector-rounded-written-out-to-r-console.png

Write out the DoubleRound vector by typing:

DoubleRound
a-script-to-request-that-a-double-vector-is-written-out-to-r-console.png

Run the line of script to console:

writing-out-a-double-float-vector-to-the-r-console.png

It can be observed that the vector has been rounded to two decimal places.  By way of further abstraction find the square root:

DoubleRoundSqrt(VectorRound)
a-script-to-improve-accuracy-of-a-vector-or-variable-with-sqrt-in-r.png

Run the line of script to console:

sqrt-function-being-executed-on-a-vector-in-r-console.png

A more concise way to create a line of script relying on several functions, could include nesting the functions:

DoubleNested <- sqrt(round(Double,2))

a-script-to-embed-the-round-function-inside-the-sqrt-function-in-r.png

Run the line of script to console:

a-script-to-embed-the-round-function-inside-the-sqrt-function-in-r-executed-in-console.png

It can be observed that with the help of several R numeric functions that complex horizontal abstractions can take place.

14) Creating a Numeric Variable by Assignment

This Blog entry is from the Getting Started in R section in Learn R.

Start by creating a new script:

creating-a-new-script-in-rstudio.png

A blank script window will be created that will be the target:

a-new-script-in-r-studio.png

Variables in R are created by assignment,  the process of setting a value.  The operator or command for assignment is the character combination of "<-".  To create and assign a numeric variable start by typing into the script window:

Numeric <- 1
creating-a-numeric-variable-by-assign-in-r-rstudio.png

Run the script to console:

r-console-numeric-variable-created-by-assign.png

A variable with the name Numeric has now been created.   It can be seen that RStudio has also recognised the creation of a new variable in the Environment Values pane towards the top right hand side of RStudio:

the-variable-environment-window-in-rstudio.png

script to console.  In this example,  create a new line in the script and type the name of the variable:

Numeric
write-numeric-variable-to-r-console.png

Run the line of script to console:

numeric-variable-written-out-to-r-console.png

It can be seen that the assigned value is written out.

The mode() function is intended to disclose the variable type, taking the variable name as the paramater.  Create a new line in the script editor and disclose the variable type, start by typing:

mode(Numeric)

Run the line of script to console:

using-the-mode-function-to-check-variable-type-in-r-console.png

It can be observed that the variable type has been returned as numeric.  It is also possible to assign a variable as the result of arithmetic or function output.  For example,  type into the script editor:

NumericResult <- 1 + 1
performing-some-basic-addition-on-numeric-variable-in-r-console.png

Run the line of script to the console:

numeric-variable-created-by-assign-and-addition-in-rstudio-variable-environment.png

It can be observed that the NumericVariable has been created and is available in the Environment Variables windows, and it would also return in the console when referencing the variable directly:

outputting-a-variable-to-r-console.png

Introduction to Loading and Shaping

This Blog entry is from the Loading, Shaping and Merging Data section in Learn R.

Abstraction, the process of shaping and molding raw data to enhance relevance prior to it being presented to machine learning algorithms, is the cornerstone of the methodologies put forward in these Blog entries.

The Blog entries that follow set out the means to load data into R, and when this data resides in R, sets forth procedures to shape and mold the data in as part of abstraction.

Most generally in Jube procedures and methodology Abstraction is offloaded to Relational Database Management platforms, the shaping and molding of data in R tends to be to augment these core datasets.