* :dir argument does not seem to be working
@ 2012-08-10 20:05 John Hendy
2012-08-10 20:13 ` John Hendy
0 siblings, 1 reply; 3+ messages in thread
From: John Hendy @ 2012-08-10 20:05 UTC (permalink / raw)
To: emacs-orgmode
Here's a hopefully reproducible example:
----------
* Test
#+header: :dir C:/Users/username/Desktop :file test.png
#+begin_src R :session R :results output graphics :exports results
setwd("C:/Users/username/Documents")
x <- 1:10
y <- x^2
plot(x,y)
#+end_src
----------
I prefer to use R on Linux, but need to stay in Windows at work
sometimes. I'm trying to export my plots to a different directory than
the org file I'm using. I tend to start R in
"C:/Users/username/Documents" on Windows 7 because that's where I set
my library directory and R has trouble loading things if I don't start
there first, load my libraries, and then move to my data directory.
In any case, for the above, when I switch to the R session called =R=,
and do =getwd()= I get C:/Users/username/Documents, which is where the
png ends up, not on the Desktop.
Is this something in my usage I'm doing wrong?
Thanks,
John
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: :dir argument does not seem to be working
2012-08-10 20:05 :dir argument does not seem to be working John Hendy
@ 2012-08-10 20:13 ` John Hendy
2012-08-10 21:32 ` John Hendy
0 siblings, 1 reply; 3+ messages in thread
From: John Hendy @ 2012-08-10 20:13 UTC (permalink / raw)
To: emacs-orgmode
On Fri, Aug 10, 2012 at 3:05 PM, John Hendy <jw.hendy@gmail.com> wrote:
> Here's a hopefully reproducible example:
>
> ----------
>
> * Test
>
> #+header: :dir C:/Users/username/Desktop :file test.png
> #+begin_src R :session R :results output graphics :exports results
> setwd("C:/Users/username/Documents")
> x <- 1:10
> y <- x^2
> plot(x,y)
> #+end_src
>
> ----------
>
> I prefer to use R on Linux, but need to stay in Windows at work
> sometimes. I'm trying to export my plots to a different directory than
> the org file I'm using. I tend to start R in
> "C:/Users/username/Documents" on Windows 7 because that's where I set
> my library directory and R has trouble loading things if I don't start
> there first, load my libraries, and then move to my data directory.
>
> In any case, for the above, when I switch to the R session called =R=,
> and do =getwd()= I get C:/Users/username/Documents, which is where the
> png ends up, not on the Desktop.
>
> Is this something in my usage I'm doing wrong?
>
>
> Thanks,
> John
Oddly, the first time I now open this file and execute the block, the
file shows up on the Desktop. If I delete it and re-execute, it puts
it in C:/Users/username/Documents! Why would this be? I used =setwd()=
above just to make sure R was elsewhere than the Desktop because I
have another file in which I thought :dir was working properly, but in
fact it was just the default R dir and so the plots were going there
anywhere. Changing the working dir caused the :dir on that block to
reveal that it wasn't working after all.
In the above, even removing the =setwd()= line produces the same
behavior. First time creates file on Desktop, subsequent times puts it
in Documents.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: :dir argument does not seem to be working
2012-08-10 20:13 ` John Hendy
@ 2012-08-10 21:32 ` John Hendy
0 siblings, 0 replies; 3+ messages in thread
From: John Hendy @ 2012-08-10 21:32 UTC (permalink / raw)
To: emacs-orgmode
On Fri, Aug 10, 2012 at 3:13 PM, John Hendy <jw.hendy@gmail.com> wrote:
> On Fri, Aug 10, 2012 at 3:05 PM, John Hendy <jw.hendy@gmail.com> wrote:
>> Here's a hopefully reproducible example:
>>
>> ----------
>>
>> * Test
>>
>> #+header: :dir C:/Users/username/Desktop :file test.png
>> #+begin_src R :session R :results output graphics :exports results
>> setwd("C:/Users/username/Documents")
>> x <- 1:10
>> y <- x^2
>> plot(x,y)
>> #+end_src
>>
>> ----------
>>
>> I prefer to use R on Linux, but need to stay in Windows at work
>> sometimes. I'm trying to export my plots to a different directory than
>> the org file I'm using. I tend to start R in
>> "C:/Users/username/Documents" on Windows 7 because that's where I set
>> my library directory and R has trouble loading things if I don't start
>> there first, load my libraries, and then move to my data directory.
>>
>> In any case, for the above, when I switch to the R session called =R=,
>> and do =getwd()= I get C:/Users/username/Documents, which is where the
>> png ends up, not on the Desktop.
>>
>> Is this something in my usage I'm doing wrong?
>>
>>
>> Thanks,
>> John
>
> Oddly, the first time I now open this file and execute the block, the
> file shows up on the Desktop. If I delete it and re-execute, it puts
> it in C:/Users/username/Documents! Why would this be? I used =setwd()=
> above just to make sure R was elsewhere than the Desktop because I
> have another file in which I thought :dir was working properly, but in
> fact it was just the default R dir and so the plots were going there
> anywhere. Changing the working dir caused the :dir on that block to
> reveal that it wasn't working after all.
>
> In the above, even removing the =setwd()= line produces the same
> behavior. First time creates file on Desktop, subsequent times puts it
> in Documents.
I read the bottom notes in the manual about :dir and it states that
once the session is started when using :session in the header, :dir
won't change the default directory... so it seems that the above is
the behavior to be expected. Sorry to have missed that.
I've worked around by simply using setwd() to change to my data
directory and read the files, and then setwd() again to switch to the
directory where I want my plots.
I'm still having an issue, though...
Here is my block:
----------
#+name: test
#+header: :width 9 :height 6 :file test.pdf :dir ~/Desktop
#+begin_src R :session model :results output graphics :exports results
setwd("~/Desktop")
x <- 1:10
y <- x^2
plot(x,y)
#+end_src
#+RESULTS: test
[[file:/home/jwhendy/Desktop/test.pdf]]
---------
For some reason, however, when exporting the .tex file just contains this:
---------
\includegraphics[width=.9\linewidth]{test.pdf}
---------
For some reason LaTeX isn't picking up the director argument from [[file:/...]]
If I use the whole path in :file, it works correctly. I was trying to
get around having to type my full path each time with either :dir or
setting the R working directory. Is this not possible? Is it only
possible to set the file via the relative path to the directory where
the .org file resides? This is probably fine in most cases, but
sometimes the relative path is just as long as the full path
(depending on how deep one is the relative path might be
../../../../../dir vs. just typing ~/dir).
Thanks for any input on what I'm missing.
Thanks,
John
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-08-10 21:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-10 20:05 :dir argument does not seem to be working John Hendy
2012-08-10 20:13 ` John Hendy
2012-08-10 21:32 ` John Hendy
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.