MyNixOS website logo
Description

MareFrame DB Querying Library.

Creates and manages a PostgreSQL database suitable for storing fisheries data and aggregating ready for use within a Gadget <https://gadget-framework.github.io/gadget2/> model. See <https://mareframe.github.io/mfdb/> for more information.

MFDB: Data management for fisheries model creation

CRAN version badge CRAN Checks CRAN RStudio mirror total downloads badge CRAN RStudio mirror monthly downloads badge R-CMD-check

This package enables automated processing of fisheries data into suitable forms for running ecosystem models against it, e.g. GADGET.

This package contains several distinct sets of functions:

  • Create and connect to a PostgreSQL database schema (mfdb function)
  • Import data into a PostgreSQL database (mfdb_import_* functions)
  • Sample / group data from database (other mfdb_* functions)
  • Manage GADGET model directories and export data into them (gadget_* functions)

Using this, you can install PostgreSQL locally and have a script automating the process of:

  1. Importing data from your sources
  2. Uploading into your local MFDB database
  3. Sampling / grouping this data
  4. Producing set of GADGET model files ready to be run by GADGET

Also, this libary can be used to connect to a remote database and generate model files from that data.

This work is based on it's predecessor, DST^2.

Prerequisites

Besides R, you will also need RPostgres set up to access the database, and PostgreSQL installed if you want to run the database locally too.

Linux (Debian / Ubuntu)

Installation of RPostgres will happen automatically, however you need some PostgreSQL libraries before it will work:

apt-get install libpq-dev

Also, you can install the postgresql package using:

apt-get install postgresql

Some additional instructions are available here: https://wiki.debian.org/PostgreSql

Now, create an mf database that the user on your computer owns:

$ echo $USER  # Check to see who you are, I'm lentinj
lentinj
$ su
# su - postgres
$ psql
postgres=# CREATE USER lentinj;
postgres=# CREATE DATABASE mf OWNER lentinj;

Linux (Redhat / Fedora)

Installation of RPostgres will happen automatically, however you need some PostgreSQL libraries before it will work:

yum install postgresql-devel

Also, you can install the postgresql package using:

yum install postgresql-server

Some additional instructions are available here: https://fedoraproject.org/wiki/PostgreSQL and some tips when troubleshooting CentOS installations can be found at: http://stackoverflow.com/questions/17633422/psql-fatal-database-user-does-not-exist

Now, create an mf database that the user on your computer owns:

$ echo $USER  # Check to see who you are, I'm lentinj
lentinj
$ su
# su - postgres
$ psql
postgres=# CREATE USER lentinj
postgres=# CREATE DATABASE mf OWNER lentinj;

Microsoft Windows

To install PostgreSQL, download version 9.5 of the database installer from here:

https://www.enterprisedb.com/downloads/postgres-postgresql-downloads

Find the psql shell (SQL shell) in the start menu, and create both an mf database and user:

postgres=# CREATE USER mf PASSWORD 'mf';
postgres=# CREATE DATABASE mf OWNER mf;

Apple OS X

Install using http://postgresapp.com/

Create a database called mf.

Installing

You can install from CRAN:

install.packages('mfdb')

Or use remotes to install this directly:

# install.packages("remotes")
remotes::install_github("gadget-framework/mfdb")

Using

For an introduction to the package, read the package?mfdb help file in R. This is also available online.

There are a selection of example scripts in the demo/ folder. The example-* scripts show the full process of importing data from specified sources into the database, then querying this to aggregate into various gadget model files. The inttest-* scripts demonstrate other aspects, and also function as tests to ensure that the library works correctly (thus the ok() function calls).

Finally, there is documentation on the database schema.

Development

Running integration tests

Given the database is setup as above, integration tests and all package examples can be run with make inttest.

To run all tests (unit tests, integration, examples and check-as-cran), use make.

Models using MFDB

  • https://github.com/gadget-framework/gadget-models

Acknowledgements

This project has received funding from the European Union’s Seventh Framework Programme for research, technological development and demonstration under grant agreement no.613571.

Metadata

Version

7.3-1

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows