Grevy’s zebra and onager

paper, original data

Affiliation groups over time for grevy's zebra and wild asses. Data in contains three columns: day, group no., individual id. Day is the day (an encoding of a date) on which the groups of animals have been sighted. Group no. is the unique group id for each sighted group. All animals with the same group no. have been seen together. All group numbers are unique and do not repeat across days. Animal id is the unique identifier of an individual animal. The letter after the id indicates demographic status: Grevy's [s stallion, b bachelor, n nonlactating, l lactating], wild asses [T territorial male, N nonlactating, L lactating].

Grevy’s zebra network

Two mode network: Zebras X Groups in time: (z,g,t) on day d zebra z was in group g. The Grevy’s zebra dataset includes 28 individuals observed over 44 daily samplings (time steps) between June and August of 2002.

The original CSV data file was split into two (zebras.csv and asses.csv). The column names were changed to Day,Group,ID .

Groups: 1 = s - stallion, 2 = b - bachelor, 3 = n - nonlactating, 4 = l - lactating.

> setwd("C:/Users/batagelj/Downloads/data/zebra")
> z <- read.csv("zebras.csv", skip=1, colClasses=c('integer','integer','character'))
> head(z)
> n <- 0; IDs <- new.env(hash=TRUE,parent=emptyenv())
> nr <- nrow(z)
> for(r in 1:nr){
+   id <- z$ID[r]
+   if (!exists(id,env=IDs,inherits=FALSE)){
+     n <- n + 1; assign(id,n,env=IDs)
+   }
+ }
> net <- file("zebras.net","w");  cat('*vertices ',n+166,n,'\n',file=net)
> clu <- file("zebras.clu","w");  cat('*vertices ',n,'\n',file=clu)
> for(id in ls(IDs)) {
+   cat(get(id,env=IDs),id,'\n',file=net);
+   cat(substr(id,3,3),'\n',file=clu)
+ }
> for(g in 1:166) cat(n+g,g,'\n',file=net);
> cat('*arcs\n',file=net)
> for(r in 1:nr){
+   id <- z$ID[r]; g <- z$Group[r]; d <- z$Day[r]
+   cat(get(id,env=IDs),n+g,'1 [',d,']\n',file=net)
+ }
> close(net); close(clu)

Transformed into Pajek's format by Vladimir Batagelj, December 27, 2015.

Onager network

day 1 : “2002-12-25” - day 163 : “2003-06-05”.

Groups: 1 = T - territorial male, 2 = N - nonlactating, 3 = L - lactating.

> izero <- function(x) return(ifelse(nchar(x)<2,'0',''))
> o <- read.csv("asses.csv", skip=1, colClasses=c('character','integer','character'))
> head(o)
> n <- 0; IDs <- new.env(hash=TRUE,parent=emptyenv())
> nr <- nrow(o)
> for(r in 1:nr){
+   id <- o$ID[r]
+   if (!exists(id,env=IDs,inherits=FALSE)){
+     n <- n + 1; assign(id,n,env=IDs)
+   }
+ }
> net <- file("onagers.net","w");  cat('*vertices ',n+429,n,'\n',file=net)
> clu <- file("onagers.clu","w");  cat('*vertices ',n,'\n',file=clu)
> for(id in ls(IDs)) {
+   cat(get(id,env=IDs),id,'\n',file=net);
+   cat(substr(id,7,7),'\n',file=clu)
+ }
> for(g in 1:429) cat(n+g,g,'\n',file=net);
> cat('*arcs\n',file=net)
> ds <- as.Date("2002-12-24"); dd <- ds
> for(r in 1:nr){
+   id <- o$ID[r]; g <- o$Group[r]; L <- unlist(strsplit(o$Day[r],"/"))
+   dd <- as.Date(paste("20",L[3],"-",izero(L[1]),L[1],"-",izero(L[2]),L[2],sep=''))
+   d <- as.integer(dd-ds)
+   cat(get(id,env=IDs),n+g,'1 [',d,']\n',file=net)
+ }
> close(net); close(clu)
notes/net/zebra.txt · Last modified: 2015/12/28 02:24 by vlado
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki