Last data update: 2014.03.03

R: Make a Used-Aavailable Data Frame
makeUsedAvailR Documentation

Make a Used-Aavailable Data Frame

Description

Make a used-available data frame from a presence-absence type data.

Usage

makeUsedAvail(x, ...)

## Default S3 method:
makeUsedAvail(x, y, ...)

## S3 method for class 'formula'
makeUsedAvail(formula, data = parent.frame(), ...)

Arguments

x

a matrix or data frame.

y

a vector with 0/1 entries, 1s are taken as used observations.

formula

two sided model formula of the form y ~ x.

data

data.

...

other arguments.

Value

The function returns a data frame, where used and available portions of the input data are bound on top of each other, the first column refers to y, where used (1) and available (0) locations are indicated different from the input values. All locations in the input data are treated as available (0), while only nonzero observations in y are treated as used (1).

Author(s)

Peter Solymos

Examples

(x <- data.frame(species=rep(1:0,each=4), var1=1:8, var2=11:18))
makeUsedAvail(species ~ var1 + var2, x)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(ResourceSelection)
ResourceSelection 0.2-6 	 2016-02-15
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/ResourceSelection/makeUsedAvail.Rd_%03d_medium.png", width=480, height=480)
> ### Name: makeUsedAvail
> ### Title: Make a Used-Aavailable Data Frame
> ### Aliases: makeUsedAvail makeUsedAvail.default makeUsedAvail.formula
> ### Keywords: manip
> 
> ### ** Examples
> 
> (x <- data.frame(species=rep(1:0,each=4), var1=1:8, var2=11:18))
  species var1 var2
1       1    1   11
2       1    2   12
3       1    3   13
4       1    4   14
5       0    5   15
6       0    6   16
7       0    7   17
8       0    8   18
> makeUsedAvail(species ~ var1 + var2, x)
   species var1 var2
1        1    1   11
2        1    2   12
3        1    3   13
4        1    4   14
5        0    1   11
6        0    2   12
7        0    3   13
8        0    4   14
9        0    5   15
10       0    6   16
11       0    7   17
12       0    8   18
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>