[R] Zoo or TS
Robert W. Baer, Ph.D.
rbaer at atsu.edu
Sun Feb 22 19:23:03 CET 2009
You have not really made it clear what you are trying to do, and I don't see
the zoo vs ts involvement in your question.
Also, your test data and code snippet you give are not quite consistent.
Thus, my advice is really a long-shot guess.
Assume your data looks like:
Time Date Rank Topic Title Author
1 0 xxxx 1 A J PAUL
2 0 xxxx 2 B K PERRI
3 0 xxxx 3 C L WILL
4 0 xxxx 4 D M ANA
5 1 xxxx 1 A J PAUL
6 1 xxxx 2 B L WILL
7 1 xxxx 3 C M ANA
8 1 xxxx 4 D K PERRI
After copying it to the clipboard, you read it into R (on Windows) using the
You type df and confirm the data is as indicated
You want to plot just the Rank for Title J at times 0 and 1 and any other
time available in the time column. You donot use an "if" statement. Rather
you use conditional arguements:
If the time variable becomes a ts or zoo object, this syntax should still
Hope this is what you are going after.
----- Original Message -----
From: "miya" <ontiveros_paloma at yahoo.com>
To: <r-help at r-project.org>
Sent: Sunday, February 22, 2009 10:50 AM
Subject: Re: [R] Zoo or TS
> Thank you Tony. I tried that, but still got an error. This is what I got.
> + plot(df["B"])
> Error in `[.data.frame`(df, "Title") : undefined columns selected
> I Think there is something wrong with my file because when I call [,1] It
> gives me the whole data set, but when I call [,2] it gives me NULL. Any
> suggestions on what I need to do?
> Thank you.
> Tony Breyal wrote:
>> I think you need to put quotes around the column header name,
>> something like: NYT["Title"]
>>> my.df <- data.frame(header1=1:3, header2=1:3)
>> Error in `[.data.frame`(my.df, header2) : object "header2" not found
>> 1 1
>> 2 2
>> 3 3
>> Hope that helps a little,
>> Tony Breyal
>> On 22 Feb, 04:41, miya <ontiveros_pal... at yahoo.com> wrote:
>>> Hi everyone,
>>> I'm trying to plot some data across time. I have a list of articles,
>>> date/times, authors, etc. Someone suggested using zoo and someone
>>> using ts. I'm pretty new at this and have been trying a simple if()
>>> statement, but it doesn't seem to work. I keep getting an error that
>>> does not exist. Basically its saying that the headers do not exist as
>>> objects. Can anyone please help.
>>> Below is what I've been trying to do and a sample of the data I am
>>> Thanks in advance.
>>> Time Date Rank Topic Title Author
>>> 0 xxxx 1 A J By PAUL
>>> 0 xxxx 2 B K By PERRI
>>> 0 xxxx 3 C L By WILL
>>> 0 xxxx 4 D M By ANA
>>> 1 xxxx 1 A J By PAUL
>>> 1 xxxx 2 B L By WILL
>>> 1 xxxx 3 C M By ANA
>>> 1 xxxx 4 D K By PERRI
>>> if(NYT[Title]=="For Catholics, a Door to Absolution Is Reopened")
>>> Error in `[.data.frame`(NYT, Title) : object "Title" not found
>>> View this message in
>>> Sent from the R help mailing list archive at Nabble.com.
>>> R-h... at r-project.org mailing
>>> PLEASE do read the posting
>>> and provide commented, minimal, self-contained, reproducible code.
>> R-help at r-project.org mailing list
>> PLEASE do read the posting guide
>> and provide commented, minimal, self-contained, reproducible code.
> View this message in context:
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help