maybe something like this ... base R
write.csv( data.frame( myid=1:10, var=runif(10) ),"temp.csv")
ids <- c(1,3,4)
read.table("temp.csv", header=T, sep=",", skip=2, nrows=2)
dummy <- function(file, ids){
tmp <-
mapply(
read.table,
skip=ids,
MoreArgs= list(nrows=1, file=file, sep=",") ,
SIMPLIFY = FALSE
)
tmp_df <- do.call(rbind.data.frame, tmp)
names(tmp_df) <- names(read.table("temp.csv", header=T, sep=",",nrows=1))
return(tmp_df)
}
dummy("temp.csv", ids)
source
share