Skip to content

Commit

Permalink
Merge pull request #717 from KingArthur0205/branch-7
Browse files Browse the repository at this point in the history
CHEXI_Lin_2019.r
  • Loading branch information
ben-domingue authored Nov 27, 2024
2 parents 2b7615a + 9520558 commit cdd0acd
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions data/CHEXI_Lin_2019.r
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Data: https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/YRLEAY
library(haven)
library(dplyr)
library(tidyr)
library(openxlsx)
library(readxl)

df <- read_excel("no_Names_coding-0623_forupload.xlsx", sheet = "data")
df$id <- seq_len(nrow(df))
df <- df |>
select(id, starts_with("item"))
df[df == 9999] <- NA
df <- df[!apply(df[, -which(names(df) == "id")], 1, function(row) all(is.na(row))), ]
df <- pivot_longer(df, col=-id, values_to="resp", names_to="item")

save(df, file="CHEXI_Lin_2019.Rdata")
write.csv(df, "CHEXI_Lin_2019.csv", row.names=FALSE)

0 comments on commit cdd0acd

Please sign in to comment.