问题描述
我正在使用 RStudio
,通常使用 + 逐行运行我的代码.通常,这可以正常工作,但可以正常运行 dplyr
,我想运行我使用管道运算符%>%
,
I'm using RStudio
and normally run my code line by line, using + . In general this works fine but working dplyr
I would like to run a whole code-section I wrote using the pipe-operator %>%
,
例如我想立即执行以下代码段,最好独立于管道代码行中的当前光标位置:
For e.g. I'd like to execute the following code-section at once, at the best independently from the current cursor position within the piped codelines:
mtcars %>%
filter(carb >= 2) %>%
group_by(cyl) %>%
summarise(mean.hp = mean(hp))
我可以逐行运行或标记所有行,然后按 + ,但这两种方式都令人讨厌.搜索互联网和"工具/修改键盘快捷键
"中可用的RStudio选项,我只发现了其他选项,例如运行整个部分,即
I could run this line by line or mark all lines and then press + but both ways are some kind of annoying. Searching the internet and the RStudio-options available in "Tools/Modify Keyboard Shortcuts
" I only found other options like running a whole section, that is starting at
# Example section--------------------
推荐答案
将光标置于代码块中的任意位置,并使用 + + (按住和,然后按按钮).第一次将放置光标的单词加亮显示,然后在重复时将整个代码块加亮显示.如果您有一个嵌套循环或其他嵌套结构,则会突出显示整个最里面的循环,然后是第二个最里面的循环,等等.
Place cursor anywhere in the code chunk and use + + (hold down and , then push button). The first time the word in which the cursor is placed gets highlighted, then, when repeted, the whole chunk of code gets highlighted. If you have a nested loop or another nested structure this will highlight the whole innermost loop, then the second inner most loop etc.
突出显示代码后,可以按 + 执行代码.
When you have the code highlighted you can press + to execute the code.
这篇关于在RStudio中执行几行的快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!