I didn't even know the function myself!! Just noticed that my script is in chapters when you wrote to me. BUT I found out how to do it on purpose - you are right this makes organizing so much easier!
To declare a new chapter you have to start your line with a "#" , then write whatever you want and finish the line with four or more "#", "-" or "=".
Here is a link to more organizing and folding options in R studio:
Thank for discovering this little note button!