Reputation: 247
I have tried the tidy_source() on my windows machine and it worked just fine. However it fails when I try to run tidy_source() on a Ubuntu machine.
> sessionInfo()
R version 3.2.1 (2015-06-18)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.2 LTS
locale:
[1] LC_CTYPE=en_SG.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_SG.UTF-8 LC_COLLATE=en_SG.UTF-8
[5] LC_MONETARY=en_SG.UTF-8 LC_MESSAGES=en_SG.UTF-8
[7] LC_PAPER=en_SG.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_SG.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] formatR_1.2
loaded via a namespace (and not attached):
[1] tools_3.2.1 grid_3.2.1 stats4_3.2.1
The sample text to be formatted is copied into clipboard, and then I ran tidy_source()
. Error message shows up, where the arrow is pointing to an invalid character (not displayed in R):
> tidy_source()
Error in parse(text = x, keep.source = TRUE) :
<text>:1:1: unexpected input
1:
^
The same procedure works for R on a Windows machine, and (apparently) on a linux machine in the example provided in the formatR package.
The following sample code works fine:
## a messy R script
messy = system.file("format", "messy.R", package = "formatR")
tidy_source(messy)
Am I doing something wrong here? Or am I missing something important?
EDIT: following comment suggestions, I have tried the following variations when calling the function, but none of them seems to work.
> tidy_source(source = "X11_clipboard")
Error in file(con, "r") :
X11 clipboard selection is not supported on this system
> tidy_source(source = "X11_primary")
Error in parse(text = x, keep.source = TRUE) :
<text>:1:1: unexpected input
1:
^
> tidy_source(source = "X11_secondary")
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") : clipboard cannot be opened or contains no text
Upvotes: 0
Views: 242