Skip to content
Back to formatted view

Raw Message

Message-ID: <PU4P216MB15680637B861C03D24236F5BC8BC9@PU4P216MB1568.KORP216.PROD.OUTLOOK.COM>
Date: 2022-07-02T18:03:43Z
From: akshay kulkarni
Subject: is.na with lists....

Dear memebers,
                            I have list of stock data OHLCData for 500 stocks, 15 of whom are NA's. The following is the code:

require(quantmod)
getOHLCData <- function(NSESym) {
  OHLCData1 <- list()
  for(i in 1:500){
    OHLCData1[[i]] <- tryCatch(getSymbols(NSESym[i], auto.assign=FALSE),
                          error = function (e) {print(i); return(NA)})

  }
  return(OHLCData1)
}

 OHLCData <- getOHLCData(NSESym)

however, when I check for is.na, I get the following:

length(OHLCData)
[1] 500
> length(is.na(OHLCData))
[1] 500

length(is.na(OHLCData)) should return 15. Whats going wrong? I assume is.na returns TRUE if there is an NA.

Yours sincerely,
AKSHAY M KULKARNI

	[[alternative HTML version deleted]]