[R] Changing text file to .r format

Henrik Bengtsson henrik.bengtsson at gmail.com
Sat Nov 7 00:38:44 CET 2015


My guess is that your on Windows. If so, make sure to change settings in
Explorer to always show filename extensions, because now I think it drops
.txt when it lists/displays your files (this is one of the most annoying
features in Windows).

Also, some basic editors add .txt extension when you save a file the first
time. You can try to put quotation marks to force it not to, e.g.
"RHtestsV4.r".

Henrik
On Nov 6, 2015 15:23, "Chattopadhyay, Somsubhra" <sch298 at g.uky.edu> wrote:

Dear all,

I am a beginner in R and want to ask a simple question. I have a code file
in text format which I need to change to .r format only. For example now it
is RHtestsV4.r.txt which needs to be changed to just RHtestsV4.r. I tried
this

sub("^([^.]*).*", "\\1", 'RHtestsV4.r.txt')
[1] "RHtestsV4"

But this didn't seem to work as again when I try to call the function using
source("RHtestsV4.r")
The error message is

Error in file(filename, "r", encoding = encoding) :
  cannot open the connection
In addition: Warning message:
In file(filename, "r", encoding = encoding) :
  cannot open file 'RHtestsV4.r': No such file or directory

I think it is due to the format of the file. Please help me to convert the
file to .r format.

Thanks
Som
--
Somsubhra Chattopadhyay
Graduate Research Assistant
Biosystem and Agricultural Engineering Department
University of Kentucky, Lexington, KY 40546
Email: schattop14 at uky.edu
Cell: 9198026951

        [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

	[[alternative HTML version deleted]]



More information about the R-help mailing list