想在一个页面上绘制两个ggplots.以Cookbook for R为例,它不起作用.错误是could not find function "multiplot".
然而ggplots是可绘制的,我也重新安装了R,ggplot2,重新启动等等.我做错了什么?
library(ggplot2)
# This example uses the ChickWeight dataset, which comes with ggplot2
# First plot
p1 <-
ggplot(ChickWeight, aes(x=Time, y=weight, colour=Diet, group=Chick)) +
geom_line() +
ggtitle("Growth curve for individual chicks")
# Second plot
p2 <-
ggplot(ChickWeight, aes(x=Time, y=weight, colour=Diet)) +
geom_point(alpha=.3) +
geom_smooth(alpha=.2, size=1) +
ggtitle("Fitted growth curve per diet")
# Third plot
p3 <-
ggplot(subset(ChickWeight, Time==21), aes(x=weight, colour=Diet)) +
geom_density() +
ggtitle("Final weight, by diet")
# Fourth …Run Code Online (Sandbox Code Playgroud) 想text在句子中分割出一个字符元素的向量.分裂标准有多种模式("and/ERT","/$").也有例外(:/$.,and/ERT then,./$. Smiley)自该模式.
尝试:匹配拆分应该的情况."^&*"在该位置插入一个不寻常的图案().strsplit具体模式
问题:我不知道如何正确处理异常.有明确的情况"^&*"应该消除异常模式()并在运行之前恢复原始文本strsplit.
码:
text <- c("This are faulty propositions one and/ERT two ,/$, which I want to split ./$. There are cases where I explicitly want and/ERT some where I don't want to split ./$. For example :/$. when there is an and/ERT then I don't want to split ./$. This is also one case where I …Run Code Online (Sandbox Code Playgroud) 我youtube-dl经常使用并且有一个非常简单的文件命名方案:仅小写字母,同一组的事物用“-”(减号,破折号等)连接,而不同的事物用“_”(下划线)连接。
我不喜欢正则表达式,因此,如果可以配置youtube-dl配置文件来根据我的命名方案存储下载的剪辑,我真的很困惑。例如:
视频:
youtube-dl https://www.youtube.com/watch?v=X8uPIquE5Oo
Run Code Online (Sandbox Code Playgroud)
我的 youtube-dl config:
--output '~/videos/%(uploader)s_%(upload_date)s_%(title)s.%(ext)s' --restrict-filenames
Run Code Online (Sandbox Code Playgroud)
我的输出:
Queen_Forever_20111202_Bohemian_Rhapsody_Live_at_Wembley_11-07-1986.mp4
Run Code Online (Sandbox Code Playgroud)
期望的输出:
queen-forever_20111202_bohemian-rhapsody-live-at-wembley-11-07-1986.mp4
Run Code Online (Sandbox Code Playgroud)
and/ERT仅当in之后的一个单词内没有“/V”后继时,您将如何拆分 at :
text <- c("faulty and/ERT something/VBN and/ERT else/VHGB and/ERT as/VVFIN and/ERT not else/VHGB propositions one and/ERT two/CDF and/ERT three/ABC")
# my try - !doesn't work
> strsplit(text, "(?<=and/ERT)\\s(?!./V.)", perl=TRUE)
^^^^
# Exptected return
[[1]]
[1] "faulty and/ERT something/VBN and/ERT else/VHGB and/ERT as/VVFIN and/ERT"
[2] "not else/VHGB propositions one and/ERT"
[3] "two/CDF and/ERT"
[4] "three/ABC"
Run Code Online (Sandbox Code Playgroud) 考虑到ID,我需要在稀疏数据帧上运行求和
require(data.table)
sentEx = structure(list(abend = c(1, 1, 0, 0, 2), aber = c(0, 1, 0, 0,
0), über = c(1, 0, 0, 0, 0), überall = c(0, 0, 0, 0, 0), überlegt = c(0,
0, 0, 0, 0), ID = structure(c(1L, 1L, 2L, 2L, 2L), .Label = c("0019",
"0021"), class = "factor"), abgeandert = c(1, 1, 1, 0, 0), abgebildet = c(0,
0, 1, 1, 0), abgelegt = c(0, 0, 0, 0, 3)), .Names = c("abend",
"aber", "über", "überall", …Run Code Online (Sandbox Code Playgroud) 你如何只提取/以下大写字母和整个字母[[:punct:]]/$[[:punct:]].
text <- c("This/ART ,/$; Is/NN something something/else A/VAFIN faulty/ADV text/ADV which/ADJD i/PWS propose/ADV as/APPR Example/NE ./$. So/NE It/PTKNEG makes/ADJD no/VAFIN sense/ADV at/KOUS all/PDAT ,/$, it/APPR Has/ADJA Errors/NN ,/$; and/APPR it/APPR is/CARD senseless/NN again/ART ./$:")
# HOW to?
textPOS <- strsplit(text,"( )|(?<=[[:punct:]]/\\$[[:punct:]])", perl=TRUE)
# ^^^
# extract only the "/" with the following capital letters
# and the whole "[[:punct:]]/$[[:punct:]]"
# Expected RETURN:
> textPOS
[1] "/ART" ",/$;" "/NN" "/VAFIN" "/ADV" "/ADV" "/ADJD" "/PWS" "/ADV" "/APPR" …Run Code Online (Sandbox Code Playgroud) 我需要一个关于不同因素的不同分布的论文.只有标准的方法似乎package(ineq)足够灵活.
但是,它不允许我在课堂上放点(见下面的评论).重要的是要看到它们,理想情况是单独命名它们.这可能吗?
Distr1 <- c( A=137, B=499, C=311, D=173, E=219, F=81)
Distr2 <- c( G=123, H=400, I=250, J=16)
Distr3 <- c( K=145, L=600, M=120)
library(ineq)
Distr1 <- Lc(Distr1, n = rep(1,length(Distr1)), plot =F)
Distr2 <- Lc(Distr2, n = rep(1,length(Distr2)), plot =F)
Distr3 <- Lc(Distr3, n = rep(1,length(Distr3)), plot =F)
plot(Distr1,
col="black",
#type="b", # !is not working
lty=1,
lwd=3,
main="Lorenz Curve for My Distributions"
)
lines(Distr2, lty=2, lwd=3)
lines(Distr3, lty=3, lwd=3)
legend("topleft",
c("Distr1", "Distr2", "Distr3"),
lty=c(1,2,3),
lwd=3)
Run Code Online (Sandbox Code Playgroud)
这就是它现在的样子

r ×7
regex ×4
strsplit ×3
text-mining ×3
ggplot2 ×2
data.table ×1
distribution ×1
plot ×1
python ×1
syntax-error ×1
wordnet ×1
youtube-dl ×1