Really useful bits of code that are missing from R

Một vài code R hữu ích

4D Pie Charts

There are some pieces of code that are so simple and obvious that they really ought to be included in base R somewhere.

Geometric mean and standard deviation ? a staple for anyone who deals with lognormally distributed data.

A drop option for nlevels. Sure your factor has 99 levels, but how many of them actually crop up in your dataset?

A way of converting factors to numbers that is quicker than as.numeric(as.character(my_factor)) and easier to remember than the method suggested in the FAQ on R.

A “not in” operator. Not many people know the precedence rules well enough to know that !x %in% y means !(x %in% y) rather than (!x) %in% y, but x %!in% y should be clear to all.

I’m sure there are loads more snippets like this that would be useful to have; please contribute your own in the comments.

EDIT:
Thanks…

View original post 98 more words

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: