list - Finding the names of all the columns in all the dataframes in a workspace -


Assume that I have several data frames in a workspace in R and I want a list of column names in all data frames. .

I thought the following would work. But this is not to see it in your own workspace.

  sapply (ls (), name)   

Why does not this work? LS () creates a list of all data frames and then the name function should be applied on each data frame. This is a simple question for me now.

Coming forward: I want to determine all those columns whose names are with them, so that I can apply the following for each of them. Columns do not matter what they do The data are in the frame.

  as.Date (dataframe $ dateofenrollment, origin = "1899-12-30")    

This does not work because ls () returns the object names in our workspace, not the objects themselves

You probably want something like the following:

  lapply (ls (), function (x) if (is.data.frame (o   

There will be NULL elements for any object that is not data frames but you can possibly work around it / P>

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -