Tena koe Robert

Many times in R one can do things without a loop.  In this case, see ?rle.  You 
might also need to check substring or months depending on how you dates are 
stored.

HTH ....

Peter Alspach

-----Original Message-----
From: R-help [mailto:r-help-boun...@r-project.org] On Behalf Of Robert Sherry
Sent: Wednesday, 4 November 2015 1:27 p.m.
To: r-help@r-project.org
Subject: [R] Working with Data Frames

I have created what I believe to be a data frame. It is called env1$SPY.  The r 
statement head( env1$SPY ) produces the following output:

            SPY.Open SPY.High SPY.Low SPY.Close SPY.Volume SPY.Adjusted
1995-01-03  45.7031  45.8437 45.6875   45.7812     324300 31.55312
1995-01-04  45.9843  46.0000 45.7500   46.0000     351800 31.70392
1995-01-05  46.0312  46.1093 45.9531   46.0000      89800 31.70392
1995-01-06  46.0937  46.2500 45.9062   46.0468     448400 31.73617
1995-01-09  46.0312  46.0937 46.0000   46.0937      36800 31.76850
1995-01-10  46.2031  46.3906 46.1406   46.1406     229800 31.80082

The above data from was created by the following commands:
     library( quantmod )
     env1 <- new.env()
     getSymbols("SPY", src = 'yahoo', from = '1995-01-01', env = env1, 
auto.assign = T)

Now, what I want to do is to loo through the data look for when the month 
changes. What is the proper way of writing a for loop in R and access the date 
field?

Bob

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 
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.
The contents of this e-mail are confidential and may be ...{{dropped:14}}

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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