This question already has answers here:
Equivalent to unix "less" command within R console
(5 answers)
Closed 8 years ago.
Is there any command in R console which behaves same as "more" command in Linux?
Consider this
>x=list(seq(100000), seq(100000))
>x
It displays everything at one go and shows message at the end "reached getOption("max.print")". Scrolling back to top doesn't show me the first values. I need a command like more(x) which will show more and more by pressing space bar.
Would ?page do the trick? e.g., page(list(a = rnorm(1000), b=rnorm(1000)))
Related
This question already has answers here:
Escaping backslash (\) in string or paths in R
(4 answers)
Closed 1 year ago.
In how to change working directory more easily?
Currently, if we use 'setwd',we have to add many '\', sometimes it's boring
Is there any easier way for this ? (Just like Python can add 'r' )
setwd('C:\Users\Administrator\Desktop\myfolder') # can't work
setwd('C:\\Users\\Administrator\\Desktop\\myfolder') # can work,but havt to add many '\'
You could use r (for raw string) and add parenthesis:
> r"(C:\Users\Administrator\Desktop\myfolder)"
[1] "C:\\Users\\Administrator\\Desktop\\myfolder"
>
And now:
setwd(r"(C:\Users\Administrator\Desktop\myfolder)")
Or reading from clipboard automatically adds the extra slashes:
setwd(readClipboard())
This question already has answers here:
Replacing white space with one single backslash
(2 answers)
Closed 6 years ago.
I have this text and I want to replace // with \
This is the text sdfd//dfsadfs
and I want it to be sdfd\dfsadfs
Can gsub work? This does not work: gsub("//","[\]","sdfd//dfsadfs")
I had a similar problem before. Like #Psidom commented, you should use gsub("//","\\\\","sdfd//dfsadfs"). This will replace //(2 characters) with \\ which is actually a single character in R (Check by running nchar("\\")). Even though it is prints as \\, it behaves as \. You can check this by running cat("\\"). If you exported the data after running gsub to a table (or csv), I believe there will be only one \
This question already has answers here:
ending "+" prompt in R
(5 answers)
Closed 6 years ago.
After entering a complex code(where something was incorrect), instead of > sign R displays +. If I knew what is missing (oftentimes due to missing out (,),') it would be easy to fix, but I am not sure. Therefore I am "locked" with this + state and cannot escape it. Is there a way to kill it and revert back to the default prompt?
It depends on where R is running. Try CTRL+C on the keyboard, if you are running plain R. Some IDE (like RStudio) have a Stop button you can press to abort the command given.
Often Esc, the escape key works.
This question already has answers here:
Vim: underscore(_) automatically converted to (<-)
(4 answers)
Closed 8 years ago.
By default, the Vim-R-plugin inserts <- whenever I type or paste an underscore _. This creates problems when I paste stuff like geom_bar, which becomes geom <- bar. Is there a way to turn this short-cut off?
I tried looking at the manual (scroll down to Edit section) but couldn't figure out how to do it.
I'm using Vim-R-plugin Version 0.9.9.9
for Vim version 7.4.
From the help page of the plugin:
6.3. Assignment operator and Rnoweb completion of code block
...
To completely disable this feature, put in your vimrc:
let vimrplugin_assign = 0
--
EDIT: As of writing this (2019-10-25), add this to your vimrc instead:
6.4. Assignment operator and Rnoweb completion of code block
...
let R_assign = 0
This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
Why and where are \n 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 \n) 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.