emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Re: [Babel] - importing a data file- missing header row
@ 2009-12-08 17:43 Thomas S. Dye
  0 siblings, 0 replies; only message in thread
From: Thomas S. Dye @ 2009-12-08 17:43 UTC (permalink / raw)
  To: emacs-orgmode list


[-- Attachment #1.1: Type: text/plain, Size: 2562 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 4026 bytes --]

[-- Attachment #2: Type: text/plain, Size: 201 bytes --]

_______________________________________________
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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-12-08 17:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-08 17:43 [Babel] - importing a data file- missing header row Thomas S. Dye

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).