Professional Documents
Culture Documents
MADE EASY
LIVE!
LINEAR
REGRESSION
COMBINING TABLES
If you have Microsoft Excel skills, I can teach you how to use R programming to
analyze your business data.
Doesn't matter if you've never coded before. Your basic skills with Excel tables,
formulas, and pivot tables makes this possible.
Despite helping 1000s of professionals learn R programming over the years, I don't
expect you to take my word for it.
If you like this style of teaching, I wanted to let you know that I'll be delivering hands-
on training with R programming on September 26th, 27th, and 28th.
-Dave
2
R PROGRAMMING MADE EASY - LIVE
While not the only way to combine tables of data, Excel's VLOOKUP function is the
most common. From Microsoft's documentation:
"Use VLOOKUP when you need to find things in a table or a range by row."
LINEAR
REGRESSION
The Excel code above is using the values of Column E to match the values stored in
Column I.
Column E contains only the values of setosa, versicolor, and virginica. All cells in Column
E contains one of these values (i.e., no data is missing).
VLOOOKUP uses values from the left table to match on values in the right table.
Where' matches are found, the values from Column J are copied to Column F.
https://bit.ly/RProgrammingLiveTraining
3
R PROGRAMMING MADE EASY - LIVE
Continuing the example, if the <enter> key is pressed, the VLOOKUP function is
executed with the following results in the left table.
In the above case, the right table does not contain all the values that exist in Column E
of the left table.
When VLOOKUP cannot find a match in the right table, it returns #N/A which means
"no value available."
Notice how all rows from the left table are preserved.
https://bit.ly/RProgrammingLiveTraining
4
R PROGRAMMING MADE EASY - LIVE
Terminology
When using your knowledge of VLOOKUP to learn combining tables of data using R,
we need to establish some terminology. You've already been exposed to left table
and right table.
join condition
https://bit.ly/RProgrammingLiveTraining
5
R PROGRAMMING MADE EASY - LIVE
Combining Tables in R
dplyr
The most common way to combine tables of data in R programming is to use the
mighty dplyr library.
Among the many functions provided by dplyr is the left_join function. Conceptually,
the left_join function does the same thing as VLOOKUP.
These tables have the same data as in the Excel example and will be used in learning
how to perform left joins using dplyr.
In this example, iris_data will be the left table and iris_stats will be the right table.
https://bit.ly/RProgrammingLiveTraining
6
R PROGRAMMING MADE EASY - LIVE
R Code
As mentioned on the previous page, the left_join function is used to combine tables
using left joins.
The following code comparison shows how your VLOOKUP knowledge maps to
using R code.
LINEAR
join condition
REGRESSION
left table right table
join condition
https://bit.ly/RProgrammingLiveTraining
7
R PROGRAMMING MADE EASY - LIVE
The left_join function does not change the data stored in left table and right table.
Instead, left_join creates a new combined table. The following code illustrates how to
store the new table.
This just one of many examples of how your Excel knowledge maps to R
programming.
Ready to scale past Excel and unlock advanced analytics like time series forecasting
and machine learning?
https://bit.ly/RProgrammingLiveTraining
8
R PROGRAMMING MADE EASY - LIVE
"Dave! You are incredible! Thank you so much for being such an attentive
instructor!" - Bruce Lam
Certificate of completion
9 hours of instruction
Hands-on labs
Limited to 20 students
PDFs of all slides/labs
All R code
1-on-1 help if needed
Recordings if you miss a
class
Ready to unleash the power of R with your data? Learn more at the link below.
https://bit.ly/RProgrammingLiveTraining
9
R PROGRAMMING MADE EASY - LIVE
https://bit.ly/RProgrammingLiveTraining
10