Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Extracting dataframes inside a list in R

I have two dataframes that I had put into a list. How do I extract these dataframees into two seperate ones? The list name is new_dfs and the dataframes inside are new_3 and new_7. I want these two dataframes to be seperate. When I converted my list into a dataframe using new_dfs<-as.data.frame. It just made them into one dataframe. An example code will be appreciated.

> str(new_dfs)
List of 2
 $ new_3:'data.frame':  683 obs. of  3 variables:
  ..$ class          : Factor w/ 2 levels "benign","malignant": 1 1 1 1 1 2 1 1 1 1 ...
  ..$ bare nuclei    : int [1:683] 1 10 2 4 1 10 10 1 1 1 ...
  ..$ clump thickness: int [1:683] 5 5 3 6 4 8 1 2 2 4 ...
 $ new_7:'data.frame':  683 obs. of  7 variables:
  ..$ class                : Factor w/ 2 levels "benign","malignant": 1 1 1 1 1 2 1 1 1 1 ...
  ..$ bare nuclei          : int [1:683] 1 10 2 4 1 10 10 1 1 1 ...
  ..$ clump thickness      : int [1:683] 5 5 3 6 4 8 1 2 2 4 ...
  ..$ uniformity cell size : int [1:683] 1 4 1 8 1 10 1 1 1 2 ...
  ..$ uniformity cell shape: int [1:683] 1 4 1 8 1 10 1 2 1 1 ...
  ..$ marginal adhesion    : int [1:683] 1 5 1 1 3 8 1 1 1 1 ...
  ..$ bland chromatin      : int [1:683] 3 3 3 3 3 9 3 3 1 2 ...

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Use list2env:

list2env(new_dfs, .GlobalEnv)
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading