Re: [R] how to skip last lines while reading the data in R

2008-01-28 Thread Gabor Grothendieck
or even: head(read.table("xy.dat", header = TRUE), -2) On Jan 28, 2008 10:52 AM, Gabor Grothendieck <[EMAIL PROTECTED]> wrote: > If you don't mind reading it in twice its just: > > DF <- read.table("xy.dat", header = TRUE, nrow = > length(readLines("xy.dat")) - 3) > tail(DF) > # or > DF <- read.

Re: [R] how to skip last lines while reading the data in R

2008-01-28 Thread Romain Francois
Hi, What about this : data <- read.table( pipe('head -n-2 data.txt') ) However, the aesthetics will only appeal to people having head (maybe it needs to be a recent version as well ...). Cheers, Romain Barry Rowlingson wrote: > Henrique Dallazuanna wrote: > >> Perhaps: >> >> data <- read

Re: [R] how to skip last lines while reading the data in R

2008-01-28 Thread Gabor Grothendieck
If you don't mind reading it in twice its just: DF <- read.table("xy.dat", header = TRUE, nrow = length(readLines("xy.dat")) - 3) tail(DF) # or DF <- read.table("xy.dat", header = TRUE, nrow = length(count.fields("xy.dat")) - 3) tail(DF) # or DF <- read.table("xy.dat", header = TRUE, nrow = nrow(r

Re: [R] how to skip last lines while reading the data in R

2008-01-28 Thread Prof Brian Ripley
On Mon, 28 Jan 2008, mrafi wrote: > but then the number of levels would reamain the same...!! Please explain: the levels of factors are taken from the data which is actually read. > > > Prof Brian Ripley wrote: >> >> On Mon, 28 Jan 2008, Barry Rowlingson wrote: >> >>> Henrique Dallazuanna wrote

Re: [R] how to skip last lines while reading the data in R

2008-01-28 Thread Henrique Dallazuanna
Ok, I agree, but I assume that her don't know the number of rows of file. In your example: rev2 <- function(x,n=100,m=5){ for(i in 1:n){ y=x[1:(length(x)-m)] } return(y) } is needed that open other textConnection - if use the example posted by me. Is there other option? On 28/01

Re: [R] how to skip last lines while reading the data in R

2008-01-28 Thread mrafi
but then the number of levels would reamain the same...!! Prof Brian Ripley wrote: > > On Mon, 28 Jan 2008, Barry Rowlingson wrote: > >> Henrique Dallazuanna wrote: >>> Perhaps: >>> >>> data <- >>> read.table(textConnection(rev(rev(readLines('data.txt'))[-(1:2)]))) >>> >> >> Euurgh! Am I the

Re: [R] how to skip last lines while reading the data in R

2008-01-28 Thread Prof Brian Ripley
On Mon, 28 Jan 2008, Barry Rowlingson wrote: > Henrique Dallazuanna wrote: >> Perhaps: >> >> data <- read.table(textConnection(rev(rev(readLines('data.txt'))[-(1:2)]))) >> > > Euurgh! Am I the only one whose sense of aesthetics is enraged by > this? To get rid of the last two items you reverse th

Re: [R] how to skip last lines while reading the data in R

2008-01-28 Thread Barry Rowlingson
Henrique Dallazuanna wrote: > Perhaps: > > data <- read.table(textConnection(rev(rev(readLines('data.txt'))[-(1:2)]))) > Euurgh! Am I the only one whose sense of aesthetics is enraged by this? To get rid of the last two items you reverse the vector, remove the first two items, then reverse t

Re: [R] how to skip last lines while reading the data in R

2008-01-28 Thread Henrique Dallazuanna
Perhaps: data <- read.table(textConnection(rev(rev(readLines('data.txt'))[-(1:2)]))) will skip the last two lines '-(1:2)' On 28/01/2008, mrafi <[EMAIL PROTECTED]> wrote: > > hey all > greetings > > hey all am an engineering student...and am trying to learn R > i am trying to automate reading a

[R] how to skip last lines while reading the data in R

2008-01-28 Thread mrafi
hey all greetings hey all am an engineering student...and am trying to learn R i am trying to automate reading a specific type of file...and perform certain functions...but i want to omit lines in the end of the file.. there is an option for skiping the lines before begining...but how can i ask R