Search code examples
rdataframefor-loopsapply

How to loop through a vector of data frame names to print first columns of the df's?


so x is a vector. i am trying to print the first col of df's name's saved in the vector. so far I have tried the below but they don't seem to work.

x = (c('Ethereum,another Df..., another DF...,'))

for (i in x){
  print(i[,1])
}

sapply(toString(Ethereum), function(i) print(i[1]))

Solution

  • You can try this

    x <- c('Ethereum','anotherDf',...)
    
    for (i in x){
      print(get(i)[,1])
    }