---
title: "350.week1b"
author: "William Revelle"
date: "04/01/24"
output:
  html_document: default
  word_document: default
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
options(width=100) #This sets the width of the output, 80 seems to be the default and is too narrow
```
## Using the psych package for descriptive statistics 


```{r}
library(psych) #make it active
library(psychTools)
#specifiy a file to read (e.g.) 
filename <- "http://personality-project.org/r/datasets/simulation.txt"
#read the file
my.data <- read.file(filename)
```

#Get basic descriptives

First, find out how many rows and columns and then, if not too many, show a few
```{r}
dim(my.data)
names(my.data)
headTail(my.data)
```

Then get the basic desriptive statistics
```{r}
describe(my.data)
```

#Basic descriptive graphs
Box plots and violins

```{r}
boxplot(my.data)
violinBy(my.data)
```

#descriptives by groups
```{r}
describeBy(my.data,"sex")
violinBy(my.data,grp="sex")
```
#Now lets try some bivariate descriptives -- The correlation

```{r}
lowerCor(my.data) #just find the correlations
corPlot(my.data)  #show them in a heat map
corPlot(my.data, numbers=TRUE) #with the values
corPlot(my.data, numbers = TRUE, stars=TRUE) # with magic astericks
corPlot(my.data,numbers=TRUE,upper=FALSE,diag=FALSE)
```
# Lets try some more conventional ways of showing it
```{r}
corr.test(my.data)
```

#What about bootstrap resampling?
```{r}
ci <- corCi(my.data)
ci
```