在RStudio中执行几行的快捷方式 [英] Shortcut for executing several lines in RStudio

查看:91
本文介绍了在RStudio中执行几行的快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 RStudio ,通常使用 Crtl + Enter 逐行运行我的代码.通常,这可以正常工作,但可以正常运行 dplyr ,我想运行我使用管道运算符%>%

I'm using RStudio and normally run my code line by line, using Crtl + Enter. 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))

我可以逐行运行或标记所有行,然后按 Crtl + Enter ,但这两种方式都令人讨厌.搜索互联网和"工具/修改键盘快捷键"中可用的RStudio选项,我只发现了其他选项,例如运行整个部分,即

I could run this line by line or mark all lines and then press Crtl + Enter 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--------------------

推荐答案

将光标置于代码块中的任意位置,并使用 Crtl + Shift + (按住 Crtl Shift ,然后按按钮).第一次将放置光标的单词加亮显示,然后在重复时将整个代码块加亮显示.如果您有一个嵌套循环或其他嵌套结构,则会突出显示整个最里面的循环,然后是第二个最里面的循环,等等.

Place cursor anywhere in the code chunk and use Crtl + Shift + (hold down Crtl and Shift, 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.

突出显示代码后,可以按 Crtl + Enter 执行代码.

When you have the code highlighted you can press Crtl + Enter to execute the code.

这篇关于在RStudio中执行几行的快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