更改 trelliscope 包图中的格式 - Zillow Data
Change formatting in trelliscope package plots - Zillow Data
所以我刚刚在 R 中安装了一个名为 trelliscope 的包。这很棒,但我在格式化时遇到了问题。它相当新,没有太多关于它的文档,想听听一些意见。所以我生成了以下代码(如果您完全按照代码进行操作,您将能够重现我所做的)。地块上的默认点color/format不合我意:
install.packages("devtools") # if not installed
devtools::install_github("tesseradata/datadr")
devtools::install_github("tesseradata/trelliscope")
devtools::install_github("hafen/housingData")
library(housingData)
library(datadr)
library(trelliscope)
conn <- vdbConn("vdb", name = "Zillow")
byCounty <- divide(housing,
by = c("county", "state"))
byCounty
# look at a subset of byCounty
byCounty[[1]]
timePanel <- function(x)
xyplot(medListPriceSqft + medSoldPriceSqft ~ time,
data = x, auto.key = TRUE, ylab = "Price / Sq. Ft.")
timePanel
priceCog <- function(x) {
zillowString <- gsub(" ", "-", do.call(paste, getSplitVars(x)))
list(
slope = cog(coef(lm(medListPriceSqft ~ time, data = x))[2],
desc = "list price slope"),
meanList = cogMean(x$medListPriceSqft),
meanSold = cogMean(x$medSoldPriceSqft),
nObs = cog(length(which(!is.na(x$medListPriceSqft))),
desc = "number of non-NA list prices"),
zillowHref = cogHref(
sprintf("http://www.zillow.com/homes/%s_rb/", zillowString),
desc = "zillow link")
)
}
priceCog(byCounty[[1]]$value)
# create the display and add to vdb
makeDisplay(byCounty,
name = "list_sold_vs_time_quickstart",
desc = "List and sold price over time",
panelFn = timePanel,
cogFn = priceCog,
width = 400, height = 400,
lims = list(x = "same"))
view()
在 运行 这段代码之后,有人可以帮我确定如何更改绘图的设置,例如点的颜色、点大小等,只是为了让它看起来更好吗?我真的只是在寻找一种编码结构来更改格式,然后如果我能在代码中找到一个好的起点,我可以自己进入细节。
谢谢!
您可以在 timePanel 函数中添加磅值和颜色参数。例如,尝试:
timePanel <- function(x)
xyplot(medListPriceSqft + medSoldPriceSqft ~ time,
data = x, auto.key = TRUE, ylab = "Price / Sq. Ft.",
par.settings = list(superpose.symbol = list(
cex = c(1,2), col =c("black", "red"))))
timePanel
所以我刚刚在 R 中安装了一个名为 trelliscope 的包。这很棒,但我在格式化时遇到了问题。它相当新,没有太多关于它的文档,想听听一些意见。所以我生成了以下代码(如果您完全按照代码进行操作,您将能够重现我所做的)。地块上的默认点color/format不合我意:
install.packages("devtools") # if not installed
devtools::install_github("tesseradata/datadr")
devtools::install_github("tesseradata/trelliscope")
devtools::install_github("hafen/housingData")
library(housingData)
library(datadr)
library(trelliscope)
conn <- vdbConn("vdb", name = "Zillow")
byCounty <- divide(housing,
by = c("county", "state"))
byCounty
# look at a subset of byCounty
byCounty[[1]]
timePanel <- function(x)
xyplot(medListPriceSqft + medSoldPriceSqft ~ time,
data = x, auto.key = TRUE, ylab = "Price / Sq. Ft.")
timePanel
priceCog <- function(x) {
zillowString <- gsub(" ", "-", do.call(paste, getSplitVars(x)))
list(
slope = cog(coef(lm(medListPriceSqft ~ time, data = x))[2],
desc = "list price slope"),
meanList = cogMean(x$medListPriceSqft),
meanSold = cogMean(x$medSoldPriceSqft),
nObs = cog(length(which(!is.na(x$medListPriceSqft))),
desc = "number of non-NA list prices"),
zillowHref = cogHref(
sprintf("http://www.zillow.com/homes/%s_rb/", zillowString),
desc = "zillow link")
)
}
priceCog(byCounty[[1]]$value)
# create the display and add to vdb
makeDisplay(byCounty,
name = "list_sold_vs_time_quickstart",
desc = "List and sold price over time",
panelFn = timePanel,
cogFn = priceCog,
width = 400, height = 400,
lims = list(x = "same"))
view()
在 运行 这段代码之后,有人可以帮我确定如何更改绘图的设置,例如点的颜色、点大小等,只是为了让它看起来更好吗?我真的只是在寻找一种编码结构来更改格式,然后如果我能在代码中找到一个好的起点,我可以自己进入细节。
谢谢!
您可以在 timePanel 函数中添加磅值和颜色参数。例如,尝试:
timePanel <- function(x)
xyplot(medListPriceSqft + medSoldPriceSqft ~ time,
data = x, auto.key = TRUE, ylab = "Price / Sq. Ft.",
par.settings = list(superpose.symbol = list(
cex = c(1,2), col =c("black", "red"))))
timePanel