This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from xiaoyuanf/master
get medol.R back
- Loading branch information
Showing
10 changed files
with
157 additions
and
72 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# author: Margot Chen | ||
# date: 2020-03-16 | ||
|
||
"This script carries out a linear regression for the Beijing pm2.5 dataset and | ||
exports the model to a user defined location. | ||
Usage: model.R --clean_path=<clean_data_path> --model_path=<model_path> | ||
"->doc | ||
|
||
# Load packages | ||
suppressMessages(library(tidyverse)) | ||
suppressMessages(library(here)) | ||
suppressMessages(library(docopt)) | ||
|
||
opt <- docopt(doc) | ||
|
||
# Main function | ||
main <- function(clean_path, model_path) { | ||
# Load data | ||
df_clean <- read.csv(here(clean_path)) | ||
|
||
# Linear regression | ||
model <- lm(pm2.5 ~ DEWP + TEMP + PRES + cbwd, data=df_clean) | ||
|
||
# Save model | ||
saveRDS(model, file = here(model_path)) | ||
|
||
# message for users | ||
print("Linear regression has run successfully!") | ||
} | ||
|
||
|
||
|
||
#' @param clean_path is the path to the cleaned data file. | ||
#' | ||
#' @param model_path is the location where the users would like to save the model. | ||
#' | ||
|
||
|
||
main(opt$clean_path, opt$model_path) |