[R] Problems plotting a sparse time series in R
Alexander Engelhardt
alex at chaotic-neutral.de
Mon Oct 29 17:15:04 CET 2012
Thanks to you two! :)
The zoo-manual explains the functions na.locf and na.approx, which deal
with this problem. I have to admit I didn't read the whole thing before
posting. But na.approx does exactly that - linear interpolation for all
NA-points. Plots work fine after adding this line:
ts <- na.approx(ts)
Thanks again!
-- Alex
> On Oct 29, 2012, at 8:14 AM, Alexander Engelhardt wrote:
>
>> Hi guys,
>>
>> I am logging data about my body (weight, body fat, blood pressure, ..)
>> in a .csv file and would like to plot this as a time series. I
>> uploaded the (noisified) .csv, you can see the link in the code I have
>> so far (you can run the code directly as-is):
>>
>> df.raw <-
>> read.csv("http://www.chaotic-neutral.de/temp/stats-noised.csv",
>> sep=";", dec=".")
>> date <- as.Date(df.raw[,1])
>> comments <- df.raw[,2]
>> stats <- df.raw[,-c(1,2)]
>>
>> ################################################################
>> #### timeSeries
>> library(timeSeries)
>> ts <- timeSeries(charvec=date, data=stats)
>> plot(ts)
>>
>> ################################################################
>> #### zoo
>> library(zoo)
>> ts <- zoo(stats, date)
>> plot(ts)
More information about the R-help
mailing list