---
title: "Standard scores"
author: "Tera Letzring"
date: "September 2017"
output: html_document
---

```{r setup, include=FALSE}

knitr::opts_chunk$set(echo = TRUE)
```

```{r set wd and read in data}

#set the working directory (wd) to the folder that contains the script file, and read in the data
x <- getwd()
setwd(x)

SDdata = read.table("schooldays.csv", header=T, sep=",")  
head(SDdata)

attach(SDdata)
```

```{r standard scores}

#create z-scores and add new variable to existing data frame. center = TRUE subtracts the mean, scale = TRUE divides by standard deviation
SDdata$Zscores <- scale (absent, center = TRUE, scale = TRUE)
mean(SDdata$Zscores)
sd(SDdata$Zscores)

#create T-scores and add to existing data frame
SDdata$Tscores <- 50 + (10*SDdata$Zscores)
mean(SDdata$Tscores)
sd(SDdata$Tscores)

#output the first 6 rows of the schooldays data set
head(SDdata)
```
