emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Thomas S. Dye" <tsd@tsdye.com>
To: emacs-orgmode list <emacs-orgmode@gnu.org>
Subject: Re: [Babel] - importing a data file- missing header row
Date: Tue, 8 Dec 2009 07:43:53 -1000	[thread overview]
Message-ID: <5D4EB066-25B8-4800-B3CF-5BFBAE9CC274@tsdye.com> (raw)


[-- 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

                 reply	other threads:[~2009-12-08 17:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5D4EB066-25B8-4800-B3CF-5BFBAE9CC274@tsdye.com \
    --to=tsd@tsdye.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).