here is the link:
https://drive.google.com/file/d/12o1bEQcLyuN-gohAVX-zZAk8qt9OS83M/view?usp=sharing
here is the code:
library(readxl)
myData <- read_excel("Downloads/SP500Correct.xlsx")
Error: path does not exist: ‘Downloads/SP500Correct.xlsx’
myData <- read_excel("Downloads/SP500Correct.xlsx")
Error: path does not exist: ‘Downloads/SP500Correct.xlsx’
library(readxl)
myData <- read_excel("Downloads/SP500Correct.xlsx")
Error: path does not exist: ‘Downloads/SP500Correct.xlsx’
myData <- read_excel("Downloads/SP500Correct.xlsx")
view(myData)
nrow(myData)
[1] 253
head(myData)
A tibble: 6 x 2
observation_date SP500
1 44033 3257.
2 44034 3276.
3 44035 3236.
4 44036 3216.
5 44039 3239.
6 44040 3218.
str(myData)
tibble [253 × 2] (S3: tbl_df/tbl/data.frame)
observation_date: num [1:253] 44033 44034 44035 44036 44039 ...
SP500 : num [1:253] 3257 3276 3236 3216 3239 ...
myData$Date <- as.Date(myData$Date, format = "%m/%d/%Y")
Error: Assigned data as.Date(myData$Date, format = "%m/%d/%Y") must be compatible with existing data.
Existing data has 253 rows.
Assigned data has 0 rows.
Only vectors of size 1 are recycled.
Run rlang::last_error() to see where the error occurred.
In addition: Warning message:
Unknown or uninitialised column: Date.
myData$observation_date <- as.observation_date(myData$observation_date, format = "%m/%d/%Y")
Error in as.observation_date(myData$observation_date, format = "%m/%d/%Y") :
could not find function "as.observation_date"
myData$observation_date <- as.Date(myData$observation_date, format = "%m/%d/%Y")
Error in as.Date.numeric(myData$observation_date, format = "%m/%d/%Y") :
'origin' must be supplied
view(myData)
myData %>%
- mutate(Datex = map_chr(observation_date , as.character))
A tibble: 253 x 3
observation_date SP500 Datex
1 44033 3257. 44033
2 44034 3276. 44034
3 44035 3236. 44035
4 44036 3216. 44036
5 44039 3239. 44039
6 44040 3218. 44040
7 44041 3258. 44041
8 44042 3246. 44042
9 44043 3271. 44043
10 44046 3295. 44046
… with 243 more rows
view(myData)
head(myData)
A tibble: 6 x 2
observation_date SP500
1 44033 3257.
2 44034 3276.
3 44035 3236.
4 44036 3216.
5 44039 3239.
6 44040 3218.
library(lubridate)
Attaching package: ‘lubridate’
The following objects are masked from ‘package:base’:
date, intersect, setdiff, union
myData[ , 1 ] <- ymd(myData[, 1])
Warning message:
All formats failed to parse. No formats found.
library(lubridate)
myData[ , 1 ] <- ymd(myData[, 1])
Warning message:
All formats failed to parse. No formats found.
library(lubridate)
myData[ , 1 ] <- ymd(myData[, 1])
Warning message:
All formats failed to parse. No formats found.
library(dplyr)
myData <- myData %>%
Error: Problem with mutate() column Date.
Date = as.Date(Date, origin = "1899-12-30").
do not know how to convert 'Date' to class “Date”
Run rlang::last_error() to see where the error occurred.
library(dplyr)
myData <- myData %>%
- mutate(Date = as.Date(Date, origin="1899-12-30"))
Error: Problem with mutate() column Date.
Date = as.Date(Date, origin = "1899-12-30").
do not know how to convert 'Date' to class “Date”
Run rlang::last_error() to see where the error occurred.