showLearn More
The materials in this course were developed through an NSF grant designed to improve how students learn about and interact with polar regions. The intent was to create materials to help students engage with polar data and researchers and learn more about how polar science issues affect people and animals
Learn more about the Oceans in the News project »
show Download

Module 2 Introduction to R and Pair Programming

Summary

This unit is designed to take students with no programming experience and introduce them to R, a programming environment commonly used by scientists for analyzing and visualizing data. By introducing students to how computers operate, they can better conceptualize why coding language is so particular. By spending time introducing students to the basics of working in R, they are prepared for tackling more difficult coding assignments later in the course. Utilizing pair programming helps students work together to tackle harder assignments and build greater cooperation and understanding.

Used this activity? Share your experiences and modifications

Learning Goals

  • Students will gain an understanding of how computers interpret commands
  • Students will learn how to execute basic commands in R
  • Students will be able to generate simple plots in R
  • Students will practice simple data collection
  • Students will gain experience working in teams

Context for Use

This module is intended to be covered across several 75-minute class periods, with each activity taking up approximately one class period. This module is intended to provide resources for the rest of the course, but can stand independently and be used as part of another course to introduce students to computer programming and R. Because of the complexities associated with programming, this is best suited for undergraduate and graduate students, however it may be suitable for honors high school students.

Pair Programming

The purpose of the R videos in this section is to introduce students to pair programming. Pair programming is a practice developed in computer science to help students learn programming context and syntax quickly. In this practice, two programmers (students in this case) work together to accomplish a task (Williams et al., 2000): one of the students is the "driver" and the other is the "navigator". The navigator is mainly responsible for watching and verbally communicating the programming instructions from the video to the driver. The driver is mainly responsible for translating the navigators instructions into syntax and inputting it into the computer.

Description and Teaching Materials


The first activity (Legos) uses colored, interlocking bricks to have students build something, write down instructions, and have a classmate attempt to follow those instructions. This highlights the need to give clear commands (to a computer).

The second activity (Buckethead/Immersion) has students lose access to sight via placing a bucket on their head or by blindfolding them, and other students must lead them through a task while acting as the blind student's eyes. This also highlights the need to give clear commands (to a computer).

The third activity (Ice Bucket) is intended to demonstrate properties of sea water while providing students an opportunity to collect and plot data. The Ice Bucket activity requires decent prior planning to ensure that all the buckets of sea water have frozen sufficiently, so care needs to be taken to prepare them well in advance.

A hole needs to be drilled into each bucket's ice, and while students should be able to do this themselves, the instructor should use their judgement on whether the students are mature enough to handle the power drill or if the instructor should do it for them. Students may also share buckets. The instructor should make sure to walk among the groups and aid with drilling and data collection as needed. Once the temperature and salinity data has been collected, students should be prepared to plot their data after watching the R tutorial videos.

Regardless of whether any of the three activities are used, the core of this module is to introduce students to R with instructional videos and accompanying code. There are five videos that accompany this module with an accompanying R code file for each, however students can also generate their own code as they follow along. Either the videos can be watched in class or assigned as homework. After watching the videos and following along, students should feel confident enough to plot data in R. If the Ice Bucket activity was performed, the students should now plot the data they collected.

Teaching Notes and Tips

The amount of time this module takes will vary greatly depending on how many activities are included. Each activity should take about an hour, but they can be shortened to fit multiple in one class session. Depending on how well the class performs, the R-coding time in class can easily be shortened or extended to ensure understanding.

The activities, mainly Legos and Buckethead, can seem a bit silly, which can make students enjoy them but may make them take the activities less seriously.

Students will often underestimate themselves when it comes to coding in R. It seems a daunting task, however the videos walk students along to show them everything they need to do. As a result, students often believe that they are struggling, when they are performing very well. They may need additional encouragement and reinforcement that they are doing well.

Assessment

Collecting the students' coding at the end allows formative assessment of how well they followed the videos. For the Legos activity, the students' instructions can be collected and evaluated. For the Ice Bucket activity, students' graphs and code can be collected and assessed. The concepts learned here will be applied to the rest of the course, and thus assessed further in the following modules.

References and Resources

R Core Team. 2017. R: A language and environment for statistical computing. Vienna, Austria. URL https://www.R-project.org/

Williams, L., R.R. Kessler, W. Cunningham, R. Jeffries. 2000. Strengthening the case for pair programming. Software IEEE 17:19-25.

R code files (for instructor reference only)

Connect with peers who are using these materials »
How this module is being adopted and adapted »