library(xts)
## Warning: package 'xts' was built under R version 4.1.3
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 4.1.3
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
library(quantmod)
## Warning: package 'quantmod' was built under R version 4.1.3
## Loading required package: TTR
## Warning: package 'TTR' was built under R version 4.1.3
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
prices <- getSymbols("GOOG", auto.assign = FALSE)
move <- Cl(last(prices)) - Op(last(prices))

ifelse(move > 0, "BUY", "SELL")
##            GOOG.Close
## 2022-05-20 "SELL"
chartSeries(prices, theme = chartTheme("white", bg.col = "white"))

as.data.frame(prices)[1:5 , 1:4]
##            GOOG.Open GOOG.High GOOG.Low GOOG.Close
## 2007-01-03  232.1299  237.4400 229.6940   232.9220
## 2007-01-04  233.6243  241.0714 233.3005   240.7277
## 2007-01-05  240.3491  242.8398 238.1623   242.6853
## 2007-01-08  242.9344  244.0204 240.1997   240.8871
## 2007-01-09  241.8186  243.2134 239.7015   241.8435
foo <- function(x) {
  x + 1
}