Read in data.
parent
e3be17e56e
commit
91a9f20839
|
@ -1,22 +1,49 @@
|
||||||
---
|
---
|
||||||
title: "R Notebook"
|
title: "Reliability of SAM threat and challenge and COPE"
|
||||||
output: html_notebook
|
output: html_notebook
|
||||||
---
|
---
|
||||||
|
|
||||||
The [R plugin](https://www.jetbrains.com/help/pycharm/r-plugin-support.html) for IntelliJ-based IDEs provides
|
|
||||||
handy capabilities to work with the [R Markdown](https://www.jetbrains.com/help/pycharm/r-markdown.html) files.
|
|
||||||
To [add](https://www.jetbrains.com/help/pycharm/r-markdown.html#add-code-chunk) a new R chunk,
|
|
||||||
position the caret at any line or the code chunk, then click "+".
|
|
||||||
|
|
||||||
The code chunk appears:
|
```{r libraries, message=FALSE, warning=FALSE, include=FALSE, cache=FALSE}
|
||||||
```{r}
|
library(conflicted)
|
||||||
|
library(here)
|
||||||
|
library(tidyverse)
|
||||||
|
library(magrittr)
|
||||||
|
library(kableExtra)
|
||||||
|
|
||||||
|
conflicts_prefer(
|
||||||
|
readr::col_factor,
|
||||||
|
purrr::discard,
|
||||||
|
dplyr::filter,
|
||||||
|
dplyr::lag,
|
||||||
|
purrr::set_names,
|
||||||
|
tidyr::extract,
|
||||||
|
kableExtra::group_rows
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Type any R code in the chunk, for example:
|
```{r style, include=FALSE, cache=FALSE}
|
||||||
```{r}
|
styler::style_file(
|
||||||
mycars <- within(mtcars, { cyl <- ordered(cyl) })
|
here("statistical_analysis", "scale_reliability.Rmd"),
|
||||||
mycars
|
scope = "tokens",
|
||||||
|
indent_by = 4L
|
||||||
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
Now, click the **Run** button on the chunk toolbar to [execute](https://www.jetbrains.com/help/pycharm/r-markdown.html#run-r-code) the chunk code. The result should be placed under the chunk.
|
|
||||||
Click the **Knit and Open Document** to build and preview an output.
|
```{r read_data}
|
||||||
|
COL_TYPES <- cols(
|
||||||
|
.default = col_double(),
|
||||||
|
participant_id = col_factor(),
|
||||||
|
username = col_factor(),
|
||||||
|
device_id = col_factor(),
|
||||||
|
esm_trigger = col_factor(),
|
||||||
|
double_esm_user_answer_timestamp = col_double(),
|
||||||
|
datetime_lj = col_datetime(format = ""),
|
||||||
|
date_lj = col_date(format = ""),
|
||||||
|
time = col_factor(),
|
||||||
|
esm_user_answer = col_factor()
|
||||||
|
)
|
||||||
|
df_SAM <- read_csv(here("data", "raw", "df_esm_SAM_threat_challenge.csv"), col_types = COL_TYPES)
|
||||||
|
df_COPE <- read_csv(here("data", "raw", "df_esm_COPE.csv"), col_types = COL_TYPES)
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue