Chapter 3-4 More R functions Graphs!. Random note The package DSUR from the Field book is not a thing. ◦ That’s ok! We’ll figure it out.

Slides:



Advertisements
Similar presentations
Introduction to R Brody Sandel. Topics Approaching your analysis Basic structure of R Basic programming Plotting Spatial data.
Advertisements

Math for Liberal Studies. An identification number is a sequence of letters and/or numbers that identifies an object, person, place, or concept The number.
Microsoft ® Office Access ® 2007 Training Build a database II: Create tables for a new Access database GPC presents:
Writing functions in R Some handy advice for creating your own functions.
Statistics for the Social Sciences
University Libraries Tab-Delimited Spreadsheets Made Easy Kathleen McElhinney, Metadata/Cataloging Librarian.
Newsletter Plugin The newsletter plugin allows you to create and send newsletters to a managed list or multiple lists of users. Your users can subscribe.
How to prepare a PowerPoint presentation
1 Creating and Tweaking Data HRP223 – 2010 October 24, 2011 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This.
Creating a Blank Database 1. Open up Microsoft Access 2. Click on Blank document button 3. On the right panel, Specify the location for saving your database.
Pet Fish and High Cholesterol in the WHI OS: An Analysis Example Joe Larson 5 / 6 / 09.
1 Topic Mathematical Proofs. 2 Topic Mathematical Proofs California Standards: 24.2 Students identify the hypothesis and conclusion in logical.
Python plotting for lab folk Only the stuff you need to know to make publishable figures of your data. For all else: ask Sourish.
The preprocessor and the compilation process COP3275 – PROGRAMMING USING C DIEGO J. RIVERA-GUTIERREZ.
Making Tables and Graphs with Excel The Basics. Where do my IV and DV go? Just like you would create a data table on paper, your IV goes in the leftmost.
Stata 12 Merging Guide Nathan Favero Texas A&M University October 19, 2012.
Row rows A matrix is a rectangular array of numbers. We subscript entries to tell their location in the array Matrices are identified by their size.
SAS Workshop Lecture 1 Lecturer: Annie N. Simpson, MSc.
ALEXANDER C. LOPILATO R: Because the names of other stat programs don’t make sense so why should this one?
Excel By: Brandon Honza. Step 1 Take the CD on the table and put it into your computer. Open the Disc. Then click and drag the entire Excel folder to.
IT-101 Section 001 Lecture #3 Introduction to Information Technology.
Introduction to R Part 2. Working Directory The working directory is where you are currently saving data in R. What is the current working directory?
Introduction to R Part 1. First Note: I am not an expert at R. – I’ve been hiking up the learning curve for about a year. You can learn R. – You will.
Fall 2001(c)opyright Brent M. Dingle 2001 Arrays Brent M. Dingle Texas A&M University Chapter 9 – Sections 1 and 2 (and some from Mastering Turbo Pascal.
Installing and Using MySQL and phpMyAdmin. Last Time... Installing Apache server Installing PHP Running basic PHP scripts on the server Not necessary.
I❤RI❤R Kin Wong (Sam) Game Plan Intro R Import SPSS file Descriptive Statistics Inferential Statistics GraphsQ&A.
Chapter 17: The binomial model of probability Part 3 AP Statistics.
Colleague, Excel & Word Best of Friends Presented by: Joan Kaun & Yvonne Nelson College of the Rockies.
1 Lab 2 and Merging Data (with SQL) HRP223 – 2009 October 19, 2009 Copyright © Leland Stanford Junior University. All rights reserved. Warning:
 Slide 1 Two-Way Independent ANOVA (GLM 3) Chapter 13.
Regression Chapter 16. Regression >Builds on Correlation >The difference is a question of prediction versus relation Regression predicts, correlation.
Accuracy Chapter 5.1 Data Screening. Data Screening So, I’ve got all this data…what now? – Please note this is going to deviate from the book a bit and.
Introduction to R Part 1. First Note: I am not an expert at R. – I’ve been hiking up the learning curve for about a year. You can learn R. – You will.
Introduction to Programming in R Department of Statistical Sciences and Operations Research Computation Seminar Series Speaker: Edward Boone
Regression Mediation Chapter 10. Mediation Refers to a situation when the relationship between a predictor variable and outcome variable can be explained.
11/25/2015Slide 1 Scripts are short programs that repeat sequences of SPSS commands. SPSS includes a computer language called Sax Basic for the creation.
Repeated-measures designs (GLM 4) Chapter 13. Terms Between subjects = independent – Each subject gets only one level of the variable. Repeated measures.
CFA: Basics Beaujean Chapter 3. Other readings Kline 9 – a good reference, but lumps this entire section into one chapter.
Slide 1 Mixed ANOVA (GLM 5) Chapter 15. Slide 2 Mixed ANOVA Mixed: – 1 or more Independent variable uses the same participants – 1 or more Independent.
DataSet Your Database student test score Database Connection Your program needs to establish a connection to the database. Click on “Add New Data Source.”
Mixed ANOVA (GLM 5) Chapter 14. Mixed ANOVA Mixed: – 1 or more Independent variable uses the same participants (repeated measures) – 1 or more Independent.
Assumptions 5.4 Data Screening. Assumptions Parametric tests based on the normal distribution assume: – Independence – Additivity and linearity – Normality.
SEM Basics 2 Byrne Chapter 2 Kline pg 7-15, 50-51, ,
Outliers Chapter 5.3 Data Screening. Outliers can Bias a Parameter Estimate.
Correlation Chapter 6. What is a Correlation? It is a way of measuring the extent to which two variables are related. It measures the pattern of responses.
Missing Values C5.2 Data Screening. Missing Data Use the summary function to check out the missing data for your dataset. summary(notypos)
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
1 PEER Session 02/04/15. 2  Multiple good data management software options exist – quantitative (e.g., SPSS), qualitative (e.g, atlas.ti), mixed (e.g.,
Build a database II: Create tables for a new Access database Create your tables In a relational database, tables store your data. Your data doesn’t “live”
BMTRY 789 Lecture9: Proc Tabulate Readings – Chapter 11 & Selected SUGI Reading Lab Problems , 11.2 Homework Due Next Week– HW6.
NOTETAKING AND STUDY SKILLS The SQRW Method. SQRW – Survey, Question, Read, Write What exactly is SQRW? ◦Well, it’s a study method where you get the best.
It’s always important that all of your nodes be numbered. So the way to do that is to go to Options at the top of the screen then select Preferences. When.
Data Screening. What is it? Data screening is very important to make sure you’ve met all your assumptions, outliers, and error problems. Each type of.
Using ODS Excel Migrating from DDE to ODS
Reporting Overview Business Goals Demystify the report menu
Multiple Regression.
به نام خدا كاربرد كامپيوتر در مهندسي صنايع نرم افزار spss
Macrosystems EDDIE: Getting Started + Troubleshooting Tips
Introduction to R.
Mapbox Studio Sarah and Haley.
اختر أي شخصية واجعلها تطير!
Crash course in R – short introduction
Lab 2 and Merging Data (with SQL)
Lab 2 HRP223 – 2010 October 18, 2010 Copyright © Leland Stanford Junior University. All rights reserved. Warning: This presentation is protected.
Macrosystems EDDIE: Getting Started + Troubleshooting Tips
Macrosystems EDDIE: Getting Started + Troubleshooting Tips
Presentation transcript:

Chapter 3-4 More R functions Graphs!

Random note The package DSUR from the Field book is not a thing. ◦ That’s ok! We’ll figure it out.

Outline New things that haven’t been covered in class or on the youtube videos: ◦ File functions ◦ Factor functions ◦ Rearranging functions

File Functions We’ve already discussed how to use the import function in Rstudio. ◦ However, that only really works well for csv files. What if we have something else? ◦ Also, what if I don’t want to deal with the working directory stuff?!

File Functions Two packages that work with files: ◦ foreign ◦ memisc Foreign will work 99% of the time for you, but sometimes does funky things with SPSS files. Memisc seems to work great?

File Functions Install the foreign/memisc library. Be sure to load the library! ◦ library(foreign) ◦ library(memisc)

File Functions file.choose() ◦ The file.choose() function allows you to pick the file from your computer – much like the import option in studio. Instead of putting the file name into the code, you simply put file.choose().

File Functions Let’s try with some code we’ve used before (read.csv). data = read.csv(file.choose(), header=TRUE) ◦ The bad thing about this function is that you have to select it every single time (ugh) AND you don’t get to see the code it did in the background.

File Functions chick = read.spss(file.choose(), to.data.frame=TRUE) OR chick = read.spss("c4 ChickFlick.sav", to.data.frame=TRUE) summary(chick)

File Functions Notice you get an error, but the data seems to be ok. Let’s try memisc instead: ◦ chick2 = as.data.set(spss.system.file(file.choose())) ◦ chick2 = as.data.set(spss.system.file("c4 ChickFlick.sav")) ◦ chick2 = as.data.frame(chick2)

File Functions Macs </3 Windows ◦ So what to do if you get the funky symbols?! Change the name of the column: ◦ By adding a new column ◦ chick2$newname = chick2$gender

File Functions Or by completing changing the column name: ◦ colnames(chick2)[1] = "gender2” ◦ Remember to replace the number with the right column number

Factor Functions Let’s start with some fake data: ◦ notfactor = rep(1:3, 50) Now, let’s make that data a factor variable.

Factor Functions factor(column name, levels = c(1,2…), labels = c(“labels”, “labels”,…). This example: factored = factor(notfactor, levels=c(1,2,3), labels = c("swiss", "feta", "gouda"))

Factor Functions We can also generate factors with the gl function ** gl( ◦ Number of levels, ◦ Cases in each level, ◦ Total cases, ◦ labels = c(“label”, …) ◦ ) **Not sure how often you’ll need this with real data.

Factor Functions GL function factored2 = gl(3, 50, 150, labels = c("swiss", "feta", "gouda"))

Factor Functions We will talk more about the factor() and relevel() functions in the ANOVA section.

Rearranging your data Install the reshape package and load the library! Load the Jiminy Cricket dataset.

Rearranging your data This data set is considered the WIDE format. ◦ In wide formats, rows are participants and columns are variables. There’s another way? ◦ In the LONG format, rows are the multiple measurements of the participants. ◦ Wutz?

Rearranging your data Going from WIDE to LONG ◦ melt() function Going from LONG to WIDE ◦ cast() function

Rearranging your data MELT( ◦ Dataframe name, ◦ id = c(“var”, “var”) – constant variables you do not want to change  These will stay their own column but get repeated when necessary ◦ measured = c(“var”, “var”) – dependent variables you want to combine into one column ◦ )

Rearranging your data longcricket = melt(cricket, id = c("ID", "Strategy"), measured = c("Success_Pre", "Succcess_Post")) Let’s look at what that did.

Rearranging your data

CAST( ◦ Dataframe name, ◦ Variables that are constant in math format ~ Long DV name, ◦ value = “label” ##usually this is value ◦ )

Rearranging your data widecricket = cast(longcricket, ID + Strategy ~ variable, value = "value") summary(widecricket)