Skip to contents

This package is designed to provide a collection of simple, standardized and approved R code snippets and functions that are commonly used across various projects at Utah Tech University. utDataStoR is greatly enhanced when used in tandem with utHelpR package.

Follow the steps below to get started:

Loading the Package

Once installed, load the package into your R session:

Using the Functions

The package includes a variety of functions that you can use in your projects. Here are a few examples:

Example Function 1: make_headcount_sql

First you will want to make sure you are choosing the correct sql you can reference documentation in the Articles tab. In this case you would want to look at vignette("headcount")

Your project must have a folder called sql you can make one by hand or use the utHelpR package

# Example usage of a make_headcount_sql function
utDataStoR::make_headcount_sql("headcount.sql", "census")

This will write the desired sql script (headcount.sql) to a .sql file housed in sql/ folder

you could then run the sql by using the utHelpR package

head_count_df <- utHelpR::get_data_from_sql_file("headcount.sql")

Example Function 2: display_sql_with_comments

# Example usage of a display_sql_with_comments function
utDataStoR::display_sql_with_comments("headcount", "headcount_census.sql")
#> /*
#> Census/3rd Week headcount
#> */
#> 
#> SELECT a.term_desc,
#>        COUNT(a.student_id) AS census_headcount
#> FROM export.student_term_level_version a
#>          LEFT JOIN export.term b
#>                    ON a.term_id = b.term_id
#> WHERE a.is_enrolled IS TRUE
#>   AND a.is_primary_level IS TRUE
#>   AND a.version_desc = 'Census'
#>   AND DATE_PART('year', NOW()) - b.academic_year_code :: INT <= 5 -- Current year plus last 5 years
#> GROUP BY a.term_desc
#> ORDER BY a.term_desc;

Documentation

Detailed documentation for each function is available on the pkgdown site. You can also access the documentation within R using the ? help operator: ?make_headcount_sql or ?display_sql_with_comments

Contributing

We welcome contributions from the Utah Tech University community! If you have suggestions for new functions or improvements to existing ones, participate in GitHub/discussion please submit a pull request on our GitHub repository.

Getting Help

If you encounter any issues or have questions, please open an issue on GitHub/issues or contact the package maintainer at .


Feel free to customize this guide further to better fit your specific needs! If you have any other questions or need additional help, just let me know.