makeScene {mateable}R Documentation

Create a matingScene object from a data frame

Description

Turns a data frame with information about temporal, spatial, or genetic mating data into a matingScene object using a standard format.

Usage

makeScene(
  df,
  multiYear = FALSE,
  startCol = "start",
  endCol = "end",
  xCol = "x",
  yCol = "y",
  s1Col = "s1",
  s2Col = "s2",
  idCol = "id",
  otherCols = NULL,
  dateFormat = "%Y-%m-%d",
  split = NULL
)

Arguments

df

a data frame containing information about a mating scene, namely coordinate of individuals in space, time, and mating type.

multiYear

logical indicating whether or not to split the result into a list by year

startCol

character name of column with start dates

endCol

character name of column with end dates

xCol

character name of column with x or E coordinates

yCol

character name of column with y or N coordinates

s1Col

character name of one column with S-allele

s2Col

character name of another column with S-alleles

idCol

character name for column with unique identifier

otherCols

character vector of column(s) to include besides the necessary ones for the mating scene. If NULL, it will be ignored.

dateFormat

character indicating either (1) the format of the start and end date columns if those columns are characters or (2) the origin for the start and end date columns if those columns are numeric. It is used in as.Date

split

character name for a column with values by which the result should be split

Details

The input dataframe can contain information about locations of individuals in 1, 2, or 3 dimensions of a mating scenes. The function currently allows two spatial coordinates. The user specifies the names of the columns and they will be saved xCol and yCol in the matingScene object. MatingScene objects currently save temporal coordinates for individuals as start and end date of mating activity within a year. Mating type coordinates are saved as mating type alleles. Columns are named id, start, end, x, y, s1, and s2 for idCol, startCol, endCol, xCol, yCol, s1Col, and s2Col respectively. The attributes "t", "s", and "mt" will be set to TRUE if the data frame has temporal, spatial, or mating type data, respectively and will be FALSE otherwise. The attribute originalNames contains all the names of the columns in the original data frame.
The start and end columns will be changed to integers relative to the start day of the population. So the first day of the first individual to become receptive will be 1 and so on. The attribute origin contains the origin that can be used when converting the columns start and end from integers to dates.
If no temporal data are available except the year in which it was collected and df is a multi-year data set, put the collection year into the column labeled as startCol and set dateFormat = " the data appropriately.

Value

a matingScene object, either a single dataframe in standard format or a list of dataframes. Attributes of the matingScene object indicate the type of information in the data frame, including the original column names, and the origin of the date columns. If multiYear = TRUE, the return value will be a list of matingScene data frames where each element in the list represents one year. If split is specified, the return value will be a list of matingScene data frames where each element in the list represents a value of the specified variable. See details for more information on attributes and how to work with multi-year data.

Author(s)

Danny Hanson


[Package mateable version 0.3.2 Index]