清除R和RStudio中的控制台的功能

本文介绍了如何在R和RStudio中清除控制台,提供了一个可在控制台中输入的函数,作为替代键盘快捷键的方法。讨论了不同操作系统中清除控制台的组合键,如Option + Command + L(Mac)、CTRL + L(Ubuntu-Gnome、Windows)。
摘要由CSDN通过智能技术生成

本文翻译自:Function to clear the console in R and RStudio

I am wondering if there is a function to clear the console in R and, in particular, RStudio I am looking for a function that I can type into the console, and not a keyboard shortcut. 我想知道R中是否有清除控制台的功能,尤其是RStudio,我在寻找可以在控制台中键入的功能,而不是键盘快捷键。

Someone has already provided such a function in this StackExchange post from 2010 . 从2010年开始,有人已经在此StackExchange帖子中提供了这样的功能。 Unfortunately, this depends on the RCom package and will not run on Mac OS X. 不幸的是,这取决于RCom软件包,无法在Mac OS X上运行。


#1楼

参考:https://stackoom.com/question/xplU/清除R和RStudio中的控制台的功能


#2楼

You may define the following function 您可以定义以下功能

clc <- function() cat(rep("\n", 50))

which you can then call as clc() . 然后可以将其称为clc()


#3楼

cat("\014")  

is the code to send CTRL + L to the console, and therefore will clear the screen. 是将CTRL + L发送到控制台的代码,因此将清除屏幕。

Far better than just sending a whole lot of returns. 比仅发送大量回报要好得多。


#4楼

如果使用默认的R控制台,则组合键Option + Command + L将清除控制台。


#5楼

In Ubuntu-Gnome , simply pressing CTRL + L should clear the screen. Ubuntu-Gnome中 ,只需按CTRL + L即可清除屏幕。

This also seems to also work well in Windows 10 and 7 and Mac OS X Sierra. 在Windows 10和7和Mac OS X Sierra中,这似乎也可以很好地工作。


#6楼

cat("\\f") may be easier to remember than cat("\\014") . cat("\\f")可能比cat("\\014")容易记住。

It works fine for me on Windows 10. 在Windows 10上对我来说效果很好。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值