facetPlot: Make a tiled plot

Description Usage Arguments Value Examples

Description

Tile plot an x and y variable by facet z.

Tile plots are a a great way to show a dense amount of information in one plot sequence. Plotting document count by category, and plotting by assignee, is one example.

Usage

1
2
facetPlot(df, xVal, fillVal, facetVal, colors = patentr::scoreColors,
  recolor = FALSE)

Arguments

df

A data frame of the cleaned data you want to plot.

xVal

A character string of the x value you want for your plot, must be a name of the header in df.

fillVal

A character string of the fill value you want for your plot, must be a name of the header in df.

facetVal

A character string of the facet you want for your plot, must be a name of the header in df.

colors

A character vector of colors, the same length as the number of unique values in the column of xVal[,fillVal]. Default set to scoreColors.

recolor

A logical allowing you to choose to recolor the plot if the colors vector is not applicable to you. Default set to FALSE. Uses the helper function makeColors to generate colors. Note that your plot may fail if colors is not the same length as the number of unique values in fillVal and recolor is set to FALSE.

Value

A ggplot2 plot object.

Examples

 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
28
29
30
31
32
## Not run: 
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
sumo$assigneeSmall <- strtrim(sumo$assigneeClean,12)
category <- c("system","control algorithm","product","control system", "communication")
c <- round(rnorm(dim(sumo)[1],mean=2.5,sd=1.5))
c[c>5] <- 5; c[c<1] <- 1
sumo$category <- category[c]

xVal = "category"
fillVal = "score"
facetVal = "assigneeSmall"

facetPlot(subset(sumo, score > 0), xVal, fillVal, facetVal, colors = patentr::scoreColors,
          recolor = FALSE)

## End(Not run)

kamilien1/patentR documentation built on May 20, 2019, 7:19 a.m.