manipulate(
実行スクリプト,
picker, sliderの情報(複数の場合はカンマで結合)
)
manipulate(
{
複数の実行スクリプト
},
picker, sliderの情報(複数の場合はカンマで結合)
)
library(manipulate)
title="PCH Symbols"
xlabel="x"
ylabel="y"
plot(0,0,pch=8,cex=5,col="blue", main=title, xlab=xlabel, ylab=ylabel)
manipulate(plot(0,0,pch=8,cex=5,col=myColors), myColors=picker("red", "violet", "pink", "orange", "yellow", "green", "blue", "cyan") )
colors = c("red", "violet", "pink", "orange", "yellow", "green", "blue", "cyan")
manipulate(plot(0,0,pch=8,cex=5,col=myColors), myColors=picker(colors) )
manipulate(
plot(0,0,pch=myMarkers,cex=5,col=myColors), myColors=picker("red", "violet", "pink", "orange", "yellow", "green", "blue", "cyan",initial="violet"),
myMarkers=picker(1,2,3,4,5,6,7,8,initial="5")
)
colPalets = c("red", "violet", "pink", "orange", "yellow", "green", "blue", "cyan")
manipulate(
plot(0,0,pch=myMarkers,cex=5,col=myColors, main=title, xlab=xlabel, ylab=ylabel),
myColors=picker(as.list(colPalets),initial=colPalets[2]),
myMarkers=picker(as.list(seq(1,8)),initial="5")
)
manipulate(
plot(0,0,pch=8,cex=mySize,col="blue"),
mySize=slider(1,10,initial=5,step=2)
)
wdLst.BBC <- getWordFreq("G7/BBC.txt")
head(wdLst.BBC)
wordLst
the in of to a ukraine
24 15 13 10 9 7
color8 = c("red", "violet", "pink", "orange", "yellow", "green", "blue", "cyan")
barplot(wdLst.BBC, las=3,col=color8,ylab="Frequency")
length(wdLst.BBC)
[1] 239
barplot(wdLst.BBC[1:length(wdLst.BBC)], las=3,col=color8,ylab="Frequency")
las = 0 : XYの両軸とも目盛り文字は軸方向(デフォルト)
las = 1 : XYの両軸とも目盛り文字は水平方向
las = 2 : XYの両軸とも目盛り文字は軸方向と直角
las = 3 : XYの両軸とも目盛り文字は垂直方向
max.Index<-10
barplot(wdLst.BBC[1:max.Index], las=3,col=color8,ylab="Frequency")
-軸ラベルの向き -wdLst.BBCの単語最大表示数(最小値=5,最大値=全出現数(Types),Step=20)
library(wordcloud)
binfo<-brewer.pal.info[]
head(binfo)
palets <-rownames(binfo[binfo$maxcolors>10,])
palets
[1] "BrBG" "PiYG" "PRGn" "PuOr" "RdBu" "RdGy" "RdYlBu"
[8] "RdYlGn" "Spectral" "Paired" "Set3"
palets[10]#"Paired"
[1] "Paired"
max.Index<-20
barplot(wdLst.BBC[1:max.Index], las=3,col=brewer.pal(10,palets[1]),ylab="Frequency")
install.packages("syuzhet")
library(syuzhet)
text1_string <- get_text_as_string("G7/Aljazeera.txt")
text1_words <- get_tokens(text1_string)
head(text1_words)
[1] "top" "diplomats" "from" "the" "group" "of"
length(text1_words)
[1] 402
text1_sentiment_scores <- get_nrc_sentiment(text1_words)
barplot(
colSums(prop.table(text1_sentiment_scores[, 1:8])),
space = 0.1,
horiz = TRUE,
las = 1,
cex.names = 0.7,
col = brewer.pal(n = 8, name = "Set3"),
main = "Aljazeera, 8 Nov 2023",
sub = "AL JAZEERA AND NEWS AGENCIES",
xlab="emotions", ylab = NULL)
text2_string <- get_text_as_string("G7/BBC.txt")
text2_words <- get_tokens(text2_string)
head(text2_words)
[1] "at" "a" "g7" "meeting" "in" "japan"
text2_sentiment_scores <- get_nrc_sentiment(text2_words)
barplot(
colSums(prop.table(text2_sentiment_scores[, 1:8])),
space = 0.1,
horiz = TRUE,
las = 1,
cex.names = 0.8,
col = brewer.pal(n = 8, name = "Set3"),
main = "BBC, 8 Nov 2023",
sub = "By Ido Vock BBC News",
xlab="emotions", ylab = NULL)
sentiData<-cbind(colSums(prop.table(text1_sentiment_scores[, 1:8])),colSums(prop.table(text2_sentiment_scores[, 1:8])))
sentiData
[,1] [,2]
anger 0.08571429 0.20588235
anticipation 0.15714286 0.10294118
disgust 0.01428571 0.05882353
fear 0.20000000 0.27941176
joy 0.10000000 0.04411765
sadness 0.10000000 0.08823529
surprise 0.05714286 0.02941176
trust 0.28571429 0.19117647
colnames(sentiData) <- c("ALJAZEERA","BBC")
barplot(sentiData,
space = 0.1,
horiz = TRUE,
las = 1,
cex.names = 0.8,
col = brewer.pal(n = 8, name = "Set3"),
legend.text = rownames(sentiData),
xlab = "Sentiment Score Ratio",
ylab = "Article",
main = "")