Learn R Programming

phenology (version 7.2)

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='%d/%m/%y') To add a dataset to a previous one, the syntaxe is : data <- add_phenology(previous=previousdata, add=newdata, name='Site', reference=as.Date('2001-01-01'), format="%Y-%m-%d") To add several timeseries at the same time with '%d/%m/%y' or '%d/%m/%Y' date format: data<-add_phenology(add=list(newdata1, newdata2), name=c('Site1', 'Site2'), reference=as.Date('2001-01-01'), format=c('%d/%m/%y', '%d/%m/%Y')) 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() Some problems that can occur: If a name is defined as a third column of a data.frame and a name is defined also with name=, the third column has priority. Two different timeseries MUST have different name and character _ is forbiden in timeseries names.

Usage

add_phenology(add = file.choose(), name = NULL, reference = NULL,
  month_ref = NULL, sep.dates = "-", header = NULL, format = NULL,
  previous = NULL, silent = FALSE)

Arguments

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

sep.dates

Separator used to separate dates when incertitude is included

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

previous

Previous data formated with add_phenology or NULL [default] if no previous data exist

silent

Does information about added timeseries is shown

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
# NOT RUN {
# Get the lastest version at:
# install.packages("http://www.ese.u-psud.fr/epc/conservation/CRAN/phenology.tar.gz", 
     repos=NULL, type="source")
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, fixed.parameters=NULL)
# Run the optimisation
result_Gratiot <- fit_phenology(data=data_Gratiot, fitted.parameters=parg, 
	fixed.parameters=NULL)
data(result_Gratiot)
# Plot the phenology and get some stats
output <- plot(result_Gratiot)
# }

Run the code above in your browser using DataLab