Skip to content

Commit

Permalink
20241002 - update
Browse files Browse the repository at this point in the history
  • Loading branch information
Petersen committed Oct 2, 2024
1 parent 5d3ccff commit 341173e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions 15-Factor-Analysis-PCA.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,32 @@ library("tinytex")
library("knitr")
library("rmarkdown")
```

### Load Data {#loadData-factorAnalysis}

### Prepare Data {#prepareData-factorAnalysis}

#### Add Missing Data {#addMissingData-factorAnalysis}

Adding missing data to dataframes helps make examples more realistic to real-life data and helps you get in the habit of programming to account for missing data.
For reproducibility, I set the seed below.
Using the same seed will yield the same answer every time.
There is nothing special about this particular seed.

`HolzingerSwineford1939` is a data set from the `lavaan` package [@R-lavaan] that contains mental ability test scores (`x1``x9`) for seventh- and eighth-grade children.

```{r}
set.seed(52242)
varNames <- names(HolzingerSwineford1939)
dimensionsDf <- dim(HolzingerSwineford1939)
unlistedDf <- unlist(HolzingerSwineford1939)
unlistedDf[sample(
1:length(unlistedDf),
size = .15 * length(unlistedDf))] <- NA
HolzingerSwineford1939 <- as.data.frame(matrix(
unlistedDf,
ncol = dimensionsDf[2]))
names(HolzingerSwineford1939) <- varNames
vars <- c("x1","x2","x3","x4","x5","x6","x7","x8","x9")
```

0 comments on commit 341173e

Please sign in to comment.