rdwd (version 1.2.0)

readDWD.stand: read subdaily/standard_format dwd data

Description

read subdaily/standard_format dwd data. Intended to be called via readDWD. All other observational data at dwdbase can be read with readDWD.data, except for the multi_annual and subdaily/standard_format data.

Usage

readDWD.stand(file, fast = TRUE, fileEncoding = "latin1",
  formIndex = formatIndex, ...)

Arguments

file

Name of file on harddrive, like e.g. DWDdata/subdaily_standard_format_kl_10381_00_akt.txt or DWDdata/subdaily_standard_format_kl_10381_bis_1999.txt.gz

fast

Logical: use readr::read_fwf instead of read.fwf? Takes 0.1 instead of 20 seconds but requires package to be installed. if fast=TRUE, fileEncoding is ignored. DEFAULT: TRUE

fileEncoding

read.table file encoding. DEFAULT: "latin1" (potentially needed on Linux, optional but not hurting on windows)

formIndex

Single object: Index used to select column widts and NA values. To use a current / custom index, see the source code of updateIndexes at https://github.com/brry/rdwd/blob/master/R/updateIndexes.R. DEFAULT: rdwd:::formatIndex

Further arguments passed to read.fwf or readr::read_fwf

Value

data.frame with column names as per formatIndex. "Q"-columns have "_parameter" appended to their name. A "Date" column has been added. NA-indicators have been processed into NAs.

See Also

readDWD

Examples

Run this code
# NOT RUN {
 # Excluded from CRAN checks, but run in localtests

link <- selectDWD(id=10381, res="subdaily", var="standard_format", per="r")
file <- dataDWD(link, dir=localtestdir(), read=FALSE)
sf <- readDWD(file)

sf2 <- readDWD(file, fast=FALSE) # 20 secs!
stopifnot(all.equal(sf, sf2))

plot(sf$Date, sf$SHK, type="l")

# Plot all columns:
if(FALSE){ # not run in any automated testing
tmp <- tempfile(fileext=".pdf")
char2fact <- function(x) 
 {
 if(all(is.na(x))) return(rep(-9, len=length(x)))
 if(!is.numeric(x)) as.factor(x) else x
 }
pdf(tmp, width=9)
par(mfrow=c(2,1),mar=c(2,3,2,0.1), mgp=c(3,0.7,0), las=1)
for(i in 3:ncol(sf)-1) plot(sf$Date, char2fact(sf[,i]), type="l", main=colnames(sf)[i], ylab="")
dev.off()
berryFunctions::openFile(tmp)
}
# }

Run the code above in your browser using DataCamp Workspace