library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.2     ✔ tibble    3.3.0
## ✔ lubridate 1.9.4     ✔ tidyr     1.3.1
## ✔ purrr     1.1.0     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
library(pastecs)
## 
## Attaching package: 'pastecs'
## 
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## The following object is masked from 'package:tidyr':
## 
##     extract
setwd("C:/Users/KaeRo/Desktop/R Studio/Reseach Data Selection")
library(readxl)
district <- read_excel("district.xls")

Cleaned_hypo<-district %>% select(DPSTTOSA,DPSTWHFP) %>% drop_na()
  1. From the data you have chosen, select a variable that you are interested in
# Variable I selected is DPSTWHFP, meaning percentage of White Teachers in a District
  1. Use pastecs::stat.desc to describe the variable. Include a few sentences about what the variable is and what it’s measuring.
pastecs::stat.desc(Cleaned_hypo$DPSTWHFP, norm=T)
##       nbr.val      nbr.null        nbr.na           min           max 
##  1.203000e+03  1.200000e+01  0.000000e+00  0.000000e+00  1.000000e+02 
##         range           sum        median          mean       SE.mean 
##  1.000000e+02  8.616490e+04  8.240000e+01  7.162502e+01  8.073503e-01 
##  CI.mean.0.95           var       std.dev      coef.var      skewness 
##  1.583973e+00  7.841329e+02  2.800237e+01  3.909580e-01 -1.198382e+00 
##      skew.2SE      kurtosis      kurt.2SE    normtest.W    normtest.p 
## -8.494993e+00  2.477781e-01  8.789401e-01  8.250715e-01  2.703655e-34
summary(Cleaned_hypo$DPSTWHFP)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    0.00   58.85   82.40   71.63   92.60  100.00
#The variable shows the percentage of teachers that are white in a school district. You can see that there are some school districts with no white teachers (0%) and some with all white teachers (100%).
  1. Remove NA’s if needed using dplyr:filter (or anything similar)
#Done on line 19
  1. Provide a histogram of the variable (as shown in this lesson)
hist(Cleaned_hypo$DPSTWHFP)

  1. transform the variable using the log transformation or square root transformation (whatever is more appropriate) using dplyr::mutate or something similar
transformed_cleaned_district<- Cleaned_hypo %>% mutate(DPSTWHFP_log=log(DPSTWHFP))
  1. provide a histogram of the transformed variable
hist(transformed_cleaned_district$DPSTWHFP_log)