psfFileChange: psfFileChange and psfFileChangeBATCH

psfFileChangeR Documentation

psfFileChange and psfFileChangeBATCH

Description

The .psf file is a script file that records the specifications used to run the USGS PeakFQ program (http://water.usgs.gov/software/PeakFQ/) for a station. psfFileChange and psfFileChangeBATCH modify the original .psf settings.

Usage

psfFileChange(
  file = tk_choose.files(default = "", caption =
    "Select file(s) to open & hold down Ctrl to choose more than 1 file", multi = TRUE,
    filters = matrix(c("Text file", ".psf", "Text file", ".PSF"), 4, 2, byrow = TRUE)),
  interactive = TRUE
)

psfFileChangeBATCH(
  path = tk_choose.dir(caption = "Select the directory with the .psf files")
)

Arguments

file

Input .psf file(s) to change specific SkewSE, GenSkew, and SkewOpt information to be selected through a file dialog.

interactive

If interactive is TRUE, then the user will select the filenames(s) to use for saving with the file dialog. In order to select more than one file, the user must hold down the Ctrl (Control) button while mouse clicking the chosen files. If interactive is FALSE, then the user will select the directory, via the directory dialog, to use for saving and the original filenames will be used.

path

Directory path of .psf files, to be selected through a directory dialog, to change specific SkewSE, GenSkew, and SkewOpt information. The user will be asked where to find the .psf files & then the user will be asked where to save the revised .psf files.

Details

psfFileChange searches for a character vector of patterns (SkewSE, GenSkew, and SkewOpt) in single or multiple .psf file(s) to replace. If the patterns are missing, then the patterns are added to the file(s). This is done for a single file or multiple files that the user selects. Although these changes are currently pre-determined, future versions may allow the user to change particular settings (for example, how outliers are handled).

psfFileChangeBATCH searches for a character vector of patterns (SkewSE, GenSkew, and SkewOpt) in a directory of .psf files to replace. If the patterns are missing, then the patterns are added to the files. This is done in a BATCH mode (whole directory of .psf files). Although these changes are currently pre-determined, future versions may allow the user to change particular settings (for example, how outliers are handled).

Value

Revised .psf text file(s)

Author(s)

Irucka Embry, Anne Hoos

Source

  1. r - How can I check if a file is empty? - Stack Overflow answered by Konrad Rudolph and edited by Geekuna Matata on Apr 23 2014. See https://stackoverflow.com/questions/23254002/how-can-i-check-if-a-file-is-empty.

  2. r - Better error message for stopifnot? - Stack Overflow answered by Andrie on Dec 1 2011. See https://stackoverflow.com/questions/8343509/better-error-message-for-stopifnot.

  3. RDocumentation: TclInterface tcltk. See https://www.rdocumentation.org/packages/tcltk/versions/3.3.1.

  4. James Wettenhall & Philippe Grosjean, File Open/Save dialogs in R tcltk, December 01, 2015. See https://web.archive.org/web/20160521051207/http://www.sciviews.org/recipes/tcltk/TclTk-file-open-save-dialogs/. Retrieved thanks to the Internet Archive: Wayback Machine

  5. Replacing nth line in a text file in R - Stack Overflow answered by Spacedman on Aug 1 2012. See https://stackoverflow.com/questions/11756353/replacing-nth-line-in-a-text-file-in-r.

  6. r - read csv files and perform function, then bind together - Stack Overflow answered by bjoseph on Jan 8 2015. See https://stackoverflow.com/questions/27846715/read-csv-files-and-perform-function-then-bind-together.

  7. multiple output filenames in R - Stack Overflow asked and edited by Gabelins on Feb 1 2013. See https://stackoverflow.com/questions/14651594/multiple-output-filenames-in-r.

  8. r - Regex return file name, remove path and file extension - Stack Overflow answered and edited by Ananda Mahto on Feb 25 20134. See https://stackoverflow.com/questions/15073753/regex-return-file-name-remove-path-and-file-extension/15073919.

Examples

## Not run: 
# Examples to change (a) .psf file(s) interactively and non-interactively

library("ie2misc")

psfFileChange() # default where interactive = TRUE
# Follow the file dialog instructions


# These are the rows that have been added or changed as a result of this function:

# SkewSE 0.361804179633127
# GenSkew 0.0104293904
# SkewOpt Weighted



psfFileChange(interactive = FALSE)
# Follow the file dialog instructions

# These are the rows that have been added or changed as a result of this function:

# SkewSE 0.361804179633127
# GenSkew 0.0104293904
# SkewOpt Weighted



psfFileChangeBATCH() # Follow the file dialog instructions


# These are the rows that have been added or changed as a result of this function:

# SkewSE 0.361804179633127
# GenSkew 0.0104293904
# SkewOpt Weighted

## End(Not run)



ie2misc documentation built on Sept. 20, 2023, 9:08 a.m.