repository | monitorgonio | io home
sattagutils is under active development… things will change. If you’d like to contribute take a look at the readme and contributing files.
I’ve put together some of the functions I use most often when manipulating Wildlife Computer’s satellite tags (especially SPLASH10s). This package isn’t on CRAN yet, though I hope a future release will be. For now you can download and install or use devtools.
Skip to the Quick guide if you don’t care about how the thing works. Perhaps the most useful functionality of sattagutils is that it’ll load a single tag or a directory of tags into R automatically dealing with all of the irregularities and inconsistencies in file and date formats. I’ve also included a handful of plotting and other tools that I tend to use a lot when I’m browsing tags.
Tag data streams are essentially tables with some metadata attached to them. I thought of tags as lists of data.frames with some additional metadata attached to them.
In the end I settled on S4 classes to represent tag and data objects. I know some people hate them, but in the end it seemed like the most sensible thing to do. I couldn’t get the seamless functionality that I wanted out of S3. Similarly, the other OO systems in R would’ve gotten in the way, I think. For most operations I wanted tables to behave just like tables.
All of the various sattag data streams inherit es4dataframe:
setClass("es4dataframe",
contains = "data.frame"
)
and a constructor:
es4dataframe <- function(..., stringsAsFactors = FALSE) {
data <- data.frame(..., stringsAsFactors = stringsAsFactors)
new("es4dataframe", data)
}
I implemented only the most basic functionality that I needed including as.data.frame, is.es4dataframe, $, [, [<-, and merge although I kind of regret that last one.
Most are fairly simple and just pass the buck to the underlying data.frame. For example:
setMethod("[<-", "es4dataframe", function(x, i, j, ..., value) {
dfin <- as.data.frame(x)
dfout <- getS3method("[<-", "data.frame")(dfin, i, j, ..., value)
x@.Data <- dfout
x@names <- names(dfout)
x@row.names <- rownames(dfout)
return(x)
})
Install and load
devtools::install_github("williamcioffi/sattagutils")
library(sattagutils)
you probably want to start with:
?sattagutils
?load_tag
?batch_load_tags