|
In R, loops are often not the most efficient way to do repetitive calculations. Rather than doing the calculations for each value of a variable it is much more efficient to organize the values of…
Copyright
I created all of this content
|
|
In this video we introduce the repeat and while loops. There are small differences in the syntax of the three types of loops in R, which may make one form more convenient than another in any given…
Copyright
I created all of this content
|
|
Loops are a basic element of all computer programming. In R, loops are somewhat less necessary than in many other languages because R can do vectorized calculations---calculations on all of the…
Copyright
I created all of this content
|
|
Conditional execution is a fundamental technique in all computer programming and most computing languages have an if statement. The if and if else statements in R are similar to those in other…
Copyright
I created all of this content
|
|
The ifelse() function evaluates a logical object (usually a vector-valued logical condition) and returns an object of the same dimension with TRUE values replaced by a value, or vector of values,…
Copyright
I created all of this content
|
|
A grouped expression is a collection of R commands or expressions enclosed in curly brackets {}. R regards a grouped expression as a single expression with a single value, although when such an…
Copyright
I created all of this content
|
|
While tapply() applies a function to different observations in a vector, which might correspond to rows in a data frame, lapply() and sapply() apply a function to each element of a list. In the case…
Copyright
I created all of this content
|
|
We continue to discuss data structures in R, this time focusing on lists. Unlike vectors, matrices and arrays, the elements of a list may be of different modes. This makes them very flexible and…
Copyright
I created all of this content
|
|
We continue to discuss data structures in R, this time focusing on arrays. An array is a generalization of a matrix with an arbitrary number of dimensions. We illustrate the structure with a three…
Copyright
I created all of this content
|
|
RStudio provides a more convenient programming environment for working with R. We introduce the RStudio and show how to work from a script within RStudio. The script that we focus on is…
Copyright
I created all of this content
|
|
In this video we introduce R. We give a brief overview of what R is; introduce CRAN (the Comprehensive R Archive Network website) and show how to find installation files, packages and documentation;…
Copyright
I created all of this content
|
|
In this video we demonstrate the ODS OUTPUT statement with an example involving PROC FREQ and compare it to the OUT= option on the TABLES statement. PROC FREQ, PROC MEANS and several other SAS PROCs…
Copyright
I created all of this content
|
|
In this video we show how to transpose variables (columns) into observations (rows) with PROC TRANSPOSE. We illustrate by converting a longitudinal data set from wide format to tall format. This can…
Copyright
I created all of this content
|
|
In this video we return to the FEV Example and show how the OUTPUT statement, in conjunction with a Sum statement, can be used to compute and store posttest-pretest differences even when the posttest…
Copyright
I created all of this content
|
|
Several SAS PROCs have an OUTPUT statement. But here we discuss the OUTPUT statement in a data step. It is used to write the current observation (the contents of the Program Data Vector) to a data…
Copyright
I created all of this content
|
|
When setting a data set, the BY statement can be used to generate special variables known as the FIRST. and LAST. variables. These variables, which are only available in the program data vector, mark…
Copyright
I created all of this content
|