-
Notifications
You must be signed in to change notification settings - Fork 8
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 #102 from tianshu129/develop
v2.0.0
- Loading branch information
Showing
38 changed files
with
1,966 additions
and
185 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: foqat | ||
Type: Package | ||
Title: Field Observation Quick Analysis Toolkit | ||
Version: 1.7.2 | ||
Version: 2.0.0 | ||
Author: Tianshu Chen | ||
Maintainer: Tianshu Chen <[email protected]> | ||
Description: Tools for quickly processing and analyzing | ||
|
@@ -21,7 +21,7 @@ BugReports: https://github.com/tianshu129/foqat/issues | |
Depends: R (>= 3.5.0) | ||
Imports: lubridate, magrittr, dplyr, plyr, stats, stringr, utils, | ||
lmodel2, reshape2, ggplot2, ggplotify, gridExtra, | ||
scales, rvest, xml2 | ||
scales, rvest, xml2, ggnewscale, patchwork | ||
License: GPL-3 | file LICENSE | ||
Encoding: UTF-8 | ||
LazyData: true | ||
|
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
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
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,58 @@ | ||
#' Calculate daily maximum-8-hour ozone in batch | ||
#' | ||
#' Calculates daily maximum-8-hour ozone in batch | ||
#' | ||
#' This function can calculate daily maximum-8-hour ozone in batch. | ||
#' @param df dataframe of time series for ozone and other related parameters. | ||
#' @param starthour numeric, start hour for calculating 8-hour ozone. By default, it equals to 0. | ||
#' @param endhour numeric, end hour for calculating 8-hour ozone. By default, it equals to 16 which means averaging ozone between 16~23. | ||
#' @param nh numeric. The number of effective hourly concentrations per 8-hour period. | ||
#' @param nc numeric. The number of effective 8-hour average concentrations per day. | ||
#' @param na.rm logical. Should missing values (including NaN) be omitted from the calculations? | ||
#' @param outputmode numeric, the format of the output, possible value: 1 or 2. See 'value' for the results of filling in 1 or 2. | ||
#' @return a dataframe depends on the value of | ||
#' 'outputMode'. Value 1 will output 1 list which incudes | ||
#' 1 table (maximum-8-hour ozone). Value 2 will output | ||
#' 1 list which contains 4 tables (8-hour ozone, | ||
#' statistics of the number of effective hourly | ||
#' concentrations in each 8-hour average concentration, | ||
#' statistics of the number of effective 8-hour average | ||
#' concentrations in each day, maximum-8-hour ozone). | ||
#' | ||
#' @export | ||
#' @importFrom dplyr left_join | ||
|
||
dm8n_batch<-function(df, starthour = 0, endhour=16, nh=6, nc=14, na.rm = TRUE, outputmode = 1){ | ||
xi_df=df[,c(1,2)] | ||
xi=dm8n_np(xi_df, colid = 1, colio = 2, starthour = 0, endhour=16, nh=6, nc=14, na.rm = TRUE, outputmode = 2) | ||
xi_D8_final=xi[["D8"]] | ||
xi_D8_count_final=xi[["D8_count"]] | ||
xi_D8_count_by_day_final=xi[["D8_count_by_day"]] | ||
xi_DMAX8_final=xi[["DMAX8"]] | ||
|
||
if(ncol(df)>2){ | ||
for(i in 3:ncol(df)){ | ||
xi_df=df[,c(1,i)] | ||
xi=dm8n_np(xi_df, colid = 1, colio = 2, starthour = 0, endhour=16, nh=6, nc=14, na.rm = TRUE, outputmode = 2) | ||
xi_D8=xi[["D8"]] | ||
xi_D8_count=xi[["D8_count"]] | ||
xi_D8_count_by_day=xi[["D8_count_by_day"]] | ||
xi_DMAX8=xi[["DMAX8"]] | ||
#left_join | ||
xi_D8_final= left_join(xi_D8_final, xi_D8, by = names(xi_D8_final)[c(1,2,3)]) | ||
xi_D8_count_final= left_join(xi_D8_count_final, xi_D8_count, by = names(xi_D8_count_final)[c(1,2,3)]) | ||
xi_D8_count_by_day_final= left_join(xi_D8_count_by_day_final, xi_D8_count_by_day, by = names(xi_D8_count_by_day_final)[1]) | ||
xi_DMAX8_final= left_join(xi_DMAX8_final, xi_DMAX8, by = names(xi_DMAX8_final)[1]) | ||
} | ||
} | ||
|
||
#set out put | ||
if(outputmode==2){ | ||
names(xi_D8_count_final)[c(-1,-2,-3)]=names(df)[-1] | ||
names(xi_D8_count_by_day_final)[-1]=names(df)[-1] | ||
results = list(D8=xi_D8_final, D8_count=xi_D8_count_final, D8_count_by_day=xi_D8_count_by_day_final, DMAX8=xi_DMAX8_final) | ||
}else{ | ||
results = xi_DMAX8_final | ||
} | ||
|
||
} |
Oops, something went wrong.