Home > Mobile >  Access Variable in a Data Frame List
Access Variable in a Data Frame List

Time:09-25

Quick question:

How can I access a variable directly out of a dataframes list?

I tried

df_list[i]$variable which is not working.
or df_list[(i)]$variable...
or df_list[i[1]]

is there a way?

CodePudding user response:

You may use [[ to access the dataframe inside the list. I am assuming you are running in a for loop. To access the variable you may use df_list[[i]]$variable.

You may also read The difference between bracket [ ] and double bracket [[ ]] for accessing the elements of a list or dataframe

  •  Tags:  
  • r
  • Related