get_group_by_individual: Convert group or individual data into a group by individual...

Description Usage Arguments Details Value Author(s) Examples

View source: R/get_gbi.R

Description

Converts several different types of data storage into a group by individual matrix for calculating or permuting networks

Usage

1
2
get_group_by_individual(association_data, identities = NULL, 
location = NULL, data_format = c("groups", "individuals"))

Arguments

association_data

Can be either a group by individual matrix or a list containing group members in each element

identities

Optional identities for each individual in the dataset

location

Returns these spatial locations for each group

data_format

Format of the input data

Details

This function will calculate an K x N matrix representing K groups and N individuals. If locations are included, these will be returned in the row names.

Value

Returns a K x N matrix, where each K row is an group defined from the input data. Column names of the matrix are given the identity where available. The K row names are given either the time or time_location for each group.

Author(s)

Damien R. Farine

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## define group memberships (these would be read from a file)
individuals <- data.frame(ID=c("C695905","H300253","H300253",
	"H300283","H839876","F464557","H300296","H300253",
	"F464557","H300296","C695905","H300283","H839876"),
	GROUP=c(1,1,2,2,2,3,3,4,5,5,6,6,6))

## create a time column
individuals <- cbind(individuals,
	DAY=c(1,1,1,1,1,2,2,2,3,3,3,3,3))

gbi <- get_group_by_individual(individuals, 
	data_format="individuals")
	
## define group memberships (these would be read from a file)
groups <- list(G1=c("C695905","H300253"),
	G2=c("H300253","H300283","H839876"),
	G3=c("F464557","H300296"),
	G4=c("H300253"),
	G5=c("F464557","H300296"),
	G6=c("C695905","H300283","H839876"))

## create a time variable
days <- c(1,1,2,2,3,3)

gbi <- get_group_by_individual(groups, 
	data_format="groups")

asnipe documentation built on Aug. 19, 2019, 5:03 p.m.