composr

Create composite variables from survey data

https://github.com/morrphd/composr

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (13.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Create composite variables from survey data

Basic Info
  • Host: GitHub
  • Owner: morrphd
  • License: mit
  • Language: R
  • Default Branch: master
  • Size: 13.7 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created almost 2 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License Citation

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# composr




The goal of composr is to facilitate the analysis of survey data by automating the creation of composite variables. Using item naming conventions, composr groups items by construct and calculates basic descriptive statistics.

Label column names with the scale name and item number separated by an underscore (e.g., "Att_3"). Also, before using composr, ensure the data is cleaned and all recoding is completed.

## Installation

You can install the development version of composr from [GitHub](https://github.com/) with:

``` r
# install.packages("pak")
pak::pak("morrphd/composr")
```

## Example

To illustrate the functionality of composr, here is an example. First, create a test dataset with 3-6 variables, with 3-10 items each.

```{r}
testData <- data.frame("Case" = matrix(1:10, ncol = 1, nrow = 10))
x = 1

while(x <= round(runif(1, 3, 6))){ #Number of Variables
  y = 1
  while(y <= round(runif(1, 3, 10))){ #Number of Items
    temp <- round(runif(10, 1, 7)) #Number of Responses
    testData <- cbind(testData, as.data.frame(temp))
    colnames(testData)[colnames(testData) == "temp"] <-
      paste0("Var", x, "_", y)
    y = y + 1
    }
  x = x + 1
}

str(testData)
```

Next, load composr and run the *compose()* function to sort the items into groups.

```{r}
library(composr)
test <- compose(testData)
str(test)
```

The items are now sorted into their scales. To create the composite variable in the main dataset, run the *compute()* function for each variable.

```{r}
testData <- compute(test$Var1, testData)
tail(names(testData))
```

Notice that, in addition to adding a column for the composite variable, running this command also produced basic statistical information.

For questions, contact Ethan Morrow at emorrow3@illinois.edu.

Owner

  • Name: Ethan Morrow
  • Login: morrphd
  • Kind: user

Ph.D. Candidate Department of Communication University of Illinois Urbana-Champaign emorrow3@illinois.edu

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: composr
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Ethan
    family-names: Morrow
    email: emorrow3@illinois.edu
    affiliation: University of Illinois Urbana-Champaign
    orcid: 'https://orcid.org/0000-0002-4308-7607'
repository-code: 'https://github.com/morrphd/composr'
license: MIT
version: 0.0.0.9000
date-released: '2024-08-29'

GitHub Events

Total
Last Year