I tried using various versions of the 'edit' command. Here is an account of how this failed. I hope I have included all relevant information. I haven't used R for a couple of years. Before restarting with R, I downloaded the latest version I could find in its binary version, and installed it without any problems. Mac Os X Finder command "About R" responds with R 3.0.1 GUI 1.61 Snow Leopard build (6492)
"edit" command does not work as I would expect
5 messages · Brandon Hurr, David Epstein, Simon Urbanek
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-sig-mac/attachments/20130813/dd8d977c/attachment.pl>
Thanks for your email, which was sufficient to point me to my error. Before your email, I had thought that if the file did not exist, then the "edit" command would create the file, since this is what happens when using editor programs under Unix. But in R is not correct, at least on my combination of OS and R. So I first separately created a file called "nam.R" and then tried vi(file="nam.R"). At this point R opened a new window with an editor that controlled the window and enabled one to edit "nam.R", but the editor wasn't vi and it wasn't vim. Maybe it was some standard editor provided with R. My problem is therefore half solved. I cannot see how to invoke a true vim or vi that cooperates directly with R. Do other Mac users experience the same feature? I would be interested to know what happens on non-Mac Unix, Linux or Windows platforms, if anyone can spare the time and has the hardware to try it. Some R-help subscribers seem to regard it as axiomatic that no problem with R on a Mac can occur on other platforms, and I have been strongly re-directed to this list. Now perhaps I'll find out that this particular question is also not appropriate for R-SIG-MAC. Thanks for any help. David
On 13 Aug 2013, at 15:45, Brandon Hurr wrote:
If I had to guess it would be that your file isn't in the working directory. If you supply the entire file location does it work as expected? HTH B On Tue, Aug 13, 2013 at 3:29 PM, David Epstein <David.Epstein at warwick.ac.uk> wrote: I tried using various versions of the 'edit' command. Here is an account of how this failed. I hope I have included all relevant information. I haven't used R for a couple of years. Before restarting with R, I downloaded the latest version I could find in its binary version, and installed it without any problems. Mac Os X Finder command "About R" responds with R 3.0.1 GUI 1.61 Snow Leopard build (6492) From inside R
version
platform x86_64-apple-darwin10.8.0
arch x86_64
os darwin10.8.0 #(However, my os is in fact 10.6.8)
system x86_64, darwin10.8.0
status
major 3
minor 0.1
year 2013
month 05
day 16
svn rev 62743
language R
version.string R version 3.0.1 (2013-05-16)
nickname Good Sport
edit(file='2.9.R')
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") : cannot open file '2.9.R': No such file or directory
getOption('editor')
[1] "vi"
edit(file='2.9.R',editor='/opt/local/bin/vim') Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file '2.9.R': No such file or directory vi(file='try') Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file 'try': No such file or directory
And here is my interaction with tcsh (my default shell) H2:~% echo $VISUAL /opt/local/bin/vim H2:~% echo $EDITOR /opt/local/bin/vim H2:~% which vi vi: aliased to /opt/local/bin/vim H2:~/<4>Chap2% ls -ld drwxr-xr-x 11 dbae dbae 374 8 Aug 10:54 ./ What am I doing wrong? Thanks for any help. David
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
David,
On Aug 14, 2013, at 10:37 AM, David Epstein wrote:
Thanks for your email, which was sufficient to point me to my error. Before your email, I had thought that if the file did not exist, then the "edit" command would create the file, since this is what happens when using editor programs under Unix. But in R is not correct, at least on my combination of OS and R. So I first separately created a file called "nam.R" and then tried vi(file="nam.R"). At this point R opened a new window with an editor that controlled the window and enabled one to edit "nam.R", but the editor wasn't vi and it wasn't vim. Maybe it was some standard editor provided with R. My problem is therefore half solved. I cannot see how to invoke a true vim or vi that cooperates directly with R. Do other Mac users experience the same feature?
I suspect that you're running the R Mac GUI (you didn't say). In that case, you're not on a shell, so obviously you cannot use shell programs like vi. If your editor is a proper OS X app (and not just a command line tool), you can set it to be the default editor in the preferences of the GUI. However, given the reference to other unix platforms above, my guess would be that you really intended to use the command-line version of R (by typing "R" in the shell) - there all the regular unix rules apply. Cheers, Simon
I would be interested to know what happens on non-Mac Unix, Linux or Windows platforms, if anyone can spare the time and has the hardware to try it. Some R-help subscribers seem to regard it as axiomatic that no problem with R on a Mac can occur on other platforms, and I have been strongly re-directed to this list. Now perhaps I'll find out that this particular question is also not appropriate for R-SIG-MAC. Thanks for any help. David On 13 Aug 2013, at 15:45, Brandon Hurr wrote:
If I had to guess it would be that your file isn't in the working directory. If you supply the entire file location does it work as expected? HTH B On Tue, Aug 13, 2013 at 3:29 PM, David Epstein <David.Epstein at warwick.ac.uk> wrote: I tried using various versions of the 'edit' command. Here is an account of how this failed. I hope I have included all relevant information. I haven't used R for a couple of years. Before restarting with R, I downloaded the latest version I could find in its binary version, and installed it without any problems. Mac Os X Finder command "About R" responds with R 3.0.1 GUI 1.61 Snow Leopard build (6492) From inside R
version
platform x86_64-apple-darwin10.8.0
arch x86_64
os darwin10.8.0 #(However, my os is in fact 10.6.8)
system x86_64, darwin10.8.0
status
major 3
minor 0.1
year 2013
month 05
day 16
svn rev 62743
language R
version.string R version 3.0.1 (2013-05-16)
nickname Good Sport
edit(file='2.9.R')
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") : cannot open file '2.9.R': No such file or directory
getOption('editor')
[1] "vi"
edit(file='2.9.R',editor='/opt/local/bin/vim') Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file '2.9.R': No such file or directory vi(file='try') Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file 'try': No such file or directory
And here is my interaction with tcsh (my default shell) H2:~% echo $VISUAL /opt/local/bin/vim H2:~% echo $EDITOR /opt/local/bin/vim H2:~% which vi vi: aliased to /opt/local/bin/vim H2:~/<4>Chap2% ls -ld drwxr-xr-x 11 dbae dbae 374 8 Aug 10:54 ./ What am I doing wrong? Thanks for any help. David
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
Dear Simon Thanks so much for explaining it all to me. Yes, I was running your GUI. i tried the command line interface to R, and, as you promised, it all worked perfectly. I had found the situation very puzzling. It also seems that R-help subscribers were, after all, right in directing me to this list. I now have a much better understanding of what is going on. Best wishes David
On 14 Aug 2013, at 16:57, Simon Urbanek wrote:
David, On Aug 14, 2013, at 10:37 AM, David Epstein wrote:
Thanks for your email, which was sufficient to point me to my error. Before your email, I had thought that if the file did not exist, then the "edit" command would create the file, since this is what happens when using editor programs under Unix. But in R is not correct, at least on my combination of OS and R. So I first separately created a file called "nam.R" and then tried vi(file="nam.R"). At this point R opened a new window with an editor that controlled the window and enabled one to edit "nam.R", but the editor wasn't vi and it wasn't vim. Maybe it was some standard editor provided with R. My problem is therefore half solved. I cannot see how to invoke a true vim or vi that cooperates directly with R. Do other Mac users experience the same feature?
I suspect that you're running the R Mac GUI (you didn't say). In that case, you're not on a shell, so obviously you cannot use shell programs like vi. If your editor is a proper OS X app (and not just a command line tool), you can set it to be the default editor in the preferences of the GUI. However, given the reference to other unix platforms above, my guess would be that you really intended to use the command-line version of R (by typing "R" in the shell) - there all the regular unix rules apply. Cheers, Simon
I would be interested to know what happens on non-Mac Unix, Linux or Windows platforms, if anyone can spare the time and has the hardware to try it. Some R-help subscribers seem to regard it as axiomatic that no problem with R on a Mac can occur on other platforms, and I have been strongly re-directed to this list. Now perhaps I'll find out that this particular question is also not appropriate for R-SIG-MAC. Thanks for any help. David On 13 Aug 2013, at 15:45, Brandon Hurr wrote:
If I had to guess it would be that your file isn't in the working directory. If you supply the entire file location does it work as expected? HTH B On Tue, Aug 13, 2013 at 3:29 PM, David Epstein <David.Epstein at warwick.ac.uk> wrote: I tried using various versions of the 'edit' command. Here is an account of how this failed. I hope I have included all relevant information. I haven't used R for a couple of years. Before restarting with R, I downloaded the latest version I could find in its binary version, and installed it without any problems. Mac Os X Finder command "About R" responds with R 3.0.1 GUI 1.61 Snow Leopard build (6492) From inside R
version
platform x86_64-apple-darwin10.8.0
arch x86_64
os darwin10.8.0 #(However, my os is in fact 10.6.8)
system x86_64, darwin10.8.0
status
major 3
minor 0.1
year 2013
month 05
day 16
svn rev 62743
language R
version.string R version 3.0.1 (2013-05-16)
nickname Good Sport
edit(file='2.9.R')
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") : cannot open file '2.9.R': No such file or directory
getOption('editor')
[1] "vi"
edit(file='2.9.R',editor='/opt/local/bin/vim') Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file '2.9.R': No such file or directory vi(file='try') Error in file(con, "r") : cannot open the connection In addition: Warning message: In file(con, "r") : cannot open file 'try': No such file or directory
And here is my interaction with tcsh (my default shell) H2:~% echo $VISUAL /opt/local/bin/vim H2:~% echo $EDITOR /opt/local/bin/vim H2:~% which vi vi: aliased to /opt/local/bin/vim H2:~/<4>Chap2% ls -ld drwxr-xr-x 11 dbae dbae 374 8 Aug 10:54 ./ What am I doing wrong? Thanks for any help. David
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac
_______________________________________________ R-SIG-Mac mailing list R-SIG-Mac at r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-mac