Hi Graham,
On Dec 8, 2009, at 6:41 AM, Graham Smith wrote:
I need a bit of help importing a data file into orgmode/babel.
The import doesn't seem to know about having a header row
#+srcname:woodland
#+begin_src R
read.table("/home/graham/Dropbox/College/BY4001/WoodlandData/
BY4001WoodlandDataFinal.txt",header=TRUE)
#+end_src
#+resname: woodland
| "V1.1" | "v" | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
0 | 0 | 0 | 0 | 5 | 0 | 0 | 10 | 0 | 0 | 0 | 100 | 0 | 3 | B
But strangely if I change the command and run the names(woodland)
after the import, I get a table of variable names but no data. I'm not
sure if the data is there but hidden as I can't get any commands to
work on the woodland object.
* Woodland Data
#+srcname:woodland
#+begin_src R
woodland<-read.table("/home/graham/Dropbox/College/BY4001/
WoodlandData/BY4001WoodlandDataFinal.txt",header=TRUE)
names(woodland)
#+end_src
#+resname: woodland
| "ID" |
| "wood" |
| "Ajug.Rept" |
| "Ange.sylv" |
| "Brac.sylv" |
| "Brom.ramo" |
| "Care.pend" |
| "Care.remo" |
| "Care.sylv" |
| "Cirs.palu" |
| "Cory.avel" |
| "Desc.caes" |
| "Dryo.fili" |
| "Endy.non" |
| "Euph.amyg" |
So it seems I already need some more help.
Graham
One solution would be to use a :session. Variables created in R will
persist in the session and can be shared by source code blocks
assigned to the :session.
I don't have access to your data, but the following source code blocks
should work for you. I've chosen to name the session 'woodland' but
you can name it whatever you'd like, or not name it and use the
default session.
* Woodland Data
- Create a variable woodland and populate it with
BY4001WoodlandDataFinal.txt
#+srcname:woodland
#+begin_src R :session woodland
woodland<-read.table("/home/graham/Dropbox/College/BY4001/WoodlandData/
BY4001WoodlandDataFinal.txt",header=TRUE)
#+end_src
- Run some summary commands to see if the woodland variable looks right
#+begin_src R :session woodland
names(woodland)
str(woodland)
summary(woodland)
#+end_src
- Show the woodland data
#+begin_src R :session woodland
woodland
#+end_src
I like this approach because I don't have to save a bunch of R objects
when I'm done. I just re-create them when I need them again, because
the R code that I've already tested is saved with my org file.
HTH,
Tom
_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode