library(dplyr)
select(diamonds, carat, depth, table) %>% plot()
3D plotting with RGL
library(rgl)
NYC <- read.csv("http://www.math.smith.edu/~bbaumer/mth241/nyc.csv")
opacity <- 0.4
with(NYC, plot3d(x = Food, y = Service, z = Price, type = "s", size = 0.3,
col = "blue", xlab = "Food Rating", ylab = "Service Rating",
zlab = "Price ($)"))
mod.fs <- lm(Price ~ Food + Service, data = NYC)
coefs <- coef(mod.fs)
planes3d(coefs["Food"], coefs["Service"], -1, coefs["(Intercept)"], alpha = opacity,
col = "lightgray")
with(NYC, plot3d(x = Food, y = Service, z = Price, type = "s", size = 0.8,
col = "blue", xlab = "Food Rating", ylab = "Service Rating",
zlab = "Price ($)"))
coefs <- coef(lm(Price ~ Food + Service + East, data=NYC))
planes3d(coefs["Food"], coefs["Service"], -1, coefs["(Intercept)"], alpha = opacity, col = "lightgray")
planes3d(coefs["Food"], coefs["Service"], -1, coefs["(Intercept)"] + coefs["East"], alpha = opacity, col = "lightgray")
library(mosaic)
mwarp <- lm(Price ~ Food + Service + Food * Service, data=NYC)
price.warp <- makeFun(mwarp)
with(NYC, plot3d(x = Food, y = Service, z = Price, type = "s", size = 1.5,
col = "blue", xlab = "Food Rating", ylab = "Service Rating",
zlab = "Price ($)"))
plot3d(price.warp, alpha = opacity, col = "pink", add=TRUE, xlim=c(0,30), ylim=c(0,30), zlim=c(0,80))
Grand tour
library(tourr)
select(diamonds, carat, depth, table, x, y, z) %>%
animate(grand_tour(), display = display_xy(),fps=15)
Bertin matrices
# install.packages("bertin",repos="http://r-forge.r-project.org")
library(bertin)
data(Hotel)
image.bertin(bertinrank(Hotel, ties.method="first"), main= "Hotel data")
plot.bertin(bertinrank(Hotel, ties.method = "first"), main= "Hotel data")
plot.bertin(Hotel, palette=c("white","black"))