Skip to content
Back to formatted view

Raw Message

Message-ID: <2b2890520803031740q1ec1d760scf82ac3da2470acb@mail.gmail.com>
Date: 2008-03-04T01:40:35Z
From: Thomas Allen
Subject: Strange paste, string or package problem?

Hi

I came across this strange bug the other day, I'm not sure how to solve it
and I wonder if anyone can even replicate it.

Using OS Ubuntu 7.10

Step 1) Make an R package using the package.skeleton() command with
only these two functions:

error <- function(){
  cmd <- paste(" -a ",1," -a ",1," -a ",1,
               " -a ",1," -a ",1," -a ",1,
               " -a ",1," -a ",1," -a ",1,
               " -a ",1," -a ",1," -a ",1,
               " ?a ",1,sep="")
  cat(cmd,"\n")
}
noerror <- function(){
  cmd <- paste(" -a ",1," -a ",1," -a ",1,
               " -a ",1," -a ",1," -a ",1,
               " -a ",1," -a ",1," -a ",1,
               " -a ",1," -a ",1," -a ",1,sep="")
  cat(cmd,"\n")
}

Step 2) Start R again. Load the package with library() and run the commands:
error()
noerror()

I get the following output:
> > library(errors)
> error()
 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 <e2><80><93>a 1
> noerror()
 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1 -a 1
>

Now why does that "<e2><80><93>" replace one of the "-" in the first command?

Any ideas?

Cheers

Tom

-- 
Thomas Allen
Department of Biochemistry
University of Otago
email1: hedbag at gmail.com
email2: allth025 at student.otago.ac.nz
Work: (+64)3 479 5123
Mobile: 027 321 4269