Factor in R


Factor is a special vector in R. It can be ordered or unordered and are important when for modeling functions such as lm() and glm() and also in plot methods. Factors have to be pre-defined values.




# Empty
Command::  factor()

#Example

spectrum <- c('Red','green','yellow','Voilet','Cyan','Magenta','Orange')
factor_spectrum<-factor(spectrum)

print(factor_spectrum)

[1] Red     green   yellow  Voilet  Cyan    Magenta Orange
Levels: Cyan green Magenta Orange Red Voilet yellow

print(nlevels(factor_spectrum))
[1] 7

Factor in R Reviewed by Rupesh on 00:17 Rating: 5

No comments:

All Rights Reserved by Technology from Developers Eye © 2014 - 2015
Powered By Blogger, Designed by Aadics
Disclaimers:: The information provided within this blogsite is for general informational purposes only. While we try to keep the information up-to-date and correct, there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this blogsite for any purpose.The author does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause.

Contact Form

Name

Email *

Message *

Powered by Blogger.