Learn R Programming

phenology (version 3.41)

add_format: Create a new dataset or add a timeserie to a previous one.

Description

To create a new dataset, the syntaxe is data<-add_format(add=newdata, name="Site", reference=as.Date('2001-12-31'), format=' add a dataset to a previous one, the syntaxe is data<-add_format(origin=previousdata, add=newdata, name='Site', reference=as.Date('2001-12-31'), adjust_ref=TRUE, format=' timeseries at the same time with ' date format: data<-add_format(add=list(newdata1, newdata2), name=c('Site1', 'Site2'), reference=as.Date('2001-12-31'), format=c(' ' 2 or 3 columns. The first one is the date in the format specified by the parameter format=. If the number of nests is known for an exact data, then only one date must be indicated If the number of nests is known for a range of date, the first and last dates must be separated but a - (dash). For example: 1/2/2000-10/2/2000 The second column is the number of nests observed for this date or this range of dates. The third column is optional and is the name of the rookery. If only two columns are indicated, the name can be indicated as a parameter of the function with name=. If no name is indicated, the default name Site will be used, but take care, only one rookery of this name can be used. Several rookeries can be included in the same file but in this case the rookery name is obligatory at the third column.

Usage

add_format(origin = NULL,
    add = stop("A dataset must be indicated"), name = NULL,
    reference = NULL, format = "%d/%m/%y",
    adjust_ref = TRUE, help = FALSE)

Arguments

origin
Previous data or NULL if no previous data exists
add
The data to be added. It can be a set of several entities that uses the same reference and date format
name
The name of the monitored site
reference
as.Date('2001-12-31') The date used as 1st date
format
The format of the date in the file. Several format can be set and the last one that give compatible result is used
adjust_ref
If TRUE, the day and month of reference is unchanged but year is changed dependent on the first date of timeseries.
help
If TRUE, an help is displayed

Value

  • Return a list of formated data

Details

add_format creates a new dataset.

Examples

Run this code
library(phenology)
# Read a file with data
# Gratiot<-read.delim("http://max2.ese.u-psud.fr/epc/conservation/BI/Complete.txt", , header=FALSE)
data(Gratiot)
# Generate a formatted list nammed data_Gratiot
data_Gratiot<-add_format(origin=NULL, add=Gratiot, name="Complete", reference=as.Date("2001-01-01"), format="%d/%m/%Y")
# Generate initial points for the optimisation
parg<-par_init(data_Gratiot, parametersfixed=NULL)
# Run the optimisation
# result_Gratiot<-fit_phenology(data=data_Gratiot, parametersfit=parg, parametersfixed=NULL, trace=1)
data(result_Gratiot)
# Plot the phenology and get some stats
output<-plot_phenology(result=result_Gratiot, pdf=FALSE)

Run the code above in your browser using DataLab