Lab Assignment 1: Introduction to R

Part 1: R

  1. Create a variable called myage and assign it the value of your age.

  2. Create a vector called grades containing the following values: 88, 92, 75, 99, and 80.

  3. Using indexing, print the third element of the grades vector to the console.

  4. Use the functionmean() to calculate the average grade. Assign the result to the object avg.

  5. Create a data frame called student_info containing the following columns: Name, Age, Major, Absent. The data should be as follows:

Name Age Major Absent
John 20 AgBiz TRUE
Emily 22 ENRE TRUE
Michael 19 ENRE FALSE
Jessica 21 AgBiz FALSE
  1. Install the package tidyverse. It installs many packages that we will use throughout the course. It may take some time. If things are happening in the console, it is working.

  2. Write a brief explanation of what you did in steps 1-6 and how it relates to the tutorial we did in class.

Part 2: Getting Started with VS Code

Ask AI (github copilot in VS Code) to complete part 1 steps 1-6. Write a brief reflection addressing the following questions:

  • How does the code that copilot wrote compare to your approach?
  • If it answered the questions differently, ask copilot to explain why?

How to Submit

You will submit two documents: the .log file for part 1 and a word doc or text file with your reflection. Refer to the lab instructions on generating a log file. Submit the two files on Canvas.