r - plot cpt.var: Use values from dataframe for axis -
when try plot result changepoint analysis using cpt.var
changepoint package, resulting values on x-axis integers starting 0 instead of values dataframe (which integers combining year , week). when plot data data frame x-axis correct, when plotting result of cpt.var
x-values gone
i have searched online answers cannot find solution. hope can me out.
the syntax more complex example below comes down same issue: plotting the dataframe using plot(df, type="l")
returns correct values on x-axis, plotting result of changepoint analysis using plot(vvalue)
not.
library(changepoint) df <- read.table(header=true,text = "year_week n 200801 12 200802 5 200803 0 200804 6 200805 0 200806 0 200807 4 200808 5 200809 3 200810 25 200811 36 200812 5 200813 2 ") vvalue <- cpt.var(df$n, method = "pelt", penalty = "bic") plot(vvalue)
plot(vvalue, xaxt = "n") axis(1, at=1:13, labels=df[,1])
Comments
Post a Comment