Skip to content

Commit 88b701a

Browse files
committed
updating survey link in index.qmd, adding analysis code
1 parent d44319b commit 88b701a

File tree

1 file changed

+46
-11
lines changed

1 file changed

+46
-11
lines changed

index.qmd

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ QUALTRICS_FULL_URL <- "https://cornell.yul1.qualtrics.com/jfe/form"
4848
4949
# Public Qualtrics URL for day 2
5050
51-
QUALTRICS_SURVEY <- "SV_cNkhKL69K2Ob7o2"
51+
QUALTRICS_SURVEY <- "SV_8Bbgqex21KyYDFY"
5252
5353
# Time when this was posted (discard anything before that)
5454
55-
QUALTRICS_STIME <- ymd_hms("2025-04-30 23:59:00")
56-
QUALTRICS_ETIME <- ymd_hms("2025-05-26 23:59:00")
55+
QUALTRICS_STIME <- ymd_hms("2025-07-01 00:00:01")
56+
QUALTRICS_ETIME <- ymd_hms("2025-08-26 23:59:00")
5757
5858
5959
if (!dir.exists(here::here("data"))) {
@@ -68,13 +68,13 @@ if (!dir.exists(here::here("data"))) {
6868
Here we will demonstrate how to preserve raw survey data and also how to handle confidential data. We will do so with data from a survey that you all will provide responses to. Some of the questions are meant to elicit "confidential" information from you as responses. You should not give your actual confidential information in response to these questions. We will use these questions as way to teach how to preserve data when some data are confidential.
6969

7070

71-
## Live Survey
71+
## Survey
7272

7373
Please fill out this survey:
7474

7575
<`r file.path(QUALTRICS_FULL_URL,QUALTRICS_SURVEY)`>
7676

77-
### Live Results
77+
### Results
7878
```{r downloaddata,include=FALSE}
7979
# download data to local location
8080
@@ -83,23 +83,22 @@ if (Sys.getenv("QUALTRICS_API_KEY") != "") {
8383
data.raw <- fetch_survey(surveyID = QUALTRICS_SURVEY, verbose = TRUE)
8484
data <- data.raw |>
8585
filter(Status != "Survey Preview") |>
86-
filter(Consent == "I agree that my data will be used in the manner described.") |>
86+
filter(consent == "Yes") |>
8787
filter(StartDate > QUALTRICS_STIME & EndDate < QUALTRICS_ETIME) |>
8888
# renaming variables
89-
select(StartDate,EndDate,Status,Finished,RecordedDate,ResponseId,Consent,Preferred_topic,Degree,JEL_primary,
90-
starts_with("JEL_secondary"),starts_with("Versioning_"))
89+
select(StartDate,EndDate,Status,Finished,RecordedDate,ResponseId,consent,age_1,gender,education,num_tabs_1,name_confidential,number_confidential)
9190
} else {
9291
data <- data.frame()
9392
}
9493
9594
```
9695

97-
```{r create_table2, results='asis', include=TRUE,echo=FALSE,message=FALSE}
96+
```{r gender_table, results='asis', include=TRUE,echo=FALSE,message=FALSE}
9897
9998
if ( nrow(data) >0 ) {
10099
data |>
101-
select(Preferred_topic) |>
102-
group_by(Preferred_topic) |>
100+
select(gender) |>
101+
group_by(gender) |>
103102
summarise(Frequency=n()) |>
104103
ungroup() |>
105104
mutate(Percent = round(Frequency/nrow(data)*100,2)) -> data.table
@@ -110,6 +109,42 @@ data.table |> kable()
110109
}
111110
```
112111

112+
```{r education_table, results='asis', include=TRUE,echo=FALSE,message=FALSE}
113+
if ( nrow(data) >0 ) {
114+
data |>
115+
select(education) |>
116+
group_by(education) |>
117+
summarise(Frequency=n()) |>
118+
ungroup() |>
119+
mutate(Percent = round(Frequency/nrow(data)*100,2)) -> data.table
120+
121+
data.table |> kable()
122+
} else {
123+
cat("No data yet. Check back later.")
124+
}
125+
```
126+
127+
```{r age_table, results='asis', echo=FALSE, message=FALSE}
128+
if (nrow(data) > 0) {
129+
cat("### Age")
130+
var_data <- data$age_1
131+
summary_stats <- data.frame(
132+
Statistic = c("Count", "Mean", "Median", "Min", "Max", "Sts. Dev."),
133+
Value = c(
134+
sum(!is.na(var_data)),
135+
mean(var_data, na.rm = TRUE),
136+
median(var_data, na.rm = TRUE),
137+
min(var_data, na.rm = TRUE),
138+
max(var_data, na.rm = TRUE),
139+
sd(var_data, na.rm = TRUE)
140+
)
141+
)
142+
print(knitr::kable(summary_stats, digits = 2))
143+
} else {
144+
cat("No data yet. Check back later.")
145+
}
146+
```
147+
113148
## Why
114149

115150
Lorem ipso facto.

0 commit comments

Comments
 (0)