By default when you create a factor in R, the `NA`'s are not included as a level. Which of the following would include `NA` as a level? [see_image_1] #RStats #DataScience [TimeStamp:12032021033052] Image 1
Options:
1. `x = factor(c(1,1,2,NA))`
2. `x = factor(c(1,1,2,NA), levels = c(1,2,NA))`
3. `x = factor(c(1,1,2,"NA"))`
4. `x = factor(c(1,1,2,NA), exclude=NULL)`
Correct Option: `x = factor(c(1,1,2,NA), exclude=NULL)`. `factor()` takes an additional argument `exclude`, which can be used to exclude levels. `exclude` can be a vector, which excludes the characters (or numbers) from a given #RStats #DataScience [TimeStamp:12032021163031]
factor `f`. Excluding non-existing character levels is equivalent to excluding nothing. By default `exclude=NA`, hence `NA` is not shown as a level. By setting `exclude=NULL`, you are explicitly mentioning to exclude nothing #RStats #DataScience [TimeStamp:12032021163031]
including `NA`'s. [see_image_1] #RStats #DataScience [TimeStamp:12032021163031] Image 1

• • •

Missing some Tweet in this thread? You can try to force a refresh
 

Keep Current with #RStats Question A Day

#RStats Question A Day Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @data_question

11 Mar
What would be the output of the following? [see_image_1] #RStats #DataScience [TimeStamp:11032021033056] Image 1
Options:
1. `1 2 3`
2. `2 3 4`
3. `1.3 2.3 3.3`
4. `NA`
Correct Option: `1.3 2.3 3.3`. The binary operator `:` in R has two meanings. For factors `a:b` is equivalent to `interaction(a,b)` except the levels' labelling and ordering is different. For numeric arguments `from:to`, the result #RStats #DataScience [TimeStamp:11032021163031]
Read 4 tweets
30 Jan
#rstats users who are planning to learn #python, welcome to another edition of tweetorial.

The idea is to leverage your experience with R to explain python concepts w/o going into too much detail. For details, refer the links attached at the bottom.
For today, I am covering the data types in python (except complex, binary types). R has data types: integer, double, character and boolean. Well python too has the same data types, although some names are different. In R `integer` cannot be a fractional and is written by
suffixing L, in python it's `int`. In R fractionals are called `double` (like 1.2), In python they are called `float`. In both R python it is not necessary to specify the type. While in R the type of a number is `double` unless specified by `L`, python infers it automatically. Image
Read 13 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!

Follow Us on Twitter!