Biological Condition Gradient fuzzy membership for metrics.
BCG.Metric.Membership(
df.metrics,
df.rules,
input.shape = "wide",
col_SAMPLEID = "SAMPLEID",
col_INDEX_NAME = "INDEX_NAME",
col_INDEX_CLASS = "INDEX_CLASS",
col_LEVEL = "LEVEL",
col_METRIC_NAME = "METRIC_NAME",
col_RULE_TYPE = "RULE_TYPE",
col_LOWER = "LOWER",
col_UPPER = "UPPER",
col_METRIC_VALUE = "METRIC_VALUE",
col_INCREASE = "INCREASE",
...
)Wide data frame with metric values to be evaluated.
Data frame of metric thresholds to check.
Shape of df.metrics; wide or long. Default is wide.
Column name for sample id. Default = "SAMPLEID"
Column name for index name. Default = "INDEX_NAME"
Column name for index class Default = "INDEX_CLASS"
Column name for level. Default = "LEVEL"
Column name for metric name. Default = "METRIC_NAME"
Column name for rule type (e.g., Rule0). Default = "RULE_TYPE"
Column name for lower limit. Default = "LOWER"
Column name for upper limit. Default = "UPPER"
Column name for metric value. Default = "METRIC_VALUE"
Column name for if the metric value increases. Default = "INCREASE"
Arguments passed to `BCG.MetricMembership` used internally
Returns a data frame of results in the long format.
Converts metric values into BCG membership values. Uses a rules table to define the metrics, scoring range, and direction for each named index.
Deprecated col_SITE_TYPE for col_INDEX_CLASS in v2.0.0.9001.
# library(readxl)
# library(BioMonTools)
# Calculate Metrics
df_samps_bugs <- readxl::read_excel(
system.file("extdata/Data_BCG_PugLowWilVal.xlsx"
, package = "BCGcalc")
, guess_max = 10^6)
myDF <- df_samps_bugs
myCols <- c("Area_mi2", "SurfaceArea", "Density_m2", "Density_ft2")
# populate missing columns prior to metric calculation
col_missing <- c("INFRAORDER", "HABITAT", "ELEVATION_ATTR", "GRADIENT_ATTR"
, "WSAREA_ATTR", "HABSTRUCT", "UFC")
myDF[, col_missing] <- NA
df_met_val_bugs <- BioMonTools::metric.values(myDF
, "bugs"
, fun.cols2keep = myCols)
#> Joining with `by = join_by(SAMPLEID, INDEX_NAME, INDEX_CLASS)`
# Import Rules
df_rules <- readxl::read_excel(system.file("extdata/Rules.xlsx"
, package = "BCGcalc")
, sheet="Rules")
#> Warning: Expecting numeric in C1980 / R1980C3: got 'Level 2'
#> Warning: Expecting numeric in C1981 / R1981C3: got 'Level 2'
#> Warning: Expecting numeric in C1982 / R1982C3: got 'Level 2'
#> Warning: Expecting numeric in C1983 / R1983C3: got 'Level 2'
#> Warning: Expecting numeric in C1984 / R1984C3: got 'Level 2'
#> Warning: Expecting numeric in C1985 / R1985C3: got 'Level 2'
#> Warning: Expecting numeric in C1986 / R1986C3: got 'Level 2'
#> Warning: Expecting numeric in C1987 / R1987C3: got 'Level 2'
#> Warning: Expecting numeric in C1988 / R1988C3: got 'Level 2'
#> Warning: Expecting numeric in C1989 / R1989C3: got 'Level 2'
#> Warning: Expecting numeric in C1990 / R1990C3: got 'Level 3'
#> Warning: Expecting numeric in C1991 / R1991C3: got 'Level 3'
#> Warning: Expecting numeric in C1992 / R1992C3: got 'Level 3'
#> Warning: Expecting numeric in C1993 / R1993C3: got 'Level 3'
#> Warning: Expecting numeric in C1994 / R1994C3: got 'Level 3'
#> Warning: Expecting numeric in C1995 / R1995C3: got 'Level 3'
#> Warning: Expecting numeric in C1996 / R1996C3: got 'Level 3'
#> Warning: Expecting numeric in C1997 / R1997C3: got 'Level 3'
#> Warning: Expecting numeric in C1998 / R1998C3: got 'Level 4'
#> Warning: Expecting numeric in C1999 / R1999C3: got 'Level 4'
#> Warning: Expecting numeric in C2000 / R2000C3: got 'Level 4'
#> Warning: Expecting numeric in C2001 / R2001C3: got 'Level 4'
#> Warning: Expecting numeric in C2002 / R2002C3: got 'Level 4'
#> Warning: Expecting numeric in C2003 / R2003C3: got 'Level 4'
#> Warning: Expecting numeric in C2004 / R2004C3: got 'Level 4'
#> Warning: Expecting numeric in C2005 / R2005C3: got 'Level 5'
#> Warning: Expecting numeric in C2006 / R2006C3: got 'Level 5'
#> Warning: Expecting numeric in C2007 / R2007C3: got 'Level 5'
#> Warning: Expecting numeric in C2008 / R2008C3: got 'Level 2'
#> Warning: Expecting numeric in C2009 / R2009C3: got 'Level 2'
#> Warning: Expecting numeric in C2010 / R2010C3: got 'Level 2'
#> Warning: Expecting numeric in C2011 / R2011C3: got 'Level 2'
#> Warning: Expecting numeric in C2012 / R2012C3: got 'Level 2'
#> Warning: Expecting numeric in C2013 / R2013C3: got 'Level 2'
#> Warning: Expecting numeric in C2014 / R2014C3: got 'Level 2'
#> Warning: Expecting numeric in C2015 / R2015C3: got 'Level 2'
#> Warning: Expecting numeric in C2016 / R2016C3: got 'Level 2'
#> Warning: Expecting numeric in C2017 / R2017C3: got 'Level 2'
#> Warning: Expecting numeric in C2018 / R2018C3: got 'Level 3'
#> Warning: Expecting numeric in C2019 / R2019C3: got 'Level 3'
#> Warning: Expecting numeric in C2020 / R2020C3: got 'Level 3'
#> Warning: Expecting numeric in C2021 / R2021C3: got 'Level 3'
#> Warning: Expecting numeric in C2022 / R2022C3: got 'Level 3'
#> Warning: Expecting numeric in C2023 / R2023C3: got 'Level 3'
#> Warning: Expecting numeric in C2024 / R2024C3: got 'Level 3'
#> Warning: Expecting numeric in C2025 / R2025C3: got 'Level 3'
#> Warning: Expecting numeric in C2026 / R2026C3: got 'Level 4'
#> Warning: Expecting numeric in C2027 / R2027C3: got 'Level 4'
#> Warning: Expecting numeric in C2028 / R2028C3: got 'Level 4'
#> Warning: Expecting numeric in C2029 / R2029C3: got 'Level 4'
#> Warning: Expecting numeric in C2030 / R2030C3: got 'Level 4'
#> Warning: Expecting numeric in C2031 / R2031C3: got 'Level 4'
#> Warning: Expecting numeric in C2032 / R2032C3: got 'Level 4'
#> Warning: Expecting numeric in C2033 / R2033C3: got 'Level 5'
#> Warning: Expecting numeric in C2034 / R2034C3: got 'Level 5'
#> Warning: Expecting numeric in C2035 / R2035C3: got 'Level 5'
#> Warning: Expecting numeric in C2036 / R2036C3: got 'Level 2'
#> Warning: Expecting numeric in C2037 / R2037C3: got 'Level 2'
#> Warning: Expecting numeric in C2038 / R2038C3: got 'Level 2'
#> Warning: Expecting numeric in C2039 / R2039C3: got 'Level 2'
#> Warning: Expecting numeric in C2040 / R2040C3: got 'Level 2'
#> Warning: Expecting numeric in C2041 / R2041C3: got 'Level 2'
#> Warning: Expecting numeric in C2042 / R2042C3: got 'Level 2'
#> Warning: Expecting numeric in C2043 / R2043C3: got 'Level 2'
#> Warning: Expecting numeric in C2044 / R2044C3: got 'Level 2'
#> Warning: Expecting numeric in C2045 / R2045C3: got 'Level 2'
#> Warning: Expecting numeric in C2046 / R2046C3: got 'Level 3'
#> Warning: Expecting numeric in C2047 / R2047C3: got 'Level 3'
#> Warning: Expecting numeric in C2048 / R2048C3: got 'Level 3'
#> Warning: Expecting numeric in C2049 / R2049C3: got 'Level 3'
#> Warning: Expecting numeric in C2050 / R2050C3: got 'Level 3'
#> Warning: Expecting numeric in C2051 / R2051C3: got 'Level 3'
#> Warning: Expecting numeric in C2052 / R2052C3: got 'Level 3'
#> Warning: Expecting numeric in C2053 / R2053C3: got 'Level 3'
#> Warning: Expecting numeric in C2054 / R2054C3: got 'Level 3'
#> Warning: Expecting numeric in C2055 / R2055C3: got 'Level 4'
#> Warning: Expecting numeric in C2056 / R2056C3: got 'Level 4'
#> Warning: Expecting numeric in C2057 / R2057C3: got 'Level 4'
#> Warning: Expecting numeric in C2058 / R2058C3: got 'Level 4'
#> Warning: Expecting numeric in C2059 / R2059C3: got 'Level 4'
#> Warning: Expecting numeric in C2060 / R2060C3: got 'Level 4'
#> Warning: Expecting numeric in C2061 / R2061C3: got 'Level 4'
#> Warning: Expecting numeric in C2062 / R2062C3: got 'Level 4'
#> Warning: Expecting numeric in C2063 / R2063C3: got 'Level 5'
#> Warning: Expecting numeric in C2064 / R2064C3: got 'Level 5'
#> Warning: Expecting numeric in C2065 / R2065C3: got 'Level 5'
#> Warning: Expecting numeric in C2066 / R2066C3: got 'Level 2'
#> Warning: Expecting numeric in C2067 / R2067C3: got 'Level 2'
#> Warning: Expecting numeric in C2068 / R2068C3: got 'Level 2'
#> Warning: Expecting numeric in C2069 / R2069C3: got 'Level 2'
#> Warning: Expecting numeric in C2070 / R2070C3: got 'Level 2'
#> Warning: Expecting numeric in C2071 / R2071C3: got 'Level 2'
#> Warning: Expecting numeric in C2072 / R2072C3: got 'Level 2'
#> Warning: Expecting numeric in C2073 / R2073C3: got 'Level 2'
#> Warning: Expecting numeric in C2074 / R2074C3: got 'Level 2'
#> Warning: Expecting numeric in C2075 / R2075C3: got 'Level 3'
#> Warning: Expecting numeric in C2076 / R2076C3: got 'Level 3'
#> Warning: Expecting numeric in C2077 / R2077C3: got 'Level 3'
#> Warning: Expecting numeric in C2078 / R2078C3: got 'Level 3'
#> Warning: Expecting numeric in C2079 / R2079C3: got 'Level 3'
#> Warning: Expecting numeric in C2080 / R2080C3: got 'Level 3'
#> Warning: Expecting numeric in C2081 / R2081C3: got 'Level 3'
#> Warning: Expecting numeric in C2082 / R2082C3: got 'Level 4'
#> Warning: Expecting numeric in C2083 / R2083C3: got 'Level 4'
#> Warning: Expecting numeric in C2084 / R2084C3: got 'Level 4'
#> Warning: Expecting numeric in C2085 / R2085C3: got 'Level 5'
#> Warning: Expecting numeric in C2086 / R2086C3: got 'Level 2'
#> Warning: Expecting numeric in C2087 / R2087C3: got 'Level 2'
#> Warning: Expecting numeric in C2088 / R2088C3: got 'Level 2'
#> Warning: Expecting numeric in C2089 / R2089C3: got 'Level 2'
#> Warning: Expecting numeric in C2090 / R2090C3: got 'Level 2'
#> Warning: Expecting numeric in C2091 / R2091C3: got 'Level 2'
#> Warning: Expecting numeric in C2092 / R2092C3: got 'Level 2'
#> Warning: Expecting numeric in C2093 / R2093C3: got 'Level 2'
#> Warning: Expecting numeric in C2094 / R2094C3: got 'Level 3'
#> Warning: Expecting numeric in C2095 / R2095C3: got 'Level 3'
#> Warning: Expecting numeric in C2096 / R2096C3: got 'Level 3'
#> Warning: Expecting numeric in C2097 / R2097C3: got 'Level 3'
#> Warning: Expecting numeric in C2098 / R2098C3: got 'Level 3'
#> Warning: Expecting numeric in C2099 / R2099C3: got 'Level 4'
#> Warning: Expecting numeric in C2100 / R2100C3: got 'Level 4'
#> Warning: Expecting numeric in C2101 / R2101C3: got 'Level 4'
#> Warning: Expecting numeric in C2102 / R2102C3: got 'Level 5'
#> Warning: Expecting numeric in C2103 / R2103C3: got 'Level 2'
#> Warning: Expecting numeric in C2104 / R2104C3: got 'Level 2'
#> Warning: Expecting numeric in C2105 / R2105C3: got 'Level 2'
#> Warning: Expecting numeric in C2106 / R2106C3: got 'Level 2'
#> Warning: Expecting numeric in C2107 / R2107C3: got 'Level 2'
#> Warning: Expecting numeric in C2108 / R2108C3: got 'Level 2'
#> Warning: Expecting numeric in C2109 / R2109C3: got 'Level 2'
#> Warning: Expecting numeric in C2110 / R2110C3: got 'Level 2'
#> Warning: Expecting numeric in C2111 / R2111C3: got 'Level 2'
#> Warning: Expecting numeric in C2112 / R2112C3: got 'Level 2'
#> Warning: Expecting numeric in C2113 / R2113C3: got 'Level 2'
#> Warning: Expecting numeric in C2114 / R2114C3: got 'Level 2'
#> Warning: Expecting numeric in C2115 / R2115C3: got 'Level 2'
#> Warning: Expecting numeric in C2116 / R2116C3: got 'Level 3'
#> Warning: Expecting numeric in C2117 / R2117C3: got 'Level 3'
#> Warning: Expecting numeric in C2118 / R2118C3: got 'Level 3'
#> Warning: Expecting numeric in C2119 / R2119C3: got 'Level 3'
#> Warning: Expecting numeric in C2120 / R2120C3: got 'Level 3'
#> Warning: Expecting numeric in C2121 / R2121C3: got 'Level 3'
#> Warning: Expecting numeric in C2122 / R2122C3: got 'Level 3'
#> Warning: Expecting numeric in C2123 / R2123C3: got 'Level 3'
#> Warning: Expecting numeric in C2124 / R2124C3: got 'Level 3'
#> Warning: Expecting numeric in C2125 / R2125C3: got 'Level 3'
#> Warning: Expecting numeric in C2126 / R2126C3: got 'Level 3'
#> Warning: Expecting numeric in C2127 / R2127C3: got 'Level 4'
#> Warning: Expecting numeric in C2128 / R2128C3: got 'Level 4'
#> Warning: Expecting numeric in C2129 / R2129C3: got 'Level 4'
#> Warning: Expecting numeric in C2130 / R2130C3: got 'Level 4'
#> Warning: Expecting numeric in C2131 / R2131C3: got 'Level 4'
#> Warning: Expecting numeric in C2132 / R2132C3: got 'Level 4'
#> Warning: Expecting numeric in C2133 / R2133C3: got 'Level 4'
#> Warning: Expecting numeric in C2134 / R2134C3: got 'Level 4'
#> Warning: Expecting numeric in C2135 / R2135C3: got 'Level 5'
#> Warning: Expecting numeric in C2136 / R2136C3: got 'Level 5'
#> Warning: Expecting numeric in C2137 / R2137C3: got 'Level 5'
#> Warning: Expecting numeric in C2138 / R2138C3: got 'Level 5'
#> Warning: Expecting numeric in C2139 / R2139C3: got 'Level 5'
#> Warning: Expecting numeric in C2140 / R2140C3: got 'Level 2'
#> Warning: Expecting numeric in C2141 / R2141C3: got 'Level 2'
#> Warning: Expecting numeric in C2142 / R2142C3: got 'Level 2'
#> Warning: Expecting numeric in C2143 / R2143C3: got 'Level 2'
#> Warning: Expecting numeric in C2144 / R2144C3: got 'Level 2'
#> Warning: Expecting numeric in C2145 / R2145C3: got 'Level 2'
#> Warning: Expecting numeric in C2146 / R2146C3: got 'Level 2'
#> Warning: Expecting numeric in C2147 / R2147C3: got 'Level 2'
#> Warning: Expecting numeric in C2148 / R2148C3: got 'Level 2'
#> Warning: Expecting numeric in C2149 / R2149C3: got 'Level 2'
#> Warning: Expecting numeric in C2150 / R2150C3: got 'Level 3'
#> Warning: Expecting numeric in C2151 / R2151C3: got 'Level 3'
#> Warning: Expecting numeric in C2152 / R2152C3: got 'Level 3'
#> Warning: Expecting numeric in C2153 / R2153C3: got 'Level 3'
#> Warning: Expecting numeric in C2154 / R2154C3: got 'Level 3'
#> Warning: Expecting numeric in C2155 / R2155C3: got 'Level 3'
#> Warning: Expecting numeric in C2156 / R2156C3: got 'Level 3'
#> Warning: Expecting numeric in C2157 / R2157C3: got 'Level 3'
#> Warning: Expecting numeric in C2158 / R2158C3: got 'Level 3'
#> Warning: Expecting numeric in C2159 / R2159C3: got 'Level 4'
#> Warning: Expecting numeric in C2160 / R2160C3: got 'Level 4'
#> Warning: Expecting numeric in C2161 / R2161C3: got 'Level 4'
#> Warning: Expecting numeric in C2162 / R2162C3: got 'Level 4'
#> Warning: Expecting numeric in C2163 / R2163C3: got 'Level 4'
#> Warning: Expecting numeric in C2164 / R2164C3: got 'Level 4'
#> Warning: Expecting numeric in C2165 / R2165C3: got 'Level 4'
#> Warning: Expecting numeric in C2166 / R2166C3: got 'Level 4'
#> Warning: Expecting numeric in C2167 / R2167C3: got 'Level 5'
#> Warning: Expecting numeric in C2168 / R2168C3: got 'Level 5'
#> Warning: Expecting numeric in C2169 / R2169C3: got 'Level 5'
#> Warning: Expecting numeric in C2170 / R2170C3: got 'Level 5'
# Run function
df_met_memb <- BCG.Metric.Membership(df_met_val_bugs, df_rules)
# Show Results
#View(df_met_memb)
# Save Results
write.table(df_met_memb
, file.path(tempdir(), "Metric_Membership.tsv")
, row.names = FALSE
, col.names = TRUE
, sep = "\t")