我正在尝试从R脚本中自动化一些基本的git操作。我在Windows OS上使用Rstudio。例如,如果您希望在脚本完成一些自动化任务后更新GitHub,这可能会有所帮助。
我编写了一些简单的函数,这些函数利用R shell()函数和Window的&管道运算符将命令链发送到OS终端:
# Git status.
gitstatus <- function(dir = getwd()){
cmd_list <- list(
cmd1 = tolower(substr(dir,1,2)),
cmd2 = paste("cd",dir),
cmd3 = "git status"
)
cmd <- paste(unlist(cmd_list),collapse = " & ")
shell(cmd)
}
# Git add.
gitadd <- function(dir = getwd()){
cmd_list <- list(
cmd1 = tolower(substr(dir,1,2)),
cmd2 = paste("cd",dir),
cmd3 = "git add --all"
)
cmd <- paste(unlist(cmd_list),collapse = " & ")
shell(cmd)
}
# Git commit.
gitcommit <- function(msg = "commit from Rstudio", …Run Code Online (Sandbox Code Playgroud) 我想保存ggplotR 中的文件以便在 Adobe Illustrator (AI) 中进行编辑。我可以将绘图保存为EPS或PS格式ggsave,但绘图总是在文本周围带来一些阴影。有没有办法在 R 或 Adobe Illustrator 中解决这个问题?
例如,我的情节如下所示:
但是,当我将其导入 AI 时,它看起来像这样(文本周围的粉红色阴影):
# Saving a plot for editing in Adobe Illustrator.
library(ggplot2) # for plotting
library(cowplot) # for ggsave
# Generate an example scatter plot.
# From: http://r-statistics.co/Top50-Ggplot2-Visualizations-MasterList-R-Code.html
options(scipen=999) # turn-off scientific notation like 1e+48
theme_set(theme_gray())
data("midwest", package = "ggplot2")
plot <- ggplot(midwest, aes(x=area, y=poptotal)) +
geom_point(aes(col=state, size=popdensity)) +
geom_smooth(method="loess", se=F) +
xlim(c(0, 0.1)) + …Run Code Online (Sandbox Code Playgroud)