Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8902535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:38:16+00:00 2026-06-15T01:38:16+00:00

I normally use matlab GUI for programming and it has very nice code folding

  • 0

I normally use matlab GUI for programming and it has very nice code folding features, such as the following:

    %% This is one chunk of code I can fold just because I am using the %% comment format.
    matrix = [1 2 3; 4 5 6];
    vector = [1 2];
    ax = vector*matrix;

    %% This is another chunk of code I can fold because I am using the %% comment format.
    matrix2 = [7 8 9; 10 11 12];
    vector2 = [7 8];
    ax2 = vector2*matrix2;

As mentioned in the matlab code, the %% comment will immediatly give the matlab GUI the folding option and a plus/minus sign for unfolding/folding will appear on that line with the comment visible.

Is it anyway to achieve such formatting in rstudio or a good R gui?

I’d like to have the plus/minus feature, and the fact that the first line comment is visible so I can know what’s in the folded chunk of code.

Thanks.

Photos of the GUI minus/plus unfolded/folded attached bellow:

minus folding
plus folding

When I try the same approach in RStudio, seems that the only option is edit -> folding collapse/expand but it hides the comments, and its not as automatable as the %% feature. In my case is more of a problem because I use X11 so I do not want to have to go to edit -> folding… all the time, but rather automate as in matlab using %%.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:38:17+00:00Added an answer on June 15, 2026 at 1:38 am

    Have you seen the code folding section of the RStudio documentation? Everything you ask for is described therein.

    To directly quote the most relevant section of the documentation, you can create a code section on any comment line by including at least four trailing dashes (-), equal signs (=), or pound signs (#) automatically creates a code section.

    If that wasn’t clear enough, maybe we can learn by example:

     # Section One ---------------------------------
    
     # Section Two =================================
    
     ### Section Three ############################# 
    

    To illustrate that this actually works further, please examine the following two screenshots. If you are getting something different, I suggest you update RStudio and then follow up directly with the good folks at RStudio:

    Expanded:
    enter image description here

    Collapsed:enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code that where I would normally use one line: if (tableView
I normally use the following code in SQL Server: IF EXISTS (SELECT * FROM
I normally use this step to set up records with factory_girl: Given /^the following
I normally use DataSet because It is very flexible. Recently I am assigned code
I normally use the following code to generate random colors: Random rand = new
I normally use UIViews to make my apps - but this one I am
I am encountering a very strange error with my project. I normally use the
I normally use ; to combine more than one command in a line, but
I normally use this function to sanitize my form inputs before storing them into
In MVC2 template, I normally use this.ViewData.TemplateInfo.GetFullHtmlFieldId(fieldName) to generate the id field of an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.