easychart / beautiful-visualization-with-r Goto Github PK
View Code? Open in Web Editor NEW《R语言数据可视化之美》配套代码
《R语言数据可视化之美》配套代码
dataProjected <- readOGR("China_adm_shp/bou2_4m/bou2_4p.shp")
错误代码如下:
Error in ogrListLayers(dsn = dsn) : Cannot open data source
我在学习过程中遇到以下问题,希望能够得到帮助,谢谢。
当运行下面代码时
# Johnson分布的偏斜度2.2和峰度13
s <- rJohnson(100, findParams(3, 1, 2., 13.1))
# Johnson分布的偏斜度0和峰度20)
k <- rJohnson(100, findParams(3, 1, 2.2, 20))
出现了如下的报错
Error in .C("JohnsonMomentFitR", as.double(mu), as.double(sigma), as.double(skew), :
程序包"SuppDists"里"JohnsonMomentFitR"不适用于.C()
mydata <- data.frame( a=c("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"),
b=c(50, 60, 70, 20,90,110,30))
myAngle <-seq(-20,-340,length.out =7)
ggplot(mydata) +
geom_bar(aes(x=a, y=b),width = 1,stat="identity",
colour = "black",fill="#F8766D") +
geom_text(aes(x=a,y = b-8,label = b),color="white") +
coord_polar(theta = "x",start=0) +
ylim(c(0,120))+
theme_light()+
theme( panel.background = element_blank(),
panel.grid.major = element_line(colour = "grey80",size=.25),
axis.text.y = element_text(size = 12,colour="black"),
axis.line.y = element_line(size=0.25),
axis.text.x=element_text(size = 13,colour="black",angle = myAngle))
Error in if (0 <= angle & angle < 90) { : the condition has length > 1
In addition: The warning message:
Vectorized input to element_text()
is not officially supported.
ℹ Results may be unexpected or may change in future versions of ggplot2.
commonality.cloud
library(tm)
library(wordcloud)
Paper1<-paste(scan("Paper1.txt", what = character(0),sep =""),collapse = " ") #读入 TXT 文档 1
Paper2<-paste(scan("Paper2.txt", what = character(0),sep =""),collapse = " ") #读入 TXT 文档 2
tmpText<- data.frame(c(Paper1,Paper2),row.names=c("Text1","Text2"))
df_title <- data.frame(doc_id=row.names(tmpText),text=tmpText$c.Paper1..Paper2.)
ds <- DataframeSource(df_title)
#创建一个数据框格式的数据源,首列是文档 id(doc_id),第二列是文档内容
corp = VCorpus(ds)
#加载文档集中的文本并生成语料库文件
corp = tm_map(corp,removePunctuation) #清除语料库内的标点符号
corp = tm_map(corp,PlainTextDocument) #转换为纯文本
corp = tm_map(corp,removeNumbers) #清除数字符号
corp = tm_map(corp,function(x){removeWords(x,stopwords())}) #过滤停止词库
term.matrix <- TermDocumentMatrix(corp)
#利用 TermDocumentMatrix()函数将处理后的语料库进行断字处理,生成词频权重矩阵
term.matrix <- as.matrix(term.matrix) #频率
colnames(term.matrix) <- c("Paper1","paper2")
#comparison.cloud(term.matrix,max.words=300,random.order=FALSE,colors=c("#00B2FF", "red"))
#图 3-9-4(a)
commonality.cloud(term.matrix,max.words=100,random.order=FALSE,color="#E7298A")
#图 3-9-4(b)
df<-data.frame(term.matrix)
#wordcloud(row.names(df) , df$Paper1 ,min.freq=10,col=brewer.pal(8,"Dark2"),rot.per=0.3 )
#图 3-9-3(a)
#wordcloud(row.names(df) , df$Paper2 , min.freq=10,col=brewer.pal(8,"Dark2"),rot.per=0.3 )
#图 3-9-3(b
错误是:> commonality.cloud(term.matrix,max.words=100,random.order=FALSE,color="#E7298A")
Error in is_overlap(x1, y1, sw1, sh1, boxes) :
程序包'Rcpp_precious_remove'不提供'Rcpp'这样的函数
书中的3.2.1的条形图是有圆角的,但是代码中不具有,请问这个圆角在ggolot中该如何实现
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.