Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在RStudio脚本中自动插入空白_R_Rstudio_Whitespace_Shortcut - Fatal编程技术网

在RStudio脚本中自动插入空白

在RStudio脚本中自动插入空白,r,rstudio,whitespace,shortcut,R,Rstudio,Whitespace,Shortcut,与使用Ctrl+I或Cmd+I正确缩进行的方式相同,是否有快捷方式自动在RStudio脚本中插入正确的空格 例如,为此: df<-data.frame(x=c(1,2,3,4,5),y=c(3,4,5,6,7)) df在RStudio下,您可以选择代码并键入ctrl+shift+A进行代码重新格式化,请参阅 结果: df <- data.frame(x = c(1, 2, 3, 4, 5), y = c(3, 4, 5, 6, 7)) df一种解决方案是使用styler包。不会动

与使用
Ctrl+I
Cmd+I
正确缩进行的方式相同,是否有快捷方式自动在RStudio脚本中插入正确的空格

例如,为此:

df<-data.frame(x=c(1,2,3,4,5),y=c(3,4,5,6,7))

df在RStudio下,您可以选择代码并键入
ctrl+shift+A
进行代码重新格式化,请参阅

结果:

df <- data.frame(x = c(1, 2, 3, 4, 5), y = c(3, 4, 5, 6, 7))

df一种解决方案是使用
styler
包。不会动态设置样式,但…安装styler,它会自动将一个加载项添加到Rstudio中的加载项列表中。然后从加载项中的下拉菜单中单击“设置活动文件样式”。您可以将此选项绑定到自定义键盘快捷键。谢谢@Waldi!对于Mac来说,这是
Cmd+Shift+A
。这个解决方案甚至在我最初查找的地方列出,但只是在搜索错误的链接时,我将它放在了答案中以供进一步参考
df <- data.frame(x = c(1, 2, 3, 4, 5), y = c(3, 4, 5, 6, 7))