Hello,

   This is a standard example in which I read the time series data from a
csv file and create a zoo object:

x0 <- read.csv(file="CPI.csv", header=TRUE)
time_0<-as.yearmon("1981-01")+(0:371)/12
x0zoo<-zoo(x0, time_0)

    The data look like this:

    TIME CPI CPI_food CPI_Clothes CPI_House CPI_Rent  198101 62.1 55.34
103.45 65.24 61.43  198102 63.16 56.95 103.21 65.77 61.49  198103 63.44
56.98 103.25 66.44 61.98  198104 63.69 57.41 103.55 66.58 62.15  198105
63.45 56.77 103.44 66.72 62.32  198106 64.05 58.06 103.35 66.81 62.4  198107
64.29 58.53 102.85 66.88 62.5
    However, time series data usually need to be transformed (e.g., ln
(natural log) , difference or log difference, etc), I would like to attach
a line under the title, and the data look like this:
 TIME CPI CPI_food CPI_Clothes CPI_House CPI_Rent  lv ln dln dln dln ln
198101 62.1 55.34 103.45 65.24 61.43  198102 63.16 56.95 103.21 65.77 61.49
198103 63.44 56.98 103.25 66.44 61.98  198104 63.69 57.41 103.55 66.58 62.15
198105 63.45 56.77 103.44 66.72 62.32  198106 64.05 58.06 103.35 66.81 62.4
198107 64.29 58.53 102.85 66.88 62.5
    How can I modify the original program so that the second line
(transformation) is read as characters? If I can do that,  I can continue
working on the data after original data and transformation are read.

    In the beginning I saved the transformation line in a separate file,
but it is troublesome to contrast the two files when I need to modify the
file. Is there any better way to work on it?

    Thanks,

Miao

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to