report_sample_char-class: Class 'report_sample_char'

report_sample_char-classR Documentation

Class 'report_sample_char'

Description

The report_sample_char class is used to load and display sample characteristics, which can be either continuous or discrete variable, for instance, it can be used to analyze size or sex structure during a given period.

Slots

data

A data frame

dc

An object of class ref_dc-class: the control devices

taxa

An object of class ref_taxa-class: the species

stage

An object of class ref_stage-class : the stages of the fish

par

An object of class ref_par-class: the parameters used

horodatedebut

An object of class ref_horodate-class

horodatefin

An object of class ref_horodate-class

Objects from the Class

Objects can be created by calls of the form new('report_sample_char', ...)

Note

This class is displayed by interface_report_sample_char, in the database, the class calls the content of the view vue_lot_ope_car

Author(s)

Cedric Briand cedric.briand@eptb-vilaine.fr

See Also

Other report Objects: report_annual-class, report_dc-class, report_df-class, report_env-class, report_ge_weight-class, report_mig-class, report_mig_char-class, report_mig_env-class, report_mig_interannual-class, report_mig_mult-class, report_sea_age-class, report_silver_eel-class, report_species-class

Examples

# launching stacomi without connection to the database
stacomi(	database_expected=FALSE)
# If you have a working database
# the following line of code will create the r_sample_char 
# dataset from the iav (default) schema in the database
## Not run: 
	stacomi(database_expected=TRUE)	# uses default option sch = 'iav'
	# prompt for user and password, you can set these in the options, 
	# including dbname and host
	if (interactive()){
		if (!exists("user")){
			user <- readline(prompt="Enter user: ")
			password <- readline(prompt="Enter password: ")	
		}	
	}
	options(					
			stacomiR.dbname = "bd_contmig_nat",
			stacomiR.host ="localhost",
			stacomiR.port = "5432",
			stacomiR.user = user,
			stacomiR.user = password						
	)	
  #create an instance of the class
  r_sample_char <- new("report_sample_char")
  # the following will load data for size, 
  # parameters 1786 (total size) C001 (size at video control)
  # dc 5 and 6 are fishways located on the Arzal dam
  # two stages are selected
  r_sample_char <- choice_c(r_sample_char,
	  dc=c(5,6),
	  taxa=c("Anguilla anguilla"),
	  stage=c("AGJ","CIV"),
	  par=c(1785,1786,1787,"C001"),
	  horodatedebut="2013-01-01",
	  horodatefin="2013-12-31",
	  silent=FALSE)
  # two warning produced, ignored if silent=TRUE
  r_sample_char <- connect(r_sample_char)
  r_sample_char <- calcule(r_sample_char,silent=TRUE)
  

## End(Not run)	
# load the dataset generated by previous lines
data("r_sample_char")

# A "violin" plot
plot(r_sample_char,plot.type="1",silent=TRUE)
# get the plot from envir_stacomi to change labels for name
# if you use require(ggplot2) the :: argument is not needed
# e.g. write require(ggplot2);g<-get("g",envir=envir_stacomi)
# g+xlab("size")+ylab("year")
if (requireNamespace("ggplot2", quietly = TRUE)){
  g<-get("g",envir=envir_stacomi)
  g+ggplot2::xlab("size")+ggplot2::ylab("year")
}
# A boxplot per month
plot(r_sample_char,plot.type="2",silent=TRUE)
# A xyplot
plot(r_sample_char,plot.type="3",silent=TRUE)

## Not run: 
  
  #####################################
# an example graph created manually from data
  #####################################
# two variables one on DC, one on stage
# passing dc information to the stage variable
  r_sample_char@data$std_libelle[r_sample_char@data$ope_dic_identifiant==5]<-
      "Yellow eel (vert. slot fishway)"
  r_sample_char@data$std_libelle[r_sample_char@data$std_libelle=="Anguille jaune"]<-
      "Yellow eel (ramp)"
  r_sample_char@data$std_libelle[r_sample_char@data$std_libelle=="civelle"]<-
      "Glass eel (ramp)"
# creating a boxplot with custom output : an example
# again if you use require(ggplot2) the :: argument is not needed
  
  if (requireNamespace("ggplot2", quietly = TRUE)){
	g<-ggplot2::ggplot(r_sample_char@data)+
		ggplot2::geom_boxplot(ggplot2::aes(x=annee,
				y =car_valeur_quantitatif,
				fill = std_libelle))+		
		ggplot2::xlab("size")+ggplot2::ylab("year")+
		ggplot2::scale_fill_manual("stage & fishway",
			values=c("Yellow eel (vert. slot fishway)"="blue",
				"Yellow eel (ramp)"="turquoise3",
				"Glass eel (ramp)"="Cyan"))+
		ggplot2::theme_bw()
	print(g)
  }
  
# get a simple summary using Hmisc::describe
  
  summary(r_sample_char)
# get the command line to create the object using choice_c 
# when the graphical interface has been used
  print(r_sample_char)

## End(Not run)

stacomiR documentation built on May 29, 2024, 10:41 a.m.