While driftR is designed to work seamlessly with output from YSI Multiparameter V2 Sonde, YSI EXO2, and Onset U24 Conductivity Logger instruments, it can also be used to correct data from other sources. There are only a few steps that would be needed to get data into a tidy driftR format. Below are example data after they have been imported using the dr_read() function. This is the expected format that driftR requires, so data from other sources must be modified to this configuration.

The sections below detail pre-processing steps that you may have to take to prepare your data for use with driftR.

Importing Data

Data come in a variety of formats, and importing them into R can occasionally be a challenge.

  • If your data are included in a flat file like a csv, tsv, txt, or another delimited file format, we recommend using the readr package.
  • If your data are included in a Microsoft Excel file, we recommend using the readxl package.
  • If your data are included in a SPSS, SAS, or Stata file, we recommend using the haven package.
  • If your data are in a Microsoft Access database, we recommend using the RODBC package. This will require a Windows computer, 32-bit R, and either Microsoft Access or the appropriate drivers installed.
  • If your data are in another database format, we recommend this article on using Databases with R.

All of the example code below assumes that you have a data frame named waterData.

Metadata

No metadata should be stored in the observations. If metadata are present, remove them using the following technique. (This example assumes that metadata is stored in row 1):

If there are multiple lines of metadata, they can be removed like so:

Tibbles

Given the typically large data sets for these intruments, we encourage (but do not enforce) data to be stored as tibbles. Tibbles are the tidyverse implementation of data frames. They print in a more organized manner and they behave in a more stable fashion. To convert your data to a tibble, use the function as_tibble():

Variable Names

Variable names should be short and descriptive. We recommend using camelCase or snake_case to name variables. Use the rename() function from dplyr to accomplish this. The function accepts the data frame name followed by a comma and the new name set equal to the old name:

If you have a number of variables to rename, you can pipe them together:

Specific Variables

Date and Time

Please check out our vignette on dates and times in driftR for additional details on how these should be formatted.

Temperature

driftR makes no direct use of the Temp data included in output. The weathermetrics package includes functions for conversions between Celsius and Fahrenheit.

Other Variables

Beyond date and time data, all variables should be stored as either double, integer, or numeric values:

Building Pipes with Date, Time, and Other Functions

You can integrate all of the non-tidyverse functions described here into mutate() function calls. The mutate() function is from the dplyr package.

Removing Unnecessary Variables

Finally, if there are unnecessary variables left in your data set at the end of the pre-processing stage, you can use the select() function from dplyr to remove them. The function accepts the data frame name followed by a comma and a list of the variables to be removed inside -c(varlist):

Like all other dplyr functions, select() can be included in a pipe as well.