Bubbles
Bubbles

Reputation: 569

subsetting data by date in R

._883<-quantmod::getSymbols("0883.HK",from="2022-04-21",to="2022-12-28",auto.assign = FALSE)

the data set covers from 2022-04-21 to 12-28, now I am trying to subset or divide the data in 2 ways, one is to cut off the data by actual date and the other one is by a ratio, say 80/20, may I know how should I subset the data in R? Thanks a lot.

Upvotes: 1

Views: 43

Answers (1)

TarJae
TarJae

Reputation: 78917

Another solution could be:

library(rsample)
split <- initial_split(._883, prop = .8)

training(split) 
testing(split) 

Upvotes: 2

Related Questions