Learn R Programming

DataMetProcess (version 1.0.8)

calculateDMY: Calculation of daily, monthly and annual scales

Description

Performs data processing on an hourly scale for daily, monthly or annual scales

Usage

calculateDMY(
  data = NULL,
  col_date = NULL,
  col_sum = NULL,
  col_mean = NULL,
  col_max = NULL,
  col_min = NULL,
  n.round = 2,
  type = c("Daily", "Monthly", "Yearly")
)

Value

Data frame with the defined scale

Arguments

data

Data frame containing the data

col_date

String with the column of data containing the date (R default date: "%Y-%m-%d")

col_sum

String with the column of data to apply the sum process

col_mean

String with the column of data to apply the averaging process

col_max

String with data column to find maximum

col_min

String with data column to find minimum

n.round

Integer, number of decimal places

type

string, receives "Daily", "Monthly" or "Yearly" ("Daily" default). Defines the scale of processing to be performed

Examples

Run this code
address <-
 base::system.file("extdata",
                    "ex1_inmet.CSV",
                    package = "DataMetProcess")

df <-
read.table(
  address,
  h=TRUE,
  sep = ";",
  dec = ",",
  skip = 8,
  na.strings = -9999,
  check.names = FALSE
)

df$Data = as.Date(df$Data,format = "%d/%m/%Y")

df.d <-
  calculateDMY(
    data = df,
    col_date = "Data",
    col_sum = colnames(df)[c(3,7)],
    col_mean = colnames(df)[-c(1,2,3,7)],
    type = "Daily"
  )

df.m <-
  calculateDMY(
    data = df.d,
    col_date = "Date",
    col_sum = colnames(df.d)[c(2)],
    col_mean = colnames(df.d)[-c(1,2)],
    type = "Monthly"
  )

df.a <-
  calculateDMY(
    data = df.m,
    col_date = "Date",
    col_sum = colnames(df.m)[c(2)],
    col_mean = colnames(df.m)[-c(1,2)],
    type = "Yearly"
  )


Run the code above in your browser using DataLab