ARCHIVE: Summer 2018: R-users and SASsy Fridays Hiatus!

Good day everyone!

I’ve been talking with a few folks about these during the summer and consensus is that everyone is busy and it will be tough to maintain attendance.  So, with that in mind, both the R-Users and SASsy Fridays sessions will be back in the Fall!

Apologies to anyone who was planning on coming.  Topics listed will be presented in September.

Have a great summer!  See you all in the Fall!
Name

R: Getting the data in, merging files, and creating new variables

PDF copy of the Getting the data in, merging files, and creating new variables notes

As we begin the coding part of the R workshop, let us try to bring things together and make it as easy as possible for you to run the code and work with me as we progress through the topics of the next 2 days.  On that note, ror each session of the R workshop, I will have an R script already prepared for you, complete with comments for every step that you will need to download and open in RStudio at the beginning of every workshop section.

Please download the following:

Getting the Data in

As with any program out there today, there are several ways to bring data into the R platform.  We will work through 2 different ways to accomplish this task, and once we’ve worked through both, I would like to hear which one you prefer!

Reading a CSV file, gets you in the habit of creating a preservation-ready format for your data, but you’ve probably already figured out, that it also means having documentation at the ready – so you remember what variable is what, and with respect to reading it into R, you need to pick and choose the location, or make sure your working directory has been set at the beginning.  Reading an Excel file, is just SOooo much easier and probably the way most of us like to work.  Just remember to save your data as you work!

Merging files

Merging files sounds like such an innocent task.  I have an Excel file with 4 monthly worksheets and all I want to do is put them all together into 1 file, so I can analyse the data.  Easy peasy right??

There are a few ways of merging files in R.  The most straightforward method is to use the merge function available in Base R.  Try it out with our data and tell me what happens when you merge the January data which has 25 observations with the February data which only has 23 observations?

So, we’ve noticed that there’s something NOT quite right with this merge.  The 2 observations that had a measure in January but not in February were not included in our final dataset. What happens if later on, say in March or April, we do have measures for these individuals?  We want them to be included.  So we need to consider other methods of merging our files.

We will use the joining functions available in the DPLYR package.  By doing this we need to take a quick little detour to remind ourselves about sets, unions, and joins?  This is the way that R takes when merging or rather joining datasets.  You’ll also see that by taking this approach we can do merge all of our data using this one function, unlike SAS and SPSS.

This is a perfect opportunity to show you the Cheatsheets in R.  In RStudio follow these steps:

  • Help
  • Cheatsheets
  • Data Transformation with DPLYR

Let’s work through the examples of Combine Tables to get a better understanding of how to merge in R.

Based on these examples, we are interested in performing a FULL_JOIN.  Did the coding in the R script work for you?  Can you see how this might work for your own research data?

Creating new variables

Creating a new variable is very straightforward function:  Ynew = Var1 + Var2 or whatever variable you need to create.  The tricky part is ensuring that it becomes a part of your dataset.  Let’s work through the examples in the R script.

Now what if we want to recode a variable rather than just creating a new one?  For example:  we want to create a new variable called wtclass that will take the weights measured in January and put them into 3 weight classes:  1 = 13-16; 2 = 17-20;  3 = 21-24

Quick recap

Getting your data into R, can be as easy as using the READXL package and importing your Excel worksheets directly into R.

Once you have your dataset in R, you can merge files using the join functions available in the DPLYR package.

Creating new variables and recoding variables is straightforward, just remember to make sure that you have added them to your R datafile by using the attach() and detach() functions.  Note there are other ways of doing this as well, this is just one.

Don’t be afraid to check out the Help resources – Cheatsheets are fun and very informative.

Name

 

ARCHIVE: Summer 2018 – SASsyFridays and R Users Group

I will continue to facilitate the SASsyFridays and the R-Users Group for May and June.  With most graduate students and researchers out in the field during the summer, we will take a hiatus for the months of July and August, and reconvene in September to continue to learn more about SAS and R.

Topics and dates for the upcoming SASsyFridays:

