在中国地图上填充离散变量

继续昨天的话题,昨天我们介绍了如何使用 ggplot2 + sf 绘制中国各级行政地图。然后在地图上填充了随机生成的数据。需要注意的是,我们生成的随机数据是一个连续变量,所以我们使用的 scale_fill_viridis_c() 方案进行颜色映射。实际工作中我们还有可能会遇到离散变量的情形,或者需要把连续变量分割成离散变量进行绘图的情形。本文就介绍了如何进行这两种操作。

这里只展示了三分之一的内容,更多内容尽在 TidyFriday!

使用 ggplot2 + sf 绘制中国地图

本文介绍了如何使用 ggplot2 + sf 绘制中国的各级行政区、水网、路网等地图,还介绍了如何在地图上添加标签、比例尺和指北针等。

欢迎加入 TidyFriday!

欢迎加入 TidyFriday 的知识星球!使用微信扫描上面的二维码即可加入!点击阅读全文可领取 20 元优惠券!

TidyFriday 是受 TidyTuesday 启发建立的,但是 TidyFriday 并不打算局限于 R,本着实用主义和分享精神, TidyFriday 致力于促进一切有用的知识的传播,致力于促进成员的学习和成长,致力于解决实际问题而非虚无的讨论代码。尽管如此,TidyFriday 目前阶段将着重于使用 R,Stata 和 Python 进行数据分析、模型构建、可视化及在社科领域的应用。为了保证 TidyFriday 的高质量发展,本社群将依托知识星球GitHub,实行付费制。同时 TidyFriday 将会为用户和成员提供超出会费的服务和产品。

你最常用哪个表情?

本文介绍了如何在 ggplot 图表上添加 GIF 图。

Cost of Living Ranking by Country & City

Expatistan provides two kinds of data: Cost of Living Ranking by Country and Cost of Living Ranking by City. It’s very easy to get these two data. This article introduced how to crawl these data and visualize theme on map.

Launch and Interact with a STATA Session

Yesterday, I found a interesting R Package on GitHub - bubble. This package provides a REPL (交互解释器) between R and node. And its source codes are quiet simple, so I want to know if I can create a Stata REPL by imitating it. Then we have statarepl package which provides a REPL interface between R and Stata, it’s different from RStata, which I have introduced before.

Mapping Quandl Macroeconomic Data

This is my notes for learning Mapping Quandl Macroeconomic Data. In this article, we are going to be working with a macroeconomic data source from the World Bank called World Development Indicators (WDI). The Quandl code for WDI is WWDI, and thus we’ll prepend WWDI/ to each data set call. For more details, you can refer to: https://docs.quandl.com/docs/r-time-series and http://datatopics.worldbank.org/world-development-indicators/

Rsampling Fama French

This is my notes for learning Rsampling Fama French. This article introduced how to conduct k-fold cross validation in R using rsample and yardstick packages. For more details, you can read the original article.

Regional Population Distribution of China, Just a Graph.

It’s very hard to get Chinese population at county level. So I just get this data for year 2004.

The shp data: chinamap.zip, theme.R can be found in this article: Create Complete China Maps Using GGPLOT2 and SF, Population data set: 全国分县市人口统计资料2004.xlsx

Portfolio Backtesting

This is my note for learning Portfolio Backtesting

Momentum Investing with R

This is my note for learning Momentum Investing with R.

In practice, momentum entails a look back into the past to determine whether an asset has exceed some benchmark, and if it has, buy and hold that asset for some benchmark, and if it has, buy and hold that asset for some time into the future. That’s completely flying in the face of the efficient market hypothesis because it’s positing that the past is somehow giving us information that has not been reflected in the current price of the asset.

A quick tour of GA

This is my note for learning A quick tour of GA.

Genetic algorithms(GAs) are stochastic search algorithms inspired by the basic principles of biological evolution and natural selection. GAs simulate the evolution of living organisms, where the fittest individuals dominate over the weaker ones, by mimicking the biological mechanisms of evolution, such as selection, crossover and mutation.

Introduction to Fama French

This is my note for learning Introduction to Fama French.

Today, we will be workding with our usual portfolio consisting of:

  • SPY (S&P500 fund) weighted 25%
  • EFA (a small-cap value fund) weighted 25%
  • IJS (a small-cap value fund) weighted 20%
  • EEM (a emerging-mkts fund) weighted 20%
  • AGG (a bond fund) weighted 10%

Themes for base plotting system in R

This is my note for learning Themes for base plotting system in R.

basetheme package is a magic package, which let you love R’s base plotting system again!

Visualizing Natural Disaster Cost

This is my note for learning Visualizing Natural Disaster Cost.

If you cannot download data-2.tsv from the provided URL, you can download it from data-2.tsv.

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×