Learn R Programming

rdwd (version 0.7.0)

createIndex: Create file and meta index of the DWD CDC FTP Server

Description

This is mainly an internal function. Create data.frames out of the vector index returned by indexDWD. For fileIndex (the first output element) createIndex tries to obtain res, var, pe,r file, id, start and end from the paths. If meta=TRUE, metaIndex and geoIndexAll are also created. They combine all Beschreibung files into a single data.frame. If you create your own index as suggested in selectDWD (argument findex), you can read the produced file as shown in the example section.

Usage

createIndex(paths,
  base = "ftp://ftp-cdc.dwd.de/pub/CDC/observations_germany/climate",
  dir = "DWDdata", fname = "fileIndex.txt", meta = FALSE,
  metadir = "meta", mname = "metaIndex.txt", gname = "geoIndexAll.txt",
  quiet = FALSE, ...)

Arguments

paths

Char: vector of DWD paths returned by indexDWD called with the same base value as this function

base

Main directory of DWD ftp server, defaulting to observed climatic records. DEFAULT: ftp://ftp-cdc.dwd.de/pub/CDC/observations_germany/climate

dir

Char: writeable directory name where to save the main output(s). Created if not existent. DEFAULT: "DWDdata" at current getwd()

fname

Char: Name of file in dir in which to write fileIndex. Use fname="" to suppress writing. DEFAULT: "fileIndex.txt"

meta

Logical: should metaIndex also be created from fileIndex? Uses dataDWD to download files if not present. DEFAULT: FALSE

metadir

Char: Directory (subfolder of dir) where original description files are downloaded to if meta=TRUE. vPassed to dataDWD. "" to write in dir. DEFAULT: "meta"

mname

Char: Name of file in dir (not metadir) in which to write metaIndex. Use mname="" to suppress writing. DEFAULT: "metaIndex.txt"

gname

Ditto for geoIndexAll. DEFAULT: "geoIndexAll.txt"

quiet

Logical: Suppress messages about directory / filename? DEFAULT: FALSE

Further arguments passed to dataDWD for the meta part.

Value

invisible data.frame (or if meta=TRUE, list with two data.frames) with a number of columns inferred from the paths. Each is also written to disc.

See Also

indexDWD, fileIndex, metaIndex, selectDWD

Examples

Run this code
 # Not tested with R CMD check because of file writing
link <- "/daily/kl/historical/tageswerte_00699_19490101_19580630_hist.zip"
ind <- createIndex(link, dir=tempdir())
ind
link2 <- "/daily/kl/historical/KL_Tageswerte_Beschreibung_Stationen.txt"
link3 <- "/daily/kl/recent/KL_Tageswerte_Beschreibung_Stationen.txt"
ind2 <- createIndex(c(link,link2,link3), dir=tempdir(), meta=TRUE)
lapply(ind2, head)


# For real usage, see last part of
if(interactive())
browseURL("https://github.com/brry/rdwd/blob/master/R/meta.R")
# where fileIndex and metaIndex are added to the package

# Read results in later:
 ## files normally not yet available:
fileIndex2 <- read.table("DWDdata/fileIndex.txt", sep="\t", header=TRUE,
                         colClasses="character")
metaIndex2 <- read.table("DWDdata/metaIndex.txt", sep="\t", header=TRUE, as.is=TRUE)


Run the code above in your browser using DataLab