[R] What is wrong with this plotting?
Sarah Goslee
sarah.goslee at gmail.com
Fri Jan 6 18:08:12 CET 2012
I think it's even simpler than that:
>> plot(y~as.POSIXct(times, format="%d.%m. %H:%M"), type="l", data=na.omit(data.frame(y,times)))
This is using y from the data specification in the plot command (not the
y in the base environment, or you'd be getting the same error), and
data= is specifying the data with NAs omitted.
>> whereas this plot command...
>>
>> plot(input[,2]~as.POSIXct(DateTime, format="%d.%m. %H:%M"), type="l", data=na.omit(data.frame(input[,2],DateTime)))
>>
>> ... produces the error:
>>
>> Error in model.frame.default(formula = input[, 2] ~ as.POSIXct(DateTime, :
>> variable lengths differ (found for 'as.POSIXct(DateTime, format = "%d.%m. %H:%M")')
This command is using input[,2] for its y varialble, which has *not* had the
NA values removed.
It's a matter of which data your plot() command is using, and it's not what
you seem to think it is.
Sarah
--
Sarah Goslee
http://www.functionaldiversity.org
More information about the R-help
mailing list