Skip to content
R for the Rest of Us Logo

This lesson is locked

Get access to all lessons in this course.

If the video is not playing correctly, you can watch it in a new window

Transcript

Click on the transcript to go to that point in the video. Please note that transcripts are auto generated and may contain minor inaccuracies.

Your Turn

  • Open the unformatted-r-code.R file and fix the formatting

    • Add hard returns to keep lines short

    • Add spaces after punctuation and around operators

    • Indent functions or processes that go together

  • Choose an option:

    • Fix the formatting by hand

    • Fix the formatting by hand then then run styler to find anything missed

    • Fix it using the styler package entirely

Learn More

Two great resources on writing readable code are:

Have any questions? Put them below and we will help you out!

You need to be signed-in to comment on this post. Login.

PAUL JEBARAJ

PAUL JEBARAJ

January 20, 2024

Hi, I have tried to fix the unformatted file entirely by using the styler approach and see nil changes..?? Opened the file,

ran:

library(tidyverse)
library(haven)
library(table1)
library(finalfit)
library(knitr)
library(xfun)

then used the drop down in the add-in and selected "style active file".

I see nil changes were made ( that is it did not format anything).

In the console, I see: styler:::style_active_file() Using style transformers styler::tidyverse_style()

Any help would be much appreciated. Thankn you kindly. Paul

David Keyes

David Keyes Founder

January 21, 2024

Hmm, it's hard to say without seeing your screen. Do you mind uploading a video here? Please send me an email when it's up and I'll review it and get back to you here.