Description Usage Arguments Value Note Examples
This function helps put a set of values into a large dataframe based on search criteria. This is useful for doing calculations that require species-specific values.
1 | putChar(x, searchVals, responseName)
|
x |
This is your full dataframe that you search. |
searchVals |
This is a dataframe that includes your search criteria. The final column is the responses that you want to insert. |
responseName |
This is what you want your response Column (the one you get back) named. |
This function returns a response dataframe with 1 column and rownumbers matching the initial rownumbers of x.
This may function unexpectedly if your searchVals criteria do not cover the entire length of x. E.g., if you miss 20 rows entirely, your response column will be a different length, and if you stick it back into TreesCA, it might just restart itself instead of putting "NA" or "NULL".
If you're having problems accessing something with your results, be sure that the str() is your desired type, and not the data.frame that this function passes.
1 2 3 4 5 6 7 8 9 | myDf <- data.frame(type=c(rep("vegetable", 10), rep("fruit", 10)),
species=c(rep("broccoli",5), rep("beans", 5), rep("apples", 5),
rep("oranges", 5)), weights=as.numeric(runif(20, 0, 2)))
uniques <- unique(myDf[,1:2])
uniques$val <- c("Gross", "Yum", "Ew", "Florida!")
putChar(myDf, uniques)
## remove species and duplicates to demonstrate only one search column
uniques <- uniques[c(1,3), c(1,3)]
putChar(myDf, uniques, "test")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.