[R] Run script R

Mohamed Benahmed art_med_ahmed at yahoo.fr
Sun Apr 10 01:51:35 CEST 2016


hi all , 
i have an problem in script R . But when I execute the script R I face this error . can you help me please ?? error:-----------------------------------------
Error in FUN(X[[i]], ...) :   Theme element 'text' has NULL property: margin, debugIn addition: Warning messages:1: Removed 361 rows containing non-finite values (stat_smooth). 2: Removed 361 rows containing missing values (geom_path). 3: Removed 6 rows containing missing values (geom_smooth). -------------------------------------------------------------script R:

suppressMessages (library(ggplot2))

source ("graph-style.R")
input = "graphs/figure-3-data-propagation-vs-time/car-relay-jump-distance.txt.gz2"output = "graphs/pdfs/figure-3-data-propagation-vs-time.pdf"
data <- read.table (bzfile(input, "r"), header=TRUE)data$Run = as.factor(data$Run)data$DistanceFromSource = data$NodeId * data$Distance
data = subset(data, Distance %in% c(10, 50, 90, 130, 170))data$Distance = as.factor(data$Distance)

g <- ggplot(data, aes(x=Time-2, y=DistanceFromSource, colour=Distance, linetype=Distance)) +  geom_line (aes(group=paste(Distance, Run, fill=Distance)), show_guide=FALSE, size=0.2) +
  ## stat_summary(aes(group=Distance, colour=Distance), fun.y="mean", geom="line", size = 2) +  ## geom_line (aes(group=Distance, y=mean(DistanceFromSource/1000))) +  geom_smooth (aes(fill=Distance), show_guide=TRUE, method="lm", colour='black', n=20, size=0.3) +
  scale_y_continuous ("Distance from source, km", limits=c(-500,10000), labels=function(x){x/1000}) +  scale_x_continuous ("Time, seconds", limits=c(0,2)) +  scale_colour_brewer("Distance between cars, m", palette="Dark2", guide = "none") +  scale_fill_brewer("Distance between cars, m", palette="Dark2") +  scale_linetype_manual("Distance between cars, m", values=c(1,2,3,4,5,6,7,8)) +  theme_custom () +  theme (legend.position = c(0.99,-0.05), legend.justification=c(1.0,0), legend.direction = "horizontal")
if (!file.exists ("graphs/pdfs")) {  dir.create ("graphs/pdfs")}
pdf (output, width=5, height=3.5)gx = dev.off ()----------------------------------------------------------------------------------------------------------------------script( graph-style.R) :
library(grid)
theme_custom <- function (base_size = 10, base_family = "serif") {  theme_grey(base_size = base_size, base_family = base_family) %+replace%    theme(      line =               element_line(colour = "black", size = 0.5, linetype = 1, lineend = "butt"),      rect =               element_rect(fill = "white", colour = "black", size = 0.5, linetype = 1),      text =               element_text(family = base_family, face = "plain", colour = "black", size = base_size, hjust = 0.5, vjust = 0.5, angle = 0, lineheight = 0.9),      axis.text =          element_text(size = rel(0.8), colour = "grey50"),      strip.text =         element_text(size = rel(0.8)),
      axis.line =          element_blank(),      axis.text.x =        element_text(family = base_family, size = base_size * 0.7, lineheight = 0.8, vjust = 1.2),      axis.text.y =        element_text(family = base_family, size = base_size * 0.7, lineheight = 0.8, hjust = 1.2),      axis.ticks =         element_line(colour = "black", size=0.2),      axis.title.x =       element_text(family = base_family, size = base_size, vjust = 0.5),      axis.title.y =       element_text(family = base_family, size = base_size, angle = 90, vjust = 0.5),      axis.ticks.length =  unit(0.15, "cm"),      axis.ticks.margin =  unit(0.1, "cm"),
      legend.background =  element_rect (fill=NA, colour=NA, size=0.1),      legend.margin =      unit(0.2, "cm"),      legend.key =         element_rect(fill = "grey95", colour = "white"),      legend.key.size =    unit(1.2, "lines"),      legend.key.height =  NULL,      legend.key.width =   NULL,      legend.text =        element_text(family = base_family, size = base_size * 0.8),      legend.text.align =  NULL,      legend.title =       element_text(family = base_family, size = base_size * 0.8, face = "bold", hjust = 1),      legend.title.align = NULL,      legend.position =    "right",      legend.direction =   NULL,      legend.justification = "center",      legend.box =         NULL,
      panel.background =   element_rect(fill = "white", colour = NA),      panel.border =       element_rect(fill = NA, colour = "grey50"),      panel.grid.major =   element_line(colour = "grey60", size = 0.1),      panel.grid.minor =   element_line(colour = "grey70", size = 0.1, linetype="dotted"),      ## panel.margin =       unit(c(0.1, 0.1, 0.1, 0.1), "lines"),
      strip.background =   element_rect(fill = NA, colour = NA),      strip.text.x =       element_text(family = base_family, size = base_size * 0.8),      strip.text.y =       element_text(family = base_family, size = base_size * 0.8, angle = -90),
      plot.background =    element_rect(colour = NA, fill = "white"),      plot.title =         element_text(family = base_family, size = base_size),      plot.margin =        unit(c(0.1, 0.1, 0.1, 0.1), "lines")    )}

	[[alternative HTML version deleted]]



More information about the R-help mailing list