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

Extract one class out of multiple classes

I know that a similar question exists but it doesn’t solve my problem. I have a dataset which has two classes:

class(wind)

"data.frame" "data.table"

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

How can I use wind as data.frame or data.table or how can I extract just one class?

I tried class(wind)[1] to get the class data.table but that didn’t work (I don’t get anything printed). Is there another way?

>Solution :

You can use

class(wind) <- class(wind)[1]

But i don’t recommend doing that because you will lose the class search mechanism in R, means some function which registered for the dropped class will not dispatched.

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