Re: [R] html excel file

From: Peter Dalgaard <p.dalgaard_at_biostat.ku.dk>
Date: Fri 20 Jan 2006 - 01:00:59 EST

roger bos <roger.bos@gmail.com> writes:

> Read ?scan very carefully and play with the settings. What makes your file
> difficult is that it is multi line, meaning that the headings have carriage
> returns between them instead of being one line separated with spaces or tabs
> or commas. Can you change the way the file is outputted? If not, you will
> have to play with scan to get the file in. Anything is possible, but it
> looks like it will be tricky.

I'd try reading the whole thing as a character vector

x <- scan(...., what="")

then

M <- matrix(x[-(1:3)], byrow=TRUE)

cn <- M[1,-1]
rn <- M[-1,1]
n <- M[-1,-1]

mode(n) <- "numeric"
dimnames(n) <- list(rn,cn)  

and then (possibly) data.frame(n)

[Notice that this is only partially tested, so no guarantees]

> HTH,
> Roger
>
>
>
> On 1/19/06, Stefan Semmeling <trittihn@web.de> wrote:
> >
> > hallo,
> >
> > i have a problem reading in the above mentioned kind of a file.
> > does anybody know an easy way how to read it in?
> > i can save it as a text file that looks like:

> >
> > Datum des Fixings
> > Restlaufzeit
> >
> >
> > 1 Jahr
> > 2 Jahre
> > 3 Jahre
> > 4 Jahre
> > 5 Jahre
> > 6 Jahre
> > 7 Jahre
> > 8 Jahre
> > 9 Jahre
> > 10 Jahre
> > 12 Jahre
> > 15 Jahre
> > 13.01.06
> > 2.819
> > 2.983
> > 3.073
> > 3.137
> > 3.194
> > 3.247
> > 3.302
> > 3.355
> > 3.409
> > 3.459
> > 3.548
> > 3.649
> > 12.01.06
> > 2.847
> > 3.013
> > 3.102
> > 3.164
> > 3.217
> > 3.268
> > 3.322
> > 3.373
> > 3.426
> > 3.475
> > 3.564
> > 3.665
> > ...
> >
> > after skipping the first four lines i want to read it in while the first
> > 12
> > lines are the heades
> > the next is the date followed by the singel values...(these lines are
> > always
> > repeated)
> >
> > it is supposed to look like
> >
> > 1 2 3 4 5 6 7 8 9 10 12 15
> > datum1 a b c d e f g h i j k l
> > datum2 a b c d e f g h i j k l
> > ...
> >
> > i tried to read it in as a normal excel file but it didn┤t work out the
> > way
> > it was supposed to
> >
> > thank you for helping!!!
> >
> > stefan
> >
> > ______________________________________________
> > R-help@stat.math.ethz.ch mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help
> > PLEASE do read the posting guide!
> > http://www.R-project.org/posting-guide.html
> >
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

-- 
   O__  ---- Peter Dalgaard             ěster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)                  FAX: (+45) 35327907

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Fri Jan 20 01:08:20 2006

This archive was generated by hypermail 2.1.8 : Fri 20 Jan 2006 - 02:16:54 EST