Description Usage Arguments Details Value Note Author(s) Examples
Set classes for variables in WiDNR Fish Management Data.
1 2 3 | setDBClasses(df, type = c("RDNR", "DNR", "R"), ...)
setFMDBClasses(df, type = c("RDNR", "DNR", "R"), ...)
|
df |
The data.frame that contains the Wi Fish Management Data (likely directly from the central database). |
type |
A single string that indicates the variable name type in |
... |
Not yet implemented. |
This function is used to set the class type (e.g., integer, factor, etc.) for variables from the WiDNR Fish Management central database.
A data.frame exactly as given in data
except, possibly, with different classes for the variables.
THIS IS EXPERIMENTAL AT THIS POINT (and not sure that it is really needed ... read.csv might do an adequate job of guessing variable class type).
Derek H. Ogle, dogle@northland.edu
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | ftmp <- system.file("extdata", "FMDB_ex.csv",package="fishWiDNR")
## Read in datafile (note periods in names) ... this is RDNR type of data
df1 <- read.csv(ftmp,stringsAsFactors=FALSE,na.strings="-")
str(df1)
## Set classes (using default 'RDNR' type)
df1a <- setFMDBClasses(df1)
tmp <- cbind(sapply(df1,class),sapply(df1a,class),
as.character(VarLookup$type[match(names(df1a),VarLookup$RDNR)]))
colnames(tmp) <- c("old","new","supposed to be")
tmp
## Set classes using R names (changed first using changeDBNames)
df1R <- changeDBNames(df1,from="RDNR","R")
df1Ra <- setFMDBClasses(df1R,type="R")
tmp <- cbind(sapply(df1R,class),sapply(df1Ra,class),
as.character(VarLookup$type[match(names(df1Ra),VarLookup$R)]))
colnames(tmp) <- c("old","new","supposed to be")
tmp
## test from partial list of RDNR names
df2 <- df1[,-c(1,4,7,10,16,32:47)]
df2a <- setFMDBClasses(df2)
tmp <- cbind(sapply(df2,class),sapply(df2a,class),
as.character(VarLookup$type[match(names(df2a),VarLookup[,"RDNR"])]))
colnames(tmp) <- c("old","new","supposed to be")
tmp
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.