尚未收集仓库信息。
尚未检测到更新。GitHub 发布版本后会显示在这里。
R package for importing and cleaning LASA data in R
翻译准备中
取自仓库 README
正在加载完整 README。
查看完整 README ↗CleanLASA helps you work with LASA (Longitudinal Aging Study Amsterdam)
data in R. LASA data comes as SPSS (.sav) files, and each file uses
its own short-hand variable names and numeric codes, which change
slightly from one measurement wave to the next. Reading such a file
with a generic tool like haven::read_sav() gives you a data frame of
bare numbers with no explanation of what they mean.
CleanLASA fixes that. Point it at a LASA .sav file and it:
4 reads as "married" instead of just 4;All of this metadata lives in one bundled database
(lasa_label_db()), hand-transcribed from LASA's own documentation
and shipped with the package. It gets more complete and more accurate
with every package update, and you can also patch your own local copy
with manual_update_lasa_labels() if something needs a quick, local
fix.
CleanLASA needs R 4.0 or later. Install the latest release (v1.0.0) from GitHub with:
# install.packages("remotes")
remotes::install_github("Highmeadows/[email protected]")
or the development version, with changes that haven't been released yet, with:
remotes::install_github("Highmeadows/CleanLASA")
See NEWS.md for what changed in each release.
The main function is read_lasa_sav(). Give it the path to a LASA
.sav file and it works out the rest from the file name -- reading the
file, matching its columns to LASA's documentation, attaching labels,
turning categorical variables into R factors, and renaming columns to
a name that's the same across every wave:
library(CleanLASA)
data <- read_lasa_sav("LASAB046.sav") # LASA wave B, file code 046
# Check whether anything didn't match:
lasa_label_report(data, problems_only = TRUE)
Z files such as LASAZOA1.sav store several waves side by side
(boak, coak, doak, ...). With format_as_long = TRUE you get
them in long format instead: one row per respondent per wave, with a
Wave column, a Time column counting the waves since the
respondent's baseline, and one oak column. transform_lasa_data()
converts any LASA data -- including merged files -- between long and
wide format:
oa <- read_lasa_sav("LASAZOA1.sav", format_as_long = TRUE)
oa_wide <- transform_lasa_data(oa, format = "wide") # boak, coak, ...
Not sure which file code you need? lasa_topics() searches LASA's
topics and themes for you, and lasa_var_info() opens LASA's own
documentation for a topic or file code:
lasa_topics(topic = "physical activity")
lasa_var_info("046")
This README is just a summary. The package
vignette
is a full, step-by-step tutorial that walks through every function with
worked examples -- how the file-name-based matching works, every option
read_lasa_sav() offers (fuzzy matching, name corrections, converting
to factors/numeric, standardizing names and labels across waves),
what's inside the label database, how to record your own corrections,
how to reshape data between long and wide format, and how to search
LASA's topic index and documentation. Start there if you're new to the
package.
| Function | Description |
|---|---|
read_lasa_sav() | Reads a LASA .sav file and labels it using lasa_label_db(), based on the wave/file code parsed from the file name |
apply_lasa_labels() | Applies lasa_label_db() labels to any data frame, resolving file code/wave explicitly or from stored provenance |
transform_lasa_data() | Transforms LASA data between wide format (one row per respondent, as in Z files) and long format (one row per respondent per wave, with Wave and Time columns) |
manual_update_lasa_labels() | Hand-corrects or adds a variable/value label in your local copy of the database |
restore_lasa_labels() | Undoes manual corrections (entirely, or scoped) and/or rebuilds the local database cache from the bundled one |
lasa_label_db() | Returns the label database currently in effect (bundled snapshot + any local updates) |
lasa_label_report() | Returns variables that could not be matched to the corresponding LASA documentation |
lasa_topics() | Searches the bundled LASA topic database for topics, themes, and file codes |
lasa_var_info() | Finds and opens a topic's or file code's variable-information PDF or LASA webpage, resolved live from the LASA website |
Full function reference and articles are available at: https://highmeadows.github.io/CleanLASA/