0

I have some publicly listed companies' financial statements in lists with similar structures, already loaded in Global Environment. I want to select a particular element from each list and rbind them in a separate column.

For this I have first stored the name of the lists in a matrix and then I am dynamically selecting each entity using $ operator while varying the name of the list using for loop.

Example data set:

library(quantmod)
cname <- as.matrix(data.frame(com = c('MCK','CERN','IMS','MDRX','HURN')))
for( i in 1:nrow(cname)){
  sm <- cname[i,1]
  getFinancials(Symbol=sm, src="google")
}

I want to get total revenue data from each company financial statements. For this I am doing the following:

# total revenue 
tr0 <- NULL
for(i in 1:nrow(cname)){
  sm <- cname[i,1]
  com.rev <- paste(sm,'.f$IS$A',sep = '')
  tr <- com.rev["Total Revenue",]
  tr0 <- rbind(tr0,tr)
}

While doing so, I am getting following error:

Error

Error in com.rev["Total Revenue", ] : incorrect number of dimensions

Mithilesh Kumar
  • 234
  • 1
  • 2
  • 17

0 Answers0