numeric vectors of unit multiplier and offset respectivaly
date.field
field name used for date and time. Default is "timestamp", as used for SMET format.
station.field
field name used for station ID. Default is "station_id", as used for SMET format.
header.fields
names used for the SMET header. Defaults are c("longitude","latitude","station_id" ,"altitude","location")
variables
(optional) selection of variables hich can be exported to SMET formats. It is used only in case of two or more stations.
force.multistation
logical value. If it is TRUE the method is forced to return a list of SMET objects even in case of only one station
metaparam
metedata optional data frame containig meta info on variables. It can be entered as an attribute of object. See the structure of metaparam of meteofrance.It must contains SMET_ID,SMET_UNIT_MULTIPLIER,SMET_UNIT_OFFSET columns/fields.
file
full filename of the reference SMET filename (not considered when object is character .
Examples
data(meteofrance)
## Choose a particular station
station_id <- unique(meteofrance$station_id)[3]
variables <- c("timestamp","DW","VW","TA","TD","RH","MFR_rr24",
"MFR_tn12","MFR_tn24","MFR_tx12","MFR_tx24","HS","HS_fresh")
header <- c("longitude","latitude","station_id" ,"altitude","location")
names(header) <- header
data <- meteofrance[meteofrance$station_id==station_id,c(header,variables)]
metaparam <- attr(meteofrance,"metaparam")
metaparam <- metaparam[metaparam$SMET_ID %in% names(data),]
header <- lapply(X=header,FUN=function(x,data) {data[1,x]},data=data)
data <- data[,variables]
attr(data,"header") <- header
attr(data,"metaparam") <- metaparam
sm <- as.smet(data)
# In case of multiple station, it return a list of SMET-class objects:
sm_multi <- as.smet(meteofrance,variables=variables)
Results
R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(RSMET)
Loading required package: stringr
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/RSMET/as.smet.Rd_%03d_medium.png", width=480, height=480)
> ### Name: as.smet
> ### Title: Coerces an object to a 'smet-class' object
> ### Aliases: as.smet as.smet,character-method as.smet,data.frame-method
> ### as.smet,list-method as.smet,smet-method
>
> ### ** Examples
>
> data(meteofrance)
>
>
> ## Choose a particular station
> station_id <- unique(meteofrance$station_id)[3]
>
>
>
>
> variables <- c("timestamp","DW","VW","TA","TD","RH","MFR_rr24",
+ "MFR_tn12","MFR_tn24","MFR_tx12","MFR_tx24","HS","HS_fresh")
> header <- c("longitude","latitude","station_id" ,"altitude","location")
> names(header) <- header
>
>
>
> data <- meteofrance[meteofrance$station_id==station_id,c(header,variables)]
> metaparam <- attr(meteofrance,"metaparam")
> metaparam <- metaparam[metaparam$SMET_ID %in% names(data),]
> header <- lapply(X=header,FUN=function(x,data) {data[1,x]},data=data)
> data <- data[,variables]
> attr(data,"header") <- header
> attr(data,"metaparam") <- metaparam
>
> sm <- as.smet(data)
>
> # In case of multiple station, it return a list of SMET-class objects:
>
> sm_multi <- as.smet(meteofrance,variables=variables)
>
>
>
>
>
>
>
>
>
>
> dev.off()
null device
1
>