Skip to content
Back to formatted view

Raw Message

Message-ID: <513F697F.2090404@ucalgary.ca>
Date: 2013-03-12T17:44:31Z
From: Peter Ehlers
Subject: Troubleshooting code
In-Reply-To: <CACvtrYiUTA870xBKOz8rJ5vTS8s53z5rFGbZV_1knXd9xOM-SQ@mail.gmail.com>

On 2013-03-12 05:29, Sahana Srinivasan wrote:
> Hi everyone, I am having trouble understanding where I went wrong with my
> code. It seems to logically be "all there"  but the output says otherwise.
> I know this is a bit long but I can't seem to find the errors so I would
> appreciate your help :)
>
> This is my program :
>
> files<-Sys.glob("*.rescount.txt");length<-length(files);* #selecting all
> files of a particular extension, saving in a list*

Your use of the name 'length' is a bad idea (but not your problem);
see fortune("dog").

If you think that your object 'files' is a 'list', you're mistaken;
try  str(files)  to see that it's a character vector.

> a<-1;
> while(a<=length) *#going through every element of the list*
> {
>    df1<-read.table(files[a]);

I would _always_ look at the result of any file import with str() to
ensure that the reading went as expected. Do (some of) your files have
variable variable name headers?

>    c.leng<-length(files[,1]);

I don't see why this instruction would not throw an error re "incorrect
number of dimensions".

Okay, at this point I gave up. Your code is not reproducible and
you're posting in HTML. Please give at least a cursory look at the
Posting Guide.

   [... rest of code sample snipped ...]

Peter Ehlers