Learn R Programming

openintro (version 2.4.0)

sp500_1950_2018: Daily observations for the S&P 500

Description

Data runs from 1950 to near the end of 2018.

Usage

sp500_1950_2018

Arguments

Format

A data frame with 17346 observations on the following 7 variables.

Date

Date of the form "YYYY-MM-DD".

Open

Opening price.

High

Highest price of the day.

Low

Lowest price of the day.

Close

Closing price of the day.

Adj.Close

Adjusted price at close after accounting for dividends paid out.

Volume

Trading volume.

Examples

Run this code

data(sp500_1950_2018)
sp500.ten.years <- subset(
  sp500_1950_2018,
  "2009-01-01" <= as.Date(Date) & as.Date(Date) <= "2018-12-31"
)
d <- diff(sp500.ten.years$Adj.Close)
mean(d > 0)

Run the code above in your browser using DataLab