Embarrassed by your #R code?

Here are 4 mistakes beginner R coders make AND how to avoid them.

#rstats #datascience
The reality is you aren't going to become a master R programmer over night.

But I see beginners making the same mistakes time and time again.

And they are easy to correct.

Here are the 4 most common mistakes and how to easily correct them.
1. Not using comments

This is a huge no-no.

Why?

Because comments help others understand your code INCLUDING future you.
2. Not using THE PIPE

The pipe %>% is a super-handy feature of the #tidyverse that lets you chain multiple data processing steps together.
Why use the pipe?

A side-effect is that your code becomes more READIBLE.

Just like comments, it makes it easier on others AND future you.
3. Not using dplyr (aka using base R only)

Even I will admit that Base R is a mess.

So why are you using it?
Instead, use #dplyr which has readable verbs like group_by() and summarize().

dplyr verbs make it MUCH easier to understand what your code is doing.

Again, this helps others AND future you.
4. Not using spacing.

R can handle white space... So use it.

Here's my simple spacing hack...
Space out operations onto multiple lines.

Align = signs

This dramatically improves the readability of your code.

So when you do complex summarize(), you can quickly spot errors and read what you've done.
BONUS...

If you want to become a BETTER R programmer quickly, then I have an EXPRESS PATH CHEAT SHEET FOR LEARNING R.

What does this cheat sheet do??
It consolidates the 20,000 R packages into the 100 best so when you want to work in:

- #Marketing
- #TimeSeries Analysis
- #Finance
- #Geospatial
- #MachineLearning

... Then you just learn these R packages on my cheat sheet!
STEAL MY EXPRESS PATH TO LEARNING #R CHEAT SHEET: business-science.io/r-cheatsheet.h…
And if you want more #free R-tips and coding advice, here's my latest R-Tip on exploratory data analysis (EDA).

business-science.io/code-tools/202…

• • •

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

Keep Current with Matt Dancho (Business Science)

Matt Dancho (Business Science) 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 @mdancho84

Sep 27
Why does every beginner data scientist fall for the "deep learning trap"?

True story 🧵

#rstats #datascience #deeplearning Image
When I was first learning data science this cost me at least 6-months. Seriously...

I was building a model for predicting which quotes would become orders.
I had just finished using a linear regression (didn't know about logistic yet) to make a predictive model.

Yeah I know - I was a noobie using regression instead of classification. So what?!
Read 15 tweets
Sep 27
When I first learned R, I struggled making data visualizations with ggplot2.

Here are the 3 things that helped me.

#rstats #R #datascience #datavisualization Image
Data visualizations are absolutely the most important thing to learn because of story telling...

... the ability to help your business take action.

AND the most powerful R library for static data visualization is ggplot2.
But ggplot2 has a STEEP learning curve.

3 things that helped me...
Read 14 tweets
Sep 26
I hate to say it but...

#Shiny is giving tableau a run for it's money.

Here's why...

#rstats
Tableau is a great tool. For descriptive analysis...

...but it's terrible at predictive analysis.

Enter Shiny.
Shiny's big con is that it takes forever to build an app.

You still need to know HTML & CSS to make it look good.

UNTIL NOW.
Read 10 tweets
Sep 17
Shiny is a powerful tool that data scientists can use for web apps & production.

But most data scientists struggle.

Here are 7 resources on shiny that helped me.

#rstats #shiny #excel #python
1. The Shiny website

The 1st place to go to learn shiny.

shiny.rstudio.com
2. Flexdashboard website

Flexdashboard combines Rmarkdown & Shiny to make quick apps.

pkgs.rstudio.com/flexdashboard/
Read 10 tweets
Sep 14
TODAY. I'm excited to share 2 years of research + 6 software packages that went into Time Series Analysis...

And it's not what you think... 🧵

#rstats #datascience #timeseries #python #excel Image
I won't be talking about ARIMA.

Or, focusing on stationarity.
And, I most certainly will NOT be talking about:

1. Prophet

2. Exponential smoothing

3. Holt winters

4. Time series decomposition

5. OR any other "common techniques"
Read 5 tweets
Sep 14
When it comes to Time Series, colleges and universities have it all wrong.

A time series thread 🧵

#rstats #excel #python #timeseries
Universities are stuck in the past, teaching ARIMA.

But the cold reality is that ARIMA is NOT winning time series competitions & ARIMA is NOT helping companies solve BIG forecasting problems.
To be frank, ARIMA is too slow.

When you use ARIMA, you fall into a trap. You think, hey, this is what they're teaching me...

It must be good, right?
Read 12 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

Don't want to be a Premium member but still want to support us?

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

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(