![]() ![]() class() Retrieves the internal class of an object.names() Names of elements within an object.Perhaps the most uesful diagnostic function in R. str() Compactly display the internal structure of an R object.How can we do that sort of comparison? Diagnostic functions in R Missing values are very important in R, but can be very frustrating for new users. Factors have this information built in.įactors can be created with factor(). Which is male? 1 or 2? You wouldn't be able to tell with just integer data. Helpful when there is no additional metadata. male and female is more descriptive than 1s and 2s. ![]() They are better than using simple integer labels because factors are what are called self describing. Underlying it's represented by numbers 1,2,3. Other times you might want factors to be ordered (or ranked). Some string methods will coerce factors to strings, while others will throw an error. While factors look (and often behave) like character vectors, they are actually integers under the hood, and you need to be careful when treating them like strings. Factors can be ordered or unordered and are important when for modelling functions such as aov(), lm() and glm() and also in plot methods.įactors can only contain pre-defined values.įactors are pretty much integers that have labels on them. Single brackets will still return another list.įactors are special vectors that represent categorical data. Prints a new line for each element.Įlements are indexed by double brackets. You can "staple" together lots of different kinds of results into a single object that a function can return. Lists are extremely useful inside functions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |