粘贴字符限制 [英] paste character limit
问题描述
可能的重复:
为什么以及在哪里引入
换行符到 c()?
我正在 GNOME 终端(版本 3.4.1.1)的 bash
shell(版本 4.2.36(1))中运行 R
(版本 2.15.1).有时我将代码写在文本文件中,然后将其直接粘贴到控制台中(运行 R
时).在我粘贴的脚本长度变长之前,我没有遇到任何问题.现在,似乎任何大于 4206 个字符(包括
)的代码都会被拒绝(即,前 4206 个字符被接受,其余代码被截断;截断伴随着终端bell""声音).这个字符限制不是特定于 bash
或 GNOME 终端的,因为我在粘贴到例如 vi
时没有观察到字符限制.因此,我怀疑字符限制是由 R
强加的,但不知道如何更改它,假设它是用户可配置的参数.粘贴限制可以更改吗?如果可以,控制它的参数是什么?
您似乎遇到了控制台的已知限制.正如 第 1.8 节 - R 命令,区分大小写等R简介:
<块引用>在控制台输入的命令行被限制[3]到大约 4095 个字节(不是字符).
[3] 有些控制台不允许你输入更多,有些控制台会默默地丢弃多余的部分,有些会将其用作下一行的开始.
要么将命令放在一个文件中并source
,或者通过在适当的点(逗号之间)插入您自己的换行符将代码分成多行.
src/include/Defn.h
中的值是硬编码的:#define CONSOLE_BUFFER_SIZE 4096
,因此您需要重新编译 R 来更改它.>
Possible Duplicate:
Why and where are newline characters getting introduced to c()?
I am running R
(version 2.15.1) in a bash
shell (version 4.2.36(1)) in the GNOME terminal (version 3.4.1.1). Sometimes I write my code in a text file and then paste it directly into the console (when running R
). I didn't have any problems until the scripts I was pasting grew in length. Now, it appears that any code greater than 4206 characters (including
) is rejected (i.e., the first 4206 characters are accepted and the remaining code is truncated; the truncation is accompanied by the terminal "bell" sound). This character limit is not specific to bash
or GNOME terminal because I do not observe a character limit when pasting into e.g., vi
. Therefore, I suspect that the character limit is imposed by R
, but do not know how to change it, assuming it is a user-configurable parameter. Can the paste limit be changed and if so, what parameter governs it?
It looks like you're running into a known limitation of the console. As it says in Section 1.8 - R commands, case sensitivity, etc. of An Introduction to R:
Command lines entered at the console are limited[3] to about 4095 bytes (not characters).
[3] some of the consoles will not allow you to enter more, and amongst those which do some will silently discard the excess and some will use it as the start of the next line.
Either put the command in a file and source
it, or break the code into multiple lines by inserting your own newlines at appropriate points (between commas).
The value is hard-coded in src/include/Defn.h
: #define CONSOLE_BUFFER_SIZE 4096
, so you would need to recompile R to change it.
这篇关于粘贴字符限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!