【发布时间】:2015-10-02 10:28:28
【问题描述】:
当我尝试使用此代码将使用 ggplot 制作的绘图保存为 pdf 时:
library(ggplot2)
file = "/data/mda/20150630-1Mb-full_comparison-low_depth_hTERT/result/comparison_figure/SD_rank_custom.csv"
figure_file = "/data/mda/20150604-1Mb-full_comparison-low_depth_hTERT/result/comparison_figure/SD_rank_custom.pdf"
sd_data <- as.data.frame(read.csv(file, header=TRUE))
# generate box plot
ggplot(
data=sd_data,
aes(
x=Experiment,
y=SD
)
)+
theme_bw() + #use bw theme
geom_boxplot(outlier.shape = NA) + #hide outlier points
geom_jitter() +
theme(axis.text.x = element_text(angle = 90, vjust = 0.5, hjust=1))
ggsave(
filename=figure_file,
width=10,
height=10
)
我收到以下错误:
grDevices::pdf(..., version = version) 中的错误:
无法打开文件'file.pdf'
调用:ggsave -> 设备 ->
执行停止
我认为我的 R 版本最近更新到 3.2.0,并且我已经确认它在 v3.1.1 中运行良好,所以我假设这是与版本相关的。我还确认可以将 csv 文件写入目录。
任何想法如何解决这个问题?
【问题讨论】:
-
能否请您发布您正在使用的代码?
-
您对当前工作目录有写权限吗?
getwd()返回什么? -
在帖子中回答了 2 个以上的 cmets
-
file.info("/data/mda/20150604-1Mb-full_comparison-low_depth_hTERT/result/comparison_figure/")$isdir是否返回TRUE?这真的只是一个文件权限问题。阅读不同于写作。你能写到那个目录吗? -
你的pdf打开了吗?