Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ToolsCollectiveR/eva_db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nokutdb

Install from GitHub

devtools::install_github("nokut/nokutdb")

Basic Usage

library(nokutdb)

# Import all CSV files from a directory
results <- import_survey_data("path/to/csv/files")

# Check import results
print(sprintf("Imported %d rows, %d failed", 
              results$successful, results$failed))

Import with Labels

The importer automatically looks for label files with the naming convention filename_labels.csv in the same directory. For example, if your data file is called survey_responses.csv, the importer will look for survey_responses_labels.csv.

Label files should have at least two columns:

variable: The variable name that matches the column in the data file label: The label text for that variable

Example label file content:

variable,label
q1,"How satisfied are you with the course?"
q2,"How useful did you find the learning materials?"
q3,"How would you rate the teaching quality?"

Controlling import behavior:

# Import without labels
results <- import_survey_data("path/to/csv/files", import_labels = FALSE)

CSV file format

The importer expects CSV files with the following characteristics:

First row contains variable names Each subsequent row contains one respondent's answers Values can be numeric or text Values can include labels in the format "value|label" (e.g., "5|Very satisfied")

Database Structure

The importer interacts with the following database tables:

surveys: Stores information about each survey survey_fields: Stores the fields (questions) for each survey respondents: Stores respondent information survey_responses: Links respondents to surveys response_values: Stores the actual response values

Implementation Details

Label Handling

Labels are stored in the survey_fields table in the database. If a data value includes a label (in the format "value|label"), the importer will:

  1. Store the value in the value_text or value_number column of response_values
  2. Extract just the value part for storage

Requirements

R 3.5.0 or later RMySQL package DBI package Access to a MySQL/MariaDB database with the NOKUT survey schema

Troubleshooting

If you encounter issues with the import process:

Check that your database connection is correctly configured Verify that your CSV files follow the expected format Ensure your database schema matches the expected structure For large imports, consider increasing the R memory limit with memory.limit(size=4000)

About

eva_db

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages