[R] How to troubleshoot issue with curve() function?

Lavrenz, Steven M slavrenz at purdue.edu
Wed Jun 25 23:02:31 CEST 2014

I am trying to plot data that I imported with read. table using a Weibull distribution. Here's the code I used for importing the data:

data <- read.table(file =
"C:/Users/Steven/OneDrive/Unfiled/Temp/phase2.csv", header = FALSE, sep = ",", dec = ".", col.names = c("cycle_time", "cycle_length", "red_time", "prot_green", "perm_green", "veh_count", "vc", "max_delay", "prot_occ", "perm_occ", "red5_occ", "gor", "ror", "arrival_time"), na.strings = "NA")

And here's my code for plotting:

curve(dexp(data(arrival_time), rate=0.06), from = 0, to = 60, main = "Exponential distribution")

I keep getting this error message:

Error in curve(dexp(data(arrival_time), rate = 0.06), from = 0, to = 60,  : 
  'expr' must be a function, or a call or an expression containing 'x'

How to I begin to troubleshoot this? The only thing I can think of is that my variable of interest, "arrival_time", does contain a number of rows with blanks, but would that be the underlying cause? If so, can I get the function to ignore blank rows?

More information about the R-help mailing list