Description Usage Arguments Value Examples
View source: R/visualizePatentData.R
Factor (or refactor) a data frame of values to be used for graphing in the correct order.
Many graphs require a reordering when plotting with a fill value. This
helper function factors the x-value of a plot that will be stacked by
fillVal
.
1 | factorForGraph(df, xVal, fillVal, decFill = TRUE)
|
df |
A data frame containing the x and fill value columns. |
xVal |
A character value from a header name in |
fillVal |
A character value from a header name in |
decFill |
Sort fill value in decreasing order. |
A data frame with two of the columns factored.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | sumo <- cleanPatentData(patentData = patentr::acars, columnsExpected = sumobrainColumns,
cleanNames = sumobrainNames,
dateFields = sumobrainDateFields,
dateOrders = sumobrainDateOrder,
deduplicate = TRUE,
cakcDict = patentr::cakcDict,
docLengthTypesDict = patentr::docLengthTypesDict,
keepType = "grant",
firstAssigneeOnly = TRUE,
assigneeSep = ";",
stopWords = patentr::assigneeStopWords)
# note that in reality, you need a patent analyst to carefully score
# these patents, the score here is for demonstrational purposes
score <- round(rnorm(dim(sumo)[1],mean=1.4,sd=0.9))
score[score>3] <- 3
score[score<0] <- 0
sumo$score <- score
dim(sumo)
sumoFactor <- factorForGraph(sumo, "assigneeClean", "score")
# if you want to view, uncomment and load ggplot2
# ggplot(sumoFactor, aes(x=assigneeClean, y=score, fill=factor(score))) +
# geom_bar(stat="identity")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.