tiff
не имеет значения, как вы назовете свой файл, он будет сохранен в формате TIFF, что приведет к большому размеру.Следовательно, вы должны изменить tiff('FORMCOBSPRED.JPEG', units="in", width=4, height=3, res=1200)
на jpeg('FORMCOBSPRED.JPEG', units="in", width=4, height=3, res=1200)
.Если вы используете ggsave
, он сохранит его в соответствии с расширением вашего файла, таким образом, как jpeg.См. Сравнение ниже:
library(ggplot2)
# tiff will result in huge size, even though you name it .jpeg:
tiff("iris_tiff.jpeg", units="in", width=4, height=3, res=1200)
qplot(x = Sepal.Width, y = Sepal.Length, color = Species, data = iris, geom = "point")
dev.off()
file.size("iris_tiff.jpeg") # size is 51840192
# using jpeg() solves that Problem:
jpeg("iris_jpeg.jpeg", units="in", width=4, height=3, res=1200)
qplot(x = Sepal.Width, y = Sepal.Length, color = Species, data = iris, geom = "point")
dev.off()
file.size("iris_jpeg.jpeg") # size is 563329
# if we use the functionality of ggsave, which automatically determines type given extension:
ggsave(filename = "iris.jpeg",
plot = qplot(x = Sepal.Width, y = Sepal.Length, color = Species, data = iris, geom = "point"),
units="in", width=4, height=3, dpi=1200)
file.size("iris.jpeg") # size is 563329, hence same as jpeg()
# same for tiff-extension:
ggsave(filename = "iris.tiff",
plot = qplot(x = Sepal.Width, y = Sepal.Length, color = Species, data = iris, geom = "point"),
units="in", width=4, height=3, dpi=1200)
file.size("iris.tiff") # size is 51840192, hence same as tiff()