数据可视化课程相关collection
本文用于总结一些®可视化的内容。
ggplot2
- Cheat Sheet
Stackoverflow 有一个整合的帖:
https://stackoverflow.com/questions/3446495/ggplot2-cheat-sheet
[1] http://r-statistics.co/ggplot2-cheatsheet.html
[2] https://ggplot2.tidyverse.org/reference/
- Book
[1] R Graphics Cookbook, Practical Recipes for Visualizing Data
- Color
[1] https://www.supfree.net/search.asp?id=6094.html
一些操作里总是记不住的points
- 怎么在图的横轴纵轴添加有希腊字母的命名
使用expression,但问题是可能使用了还是显示不出,此时可以运行代码:
#setting to type greek character
Sys.setlocale('LC_CTYPE', 'greek')
此问题的解决参考:https://ask.helplib.com/others/post_12867913
我记得也有办法在标题里使用,而且可以是文字+希腊组合的形式,具体等后面有空查询补齐。
- 画完线之后添加点和渐近线
plot(alpha,beta,col = 'blue'
,type = 'l', xlab = expression(alpha), ylab = expression(beta),main = 'Neyman-Pearson alpha-beta curve')
vary = c(seq(-0.4,0.8,0.2))
c_2 = vary*sqrt(10)
points(1-pnorm(c_2),pnorm(vary*sqrt(10)-0.5*sqrt(10)),pch = 16, col = 'red')
abline(h = 0, lty = 3)
abline(h = 1, lty = 3)
abline(v = 0, lty = 3)
abline(v = 1, lty = 3)
添加点用points, 添加渐近线用abline, 其中横线h竖线v。
- 标准正态函数
pnorm为概率分布函数, qnorm为分位数函数。
http://www.mamicode.com/info-detail-993240.html
apply family
参考:https://blog.youkuaiyun.com/qq_34941023/article/details/51571191
merge/cbind/rbind
参考:http://blog.sina.com.cn/s/blog_4b7a920d0102wdnd.html
reduce
参考:http://bbs.pinggu.org/thread-2632228-1-1.html
stringr
命令:
str_split #分割文本
str_sub #提取给定位置文本
str_c #合并文本
str_dup #复制字符串中的字符
str_trim #移除开始和结尾的空格
str_pad #在粘贴一个字符串的时候在左边或右边添加空格
str_detect #寻找文本中满足搜索规则的文本语句
str_extract #提取给定文本
str_replace #替换文本
stringr讲解参考:http://blog.fens.me/r-stringr/
参考:https://blog.youkuaiyun.com/htx931005/article/details/50128745
正则表达式参考:http://www.cnblogs.com/wheng/p/6262737.html
Week 6 - 17th Oct.
package: lubridate
处理日期
package: plyr, dplyr
处理数据的结构等
do.call
一个R里面的小trick
na.rm
处理缺失值。
常见用法:
#计算某一列的平均值, 移除NA值
mean(df$d, na.rm=TRUE)
package: reshape
package: matrix
Function: sparseMatrix, 专门用来形成稀疏矩阵的函数。用来生成稀疏矩阵的数据有三列,第一列是行序号,第二列是列序号,第三列是该行该列对应的数值。
cbind, rbind
cbind是根据列进行合并,合并的前提是所有数据行数相等。
rbind是根据行进行合并,就是自动往下面顺延,但要求所有数据列数是相同的才能用rbind.
as.factor, as.numeric
Week 10 - 14th Nov.
关联规则
R package: arulesViz
https://blog.youkuaiyun.com/jiabiao1602/article/details/45465613
more details:
https://blog.youkuaiyun.com/xsdxs/article/details/50773580
R package: igraph
尝试把arulesViz的结果以新的格式通过igraph画出网络图,发现一些rules and community.
这是一篇关于R语言的数据可视化和数据处理总结。涵盖了ggplot2绘图技巧,如使用points添加点,abline绘制渐近线;数据操作如apply家族、merge/cbind/rbind、reduce;字符串处理函数stringr;日期处理包lubridate;数据清洗和转换的dplyr;以及arulesViz和igraph包在关联规则和网络图绘制中的应用。
8059

被折叠的 条评论
为什么被折叠?



