Dear list,

I have a problem with defining a function (see below) to read my testfile
(see testfile). My function only returns mydata I wish to work with
attr(mydata, 'fc') as well (for labelling a plot). Principally it works if
I do not insist on this function but it would be much easer if it is
possible to return mydata AND attr(mydata, 'fc') by using a function.

1) testfile:

Id;fc;zat;dat;hat
PG;1,3;1;2;3
HU;2,5;0;2;5
JZ;1,8;1;0;4


2) my function:

read.data <- function(file,  ...){

  mydata <- read.csv2 (file, header=TRUE, as.is=TRUE) # read everything

  fc <- mydata[,2]                      # extract FC column
  rownames(mydata) <- mydata[,1]        # same for gene names to be used as
rownames
  mydata <- mydata[,-(1:2)]             # drop those two columns
  attr(mydata, 'fc') <- fc               # attach FC back as attribute
  return(mydata)                        # and return
  # return fc or return attr(mydata, 'fc') does not work
}

further code is like this:

newdata <- read.data("testfile")
head (newdata) #works but not
fc # or
attr(mydata, 'fc') # it does not work if I include return fc or attr... in
my function neither


Then I can get access to newdata and on but not on fc or attr(mydata, 'fc').

Is there a possibility to use function and having access to attr AND
newdata?

Thanks
Sincerely
Hermann Norpois

	[[alternative HTML version deleted]]

