我(某种程度上)已经知道这个问题的答案。但我认为这是 R 用户列表中经常被问到的问题,应该有一个可靠的好答案。据我所知,R 中没有多行注释功能。那么,有人有什么好的解决方法吗?
虽然 R 中的相当多的工作通常涉及交互式会话(这让人怀疑是否需要多行注释),但有时我不得不向同事和同学发送脚本,其中大部分涉及重要的代码块。对于来自其他语言的人来说,这是一个相当自然的问题。
过去我使用过引号。由于字符串支持换行符,因此运行 R 脚本
"
Here's my multiline comment.
"
a <- 10
rocknroll.lm <- lm(blah blah blah)
...
工作正常。有人有更好的解决方案吗?
Most of the editors take some kind of shortcut to comment out blocks of code. The default editors use something like command or control and single quote to comment out selected lines of code. In RStudio it's Command or Control+/. Check in your editor.
It's still commenting line by line, but they also uncomment selected lines as well. For the Mac RGUI it's command-option ' (I'm imagining windows is control option). For Rstudio it's just Command or Control + Shift + C again.
随着编辑器的更新以及不同的软件成为最流行的 R 编辑器,这些快捷方式可能会随着时间的推移而改变。无论您拥有什么软件,您都必须查找它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)