Title: | Transforming Behavioral Observation Records into Data Matrices |
---|---|
Description: | Transforms focal observations' data, where different types of social interactions can be recorded by multiple observers, into asymmetric data matrices. Each cell in these matrices provides counts on the number of times a specific type of social interaction was initiated by the row subject and directed to the column subject. |
Authors: | David N Sousa [aut, cre], Joao R Daniel [aut] |
Maintainer: | David N Sousa <[email protected]> |
License: | GPL-3 |
Version: | 0.1.0 |
Built: | 2024-11-22 06:23:18 UTC |
Source: | https://github.com/davidnsousa/bor |
countb takes a data frame with dyadic social interactions' data (akin to that returned by dtable function) and returns a list of asymmetric data matrices- one for each observer and type of social interaction. Each matrix cell provides counts on the number of times a specific type of social interaction was initiated by the row subject and directed to the column subject.
countb(x)
countb(x)
x |
A data frame with 7 columns: the 1st column should refer to the focal subject's identification code (e.g., column named "id1" as in the output of dtable function); the 2nd column should refer to the identification code of the interaction partner (e.g., "id2"); the 3rd column (e.g., "sender_id1") should refer whether the focal subject was the initiator (coded 1) or the target of the social interaction (coded 0); the 4th column should refer to the type/code of social interaction recorded; the 5th column (e.g., "no_occurrence") should refer whether no social interactions were recorded (coded as 1; NA's otherwise); the 6th column (e.g., "missing") should refer whether the focal subject was unavailable for observation (coded as 1; NA's otherwise); the 7th columns (e.g., "observer") should refer to the observer's identification code. |
countb returns a list with asymmetric matrices, one for each observer and type of social interaction recorded. Matrix cells provide counts on the number of times social interactions were initiated by the row subjects and directed to the column subjects.
## create list of asymmetric matrices (data2) from data object ## data object is obtained by converting raw focal observations' data in ex_field_data with ## dtable function b <- c("+","-") data <- dtable(ex_field_data, bset = b) data2 <- countb(data) data2
## create list of asymmetric matrices (data2) from data object ## data object is obtained by converting raw focal observations' data in ex_field_data with ## dtable function b <- c("+","-") data <- dtable(ex_field_data, bset = b) data2 <- countb(data) data2
dtable takes a data frame containing raw focal observations' data and transforms it into another data frame more suitable for further data analysis.
dtable(x, bset, bsep = ".", asep = ";", missing = "x", noc = "0")
dtable(x, bset, bsep = ".", asep = ";", missing = "x", noc = "0")
x |
data frame containing raw focal observations' data, referring to dyadic social interactions. This data frame should contain one focal observation per row and 3 columns. The first column should refer to focal's subject identification code; the second, to the recorded dyadic social interactions; and the third, to observer's identification code. See ex_field_data for further details on the structure of this data frame. |
bset |
A vector specifying the codes of the recorded social interactions. |
bsep |
The separation character used in the second column of x to separate subject's id code from social interactions code. Default is ".". |
asep |
The separation character used in the second column of x to separate different social interactions recorded within the same focal sample. Default is ";". |
missing |
A character, used in the second column of x, to identify focal observations where the focal subject was unavailable for observation. Default is "x". |
noc |
A character, used in the second column of x, to identify focal observations where no social interactions were recorded. Default is "0". |
dtable returns a data frame with 7 columns: "id1" identifies the focal subject's; "sender_id1" identifies whether the focal's subject (id1) was the initiator of the dyadic social interaction (coded 1), or the target of the social interaction (coded 0; in this case the initiator is the subject referred in the column "id2"); "behavior" identifies the social interaction observed; if no social interactions were recorded in a focal sample, "no_occurrence" and "missing" columns specify whether the focal subject was observed but did not interact, or was unavailable for observation, respectively; "observer" columns identifies the observer.
## convert raw focal observations' data in ex_field_data ## see ?ex_field_data for further details ## bsep, asep, missing and noc arguments take default values (".", ";", "x", "0" respectively) b <- c("+","-") data <- dtable(ex_field_data, bset = b) head(data)
## convert raw focal observations' data in ex_field_data ## see ?ex_field_data for further details ## bsep, asep, missing and noc arguments take default values (".", ";", "x", "0" respectively) b <- c("+","-") data <- dtable(ex_field_data, bset = b) head(data)
A data frame containing an hypothetical (randomly generated) focal observations' data set to be passed to dtable(). This example contains 100 focal samples in a group of 9 subjects.
ex_field_data
ex_field_data
Data frame containing raw focal observations' data, referring to dyadic social interactions. This data frame contains one focal observation per row and 3 columns:
focal subject's identification code.
recorded social interactions (SIs) in each focal sample.
observer's identification code.
In this example two different SIs were recorded (coded + and -); SIs codes, subjects' id codes, and separation characters should not overlap. The . character is used to separate subjects' id codes from the SIs' codes, and the ; character is used to separate different SIs occurring within the same focal sample. Whenever a subject's id appears before a SI's code it means that, that subject initiated a SI with the focal subject (see row 6); whenever a subject's id appears after the SI's it means that the focal subject (id1 column) initiated a SI with that subject (see row 4). For example, the 4th row indicates that the focal subject s1 initiated a + social interaction with subject s4, while the 6th row indicates that the focal subject s5 was involved in two social interactions- the first initiated by s4 (-), the second (+) initiated by s2. 0s in this column refer to focal observations where no SIs were recorded, and xs refer to focal observations where the focal subject was unavailable for observation.