Learn R Programming

BiodiversityR (version 1.5)

import.from.Excel: Import Community or Environmental Data from Excel or Access

Description

This function provides a method for importing community or environmental data from Excel (through functions odbcConnectExcel or odbcConnectAccess). In case of stacked data, a community dataset is formed by function makecommunitydataset.

Usage

import.from.Excel(file = file.choose(), sheet = "community", sitenames = "sites", 
    column = "species", value = "abundance", factor = "", level = "", cepnames = FALSE)
import.from.Access(file = file.choose(), table = "community", sitenames = "sites", 
    column = "species", value = "abundance", factor = "", level = "", cepnames = FALSE)

Arguments

file
Location of the Excel file.
sheet
Name of the sheet of the Excel file to import: one of "community", "environmental" or "stacked".
table
Name of the table of the Access file to import: one of "community", "environmental" or "stacked".
sitenames
Name of categorical variable that provides the names for the sites.
column
Name of the categorical variable for the columns of the crosstabulation (typically indicating species); passed to makecommunitydataset.
value
Name of numerical variable for the cells of the crosstabulation (typically indicating abundance). The cells provide the sum of all values in the data frame; passed to makecommunitydataset.
factor
Name of the variable to calculate a subset of the data frame; passed to makecommunitydataset.
level
Value of the subset of the factor variable to calculate a subset of the data frame; passed to makecommunitydataset.
cepnames
Should the names of columns be abbreviated via make.cepnames (TRUE) or not (FALSE).

Value

  • The function returns a dataset that can be used as community or environmental data for analysis in BiodiversityR.

Details

This function provides a method of method of importing community or environmental datasets through functions odbcConnectExcel and sqlFetch. For stacked datasets, a community data set is created with function makecommunitydataset. For community data with more species than the limited number of columns in Excel, this may be the only option of importing a community dataset. An additional advantage of the function is that the community and environmental data can be stored in the same file. You may want to check compatibility of the community and environmental datasets with functions check.datasets and modify the community dataset through same.sites.

References

Kindt, R. & Coe, R. (2005) Tree diversity analysis: A manual and software for common statistical methods for ecological and biodiversity studies. http://www.worldagroforestry.org/resources/databases/tree-diversity-analysis

Examples

Run this code
## Example is not run as requires RODBC
## Check for file "dune.xls" in the etc folder of BiodiversityR
##
#### Default 'ordiplot3d'
library(RODBC)
dunenew <- import.from.Excel(sheet="community", sitenames="sites")
dune.envnew <- import.from.Excel(sheet="environmental", sitenames="sites")

Run the code above in your browser using DataLab