May 18:  Using Proc GLMPOWER to estimate power for your completed analyses
June 15: Tips and Tricks #1: debugging your data for analysis – PRINT, FREQ, MEANS
June 29: Tips and Tricks #2: debugging your data for analysis – LENGTH, UNIVARIATE

Topics and dates for the upcoming R Users Group:

May 11: Introduction to R-Markdown – how to save your output in Word
June 8:  Tentative: Tips and Tricks on finding R resources
June 22:  Tentative: More of GGPLOT2

Name

 

ARCHIVE: Summer 2018 Workshops

Workshops for the Summer 2018 have just been posted and are now available for Registration.  Please register if you are planning on attending.  If you register and need to cancel, please do so with the link on the confirmation email you receive when registering or by emailing oacstats@uoguelph.ca .  The registration link for each workshop is listed below and is unique to that workshop.

SAS

A 2-day workshop will be held on May 8-9, 2018 from 9am – 4pm in ANNU Rm 102.  Topics covered will include:

  • Getting the data in
  • Merging datasets and creating new variables
  • Descriptive statistics
  • ANOVA using GLIMMIX – we will work through a number of examples

If you are new to SAS, please plan on attending the 2 days.  For anyone interested in learning more about GLIMMIX, you are invited to attend May 10 only.  However, please note that any material covered on the first day will NOT be repeated on Day 2.

To register for this workshop, please register for each day separately here.

Date: May 8 – 9, 2018 9am – 4pm
Location:  ANNU Rm 102

SPSS

A 2-day workshop will be held on May 16-17, 2018 from 9am – 4pm in ANNU Rm 102.  Topics covered will include:

  • Getting the data in
  • Merging datasets and creating new variables
  • Descriptive statistics
  • ANOVA and GLMM
  • Non-parametric analyses, including Kruskal-Wallis, and Friedman ANOVA

If you want to follow along with the workshop, please ensure that you have the SPSS Software installed on your laptop.  You always have the option to follow the instructor if you do not have the software on your laptop.  Please plan to attend the 2 days to learn all about SPSS and how you can use it for your research project.

To register for this workshop, please register for each day separately here.

Date: May 16-17, 2018  9am-4pm
Location: ANNU Rm 102

R workshop

A 2-day workshop will be held on May 22-23, 2018 from 9am – 4pm in ANNU Rm 102.  Topics covered will include:

  • Getting your data into R
  • Working with your data – cleaning and tidying
  • Descriptive statistics
  • Packages performing ANOVA
  • Packages performing Regression
  • ggplot2

If you want to follow along with the workshop, please ensure that you have the R and RStudio installed on your laptop.  You always have the option to follow the instructor if you do not have the software on your laptop.  Please plan to attend the 2 days to learn all about R and how you can use it for your research project.

To register for this workshop, please register for each day separately here.

Date: May 22-23, 2018  9am-4pm
Location: ANNU Rm 102

RDM: Starting your Research on the Right Foot!

Join Carol Perry from the Library and Michelle Edwards, to learn how to start your research on the right foot.  If you are just starting your graduate work or if you’re an experienced researcher, join us to learn all about the best practices to help you organize and document your project data, store and analyze your data, secure and preserve your data legacy.  This day long workshop is filled with hands-on exercises to encourage you to treat your data as a valuable commodity.  At the end of this workshop, every participant will complete a Data Management Plan and be will be all set to tackle their research data.

This is a one-day workshop held on Tuesday, June 5, 2018 in ANNU Rm 102.  The workshop startst at 9am and will be finished at 4pm.  Please register here.

Date: June 5, 2018  9am-4pm
Location: ANNU Rm 102

 

Thank-you and hope to see you in a workshop!

Name

 

 

R: Linear Mixed Models in R – A case Study

Jordan Graham, MSc student in SES, presented his experiences working with Linear Mixed Models (LMM) in R.  Please review the presentation and the sample code provided.

R-Users group will continue in May.  Stay tuned for an updated list of dates and topics.  If you are interested in talking to the group about a package that you’ve been using, please contact me at oacstats@uoguelph.ca  – I welcome all suggestions!

Name