Hello,

Your data.frame has some noise in the last two rows.
See if this works.


#------------------- this is your code ---------------
spec <- "EU2001"
part1 <- "http://www.bundesbank.de/statistik/statistik_zeitreihen_download.php?func=directcsv&from=&until=&filename=bbk_";
part2 <- "&csvformat=de&euro=mixed&tr="
tmp <- tempfile()
load <- paste(part1, spec, part2, spec, sep="")
download.file(load,tmp)

# read it in, no conversion from strings to factors
file <- read.csv(tmp, sep=";", dec=",", skip="5", stringsAsFactors=FALSE)
# see it
str(file)
head(file)
tail(file)  # -----> problem
# last two rows are messed up
nr <- nrow(file)
# see it without them
tail(file[ -c(nr - 1, nr), ])

# remove the last two rows
fl <- file[ -c(nr - 1, nr), ]
(relevant <- fl[, 2])

Also, 'file' is the name of an R function, use something else, it can be confusing.

Hope this helps,

Rui Barradas



Em 15-05-2012 11:00, r-help-requ...@r-project.org escreveu:
Date: Mon, 14 May 2012 02:33:54 -0700 (PDT)
From: barb<mainze...@hotmail.com>
To:r-help@r-project.org
Subject: [R] Data read as labels
Message-ID:<1336988034111-4629901.p...@n4.nabble.com>
Content-Type: text/plain; charset=us-ascii

Hey guys,

i have a strange problem reading a .csv file.
Seems not to be covered by the usual read.csv techniques.

The relevant data i want to use, seems to be saved as the label of the data
point.
Therefore i can not really use it


spec<-"EU2001"
part1<-"http://www.bundesbank.de/statistik/statistik_zeitreihen_download.php?func=directcsv&from=&until=&filename=bbk_";
part2<-"&csvformat=de&euro=mixed&tr="
tmp<-tempfile()
load<-paste(part1,spec,part2,spec,sep="")
download.file(load,tmp)
file<-read.csv(tmp,sep=";",dec=",", skip="5")
(relevant<-file[,2][1])

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to