class: center, middle, inverse, title-slide # Lab 02: Simple Linear Regression ### 01.25.19 --- class: center, middle # Welcome to lab --- ## Agenda 1. **Teams:** Find teammates. 2. **Tips:** Working in RStudio & GitHub 3. **Starting a new project:** Clone the repo into a new RStudio Cloud project. 4. **Configure git**: Make sure your git config is set up 5. **Warm-up:** Make sure you know how to push and pull. --- ## Teams - Find your teammates: [STA210 Teams](https://prodduke-my.sharepoint.com/:x:/g/personal/mt324_duke_edu/EbV11QsftSdPvMeb05D9oIUBScKanaCBzZhqA81uCAgX2A?e=Y3FRgt) - By the end of today's lab: - Come up with a **team name** and let me know the name. - Find a **weekly 2-hour block between Thursday and Monday** that the team can meet to finish lab. You may not need to use the time every week, but it will be helpful to already have a plan for the weeks that you do need extra time. --- ## Tips - Be ready to troubleshoot your document, since it will likely fail to knit on multiple occasions throughout the process. Read the error message carefully and take note of which line is preventing a successful knit. - Make sure to keep track of your various chunks and to keep text and code in the right place. - Remember that your R Markdown file is not aware of your project's global environment and can only make use of variables, functions, etc. that you have loaded or defined in the document. - If you're unsure how a function works or what its arguments are, simply type `?` in front of it and hit enter (`?read_csv` for instance). The "Help" tab will open and provide a summary of the function as well as some examples. --- ## Starting a new project - Go to the course GitHub organization and find the **lab-02** repo that has your team name on it. - On GitHub, click on the green Clone or download button, select Use HTTPS (this might already be selected by default, and if it is, you’ll see the text Clone with HTTPS). Click on the clipboard icon to copy the repo URL. - Go to RStudio Cloud and into the course workspace. Create a New Project from Git Repo. You will need to click on the down arrow next to the New Project button to see this option. - Copy and paste the URL of your assignment repo into the dialog box and click OK. --- ## Configure Git - Type the following lines of code in the console in RStudio filling in your name and email address. ```r library(usethis) use_git_config(user.name="your name", user.email="your email") ``` - Update the name of your RStudio project to "Lab 02 - Simple Linear Regression" - Before starting on lab, let's talk about the workflow now that you're on a team --- ## Team Workflow - You and your teammates are working from the same lab-02 GitHub repo. This means you are all contributing to the same R Markdown document! - For today's lab, only **one person** on the team should be typing the code/narrative in the R Markdown document at a time. - Rotate who updates the document. Each team member should have at least one commit in the lab. - When you're not typing, you should still be contributing to the discussion but do not actually touch the files on your computer. --- ## Team Workflow I will now demonstrate the steps for updating the lab documents and sharing the updated files with your teammates. - **Every team member**: Click the **Pull** button in the Git pane. This brings the most updated files from GitHub to your RStudio project. - **<u>ONE</u> team member**: - Knit the .Rmd file. - Click the box next to <u>every</u> file in the Git pane. - Write a short and informative commit message. - Push the changes to GitHub. - **Every team member**: Click the **Pull** button in the Git pane. You should now see the changes reflected in the documents in your RStudio project. --- ## Warm-up - Complete the warmup exercise to practice pushing and pulling changes. - Once you've completed the warmup read through the tips on the next slide. You are then ready to start working on the rest of lab. - **Remember: only one person should updating the .Rmd file during the warmup** - We will talk more about working with teams in GitHub next week. - Please raise your hand if you have any questions about the warmup exercise.