Learn R Programming

phenology (version 3.72)

add_phenology: Create a new dataset or add a timeserie to a previous dataset.

Description

To create a new dataset, the syntaxe is data<-add_phenology(add=newdata, name="Site", reference=as.Date('2001-12-31'), format='To add a dataset to a previous one, the syntaxe is data<-add_phenology(previous=previousdata, add=newdata, name='Site', reference=as.Date('2001-12-31'), adjust_ref=TRUE, format='To add several timeseries at the same time with 'data<-add_phenology(add=list(newdata1, newdata2), name=c('Site1', 'Site2'), reference=as.Date('2001-12-31'), format=c('The dataset to be added must include 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. The simplest use of this function is just: phen <- add_phenology()

Usage

add_phenology(add = file.choose(), name = NULL, reference = NULL,
  month_ref = NULL, header = NULL, format = NULL, previous = NULL,
  silent = FALSE, help = FALSE)

Arguments

previous
Name of previous data formated with add_phenology or NULL [default] 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
month_ref
If no reference date is given, use this month as a reference
header
If the data is read from a file, can be used to force header or not
format
The format of the date in the file. Several format can be set and the last one that give compatible result is used
silent
Does information about added timeseries is shown
help
If TRUE, an help is displayed

Value

  • Return a list of formated data that can be used ith fit_phenology()

Details

add_phenology 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
refdate <- as.Date("2001-01-01")
data_Gratiot<-add_phenology(Gratiot, name="Complete",
	reference=refdate, 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(result_Gratiot)

Run the code above in your browser using DataLab