r 探索R的rbokeh图书馆
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了r 探索R的rbokeh图书馆相关的知识,希望对你有一定的参考价值。
library(dplyr)
library(ggplot2)
library(rbokeh)
########################
# Layering
########################
# Histogram & Density Plot - Price
ggplot(diamonds) + aes(price, y = ..density..) +
geom_histogram(binwidth = 100) +
geom_density(color = "red")
figure() %>%
ly_hist(price, data = diamonds, breaks = 250, freq = FALSE) %>%
ly_density(price, data = diamonds, color = "red")
########################
# Interaction
########################
# Take a sample of 1000 from diamonds dataset
dsmall <- sample_n(diamonds, 1000)
# Scatterplot - Carat vs Price, with Cut
ggplot(dsmall) + aes(carat, price, color = cut) +
geom_point(alpha = 0.5, size = 4)
# Make same scatterplot with rbokeh
figure() %>%
ly_points(carat, price, data = dsmall, color = cut)
# Make same scatterplot with rbokeh - width = 600
figure(width = 600) %>%
ly_points(carat, price, data = dsmall, color = cut)
# Add a interactive tool capability - lasso
figure(width = 600) %>%
ly_points(carat, price, data = dsmall, color = cut) %>%
tool_lasso_select()
# Add hover labels to the point
figure(width = 600) %>%
ly_points(carat, price, data = dsmall, color = cut,
hover = list(carat, price, color))
########################
# Mapping
########################
# Create a dummy data frame of points
set.seed(500)
df <- round(data.frame(
lon = jitter(rep( 77.59, 50), amount = .3),
lat = jitter(rep( 12.97, 50), amount = .3)
), digits = 2)
# Plot these points on the map using ggmap
library(ggmap)
map <- get_map("Bangalore")
ggmap(map)
ggmap(map) + geom_point(data = df, aes(lon, lat),
color = "red", size = 6)
# Plot these points on the map using rbokeh
map1 <- gmap(lat = 12.97, lng = 77.59, zoom = 9,
width = 500, height = 500)
map1 %>%
ly_points(lon, lat, data = df, alpha = 0.8, col = "red",
hover = c(lon, lat))
以上是关于r 探索R的rbokeh图书馆的主要内容,如果未能解决你的问题,请参考以下文章
r R中数据科学竞赛的共同特征探索功能
R数据科学(五)探索性数据分析
R在HPC MPIcluster上运行foreach dopar循环
R基础--快速探索数据(《R可视化》)
R探索新数据分析(Exploratory Data Analysis,EDA)
《数据挖掘R语言实战》图书介绍,数据挖掘相关人员看过来!