Writing Efficient Code in R: Logical Statements and Loops

Logic statements and loops in R mashup

 

In Person

This is an intermediate level workshop with a focus on developing practical skills for writing and utilising logical statements and loops in R. A basic understanding of R is assumed. This assumed understanding is at the level covered in the Introduction to R and RStudio course, though participation in that workshop itself is not required in order to attend this workshop. No prior experience with logical statements in any coding language is required. 

Logical statements can be used for both simple calculations and comparisons, as well as for more complex tasks such as setting up conditions for loops and pre-screening data before running tests, which can all aid in automating/streamlining efficient scripts. 

The session will begin with a theoretical demonstration of the use of logical statements and loops, and how to write them in R. A practical, guided exercise will then follow. All of this will cover topics such as: 

  • Logical operators and logical statements 

  • Utilising binary logical outputs 

  • If and if else statements 

  • Loops 

  • While, For and Break   

The workshop will ultimately help to develop an understanding of logical statements and loops, and how these can be created and implemented in R, leading to far more efficient code. Crucially, this will foster a familiarity with the core principles and the capabilities of the software, allowing attendees to confidently apply these, or indeed seek out new concepts for their own and future research. 

Those who have registered to take part will receive an email with full details on how to get ready for the course. 

After taking part in this event, you may decide that you need some further help in applying what you have learnt to your research. If so, you can book a Data Surgery meeting with one of our training fellows. 

More details about Data Surgeries. 

If you’re new to this training event format, or to CDCS training events in general, read more on what to expect from CDCS training. Here you will also find details of our cancellation and no-show policy, which applies to this event. 

If you're interested in other training on Data Wrangling, have a look at the following:

 

Return to the Training Homepage to see other available events.

Digital Scholarship Centre

Digital Scholarship Centre, 6th floor

Main Library 

University of Edinburgh 

Edinburgh EH8 9LJ

You might be interested in

Introduction to Databases and SQL

Silent Disco: Introduction to Databases and SQL

Regression and Mixed Effect Modelling mashup

Regression and Mixed Effects Modelling

Sentiment Analysis

Silent Disco: Introduction to Sentiment Analysis

An Introduction to Machine Learning

An Introduction to Machine Learning

Null Hypothesis Testing in R

Null Hypothesis Testing in R

Interactive Analysis Reports with R Markdown

Interactive Analysis Reports with R Markdown