Re: [R] Length problem

From: milton ruser <milton.ruser_at_gmail.com>
Date: Mon, 11 Feb 2008 14:02:01 -0300

Ciao Paulo,
my.data<-read.table(stdin(),head=T,sep=",")

yy,mm,dd,C.531,C.542,C.558,C.565
2003,1,1,0.9941125,1.412338,0.8996750,2.258200
2003,1,2,1.7931375,2.786900,NA,3.108725
2003,1,3,NA,3.657775,1.7269750,2.541938
2003,1,4,1.0840625,1.766925,1.2313375,2.321300
2003,1,5,1.1558000,2.128488,0.9670375,NA


coppie<-c(my.data[4:length(my.data)])

my.data[,4]

length(my.data[,4])

coppie[1]

length(coppie[1]) #here you get 1 because you have one object ($C.531)

length(coppie[[1]]) #here you get what you want.  Good luck

Miltinho

On 2/11/08, Paolo Grillo <paolo.grillo_at_guest.unimi.it> wrote:
>
> Ciao Milthinho
> Here it is
>
> > data
> yy mm dd C.531 C.542 C.558 C.565
> 1 2003 1 1 0.9941125 1.412338 0.8996750 2.258200
> 2 2003 1 2 1.7931375 2.786900 NA 3.108725
> 3 2003 1 3 NA 3.657775 1.7269750 2.541938
> 4 2003 1 4 1.0840625 1.766925 1.2313375 2.321300
> 5 2003 1 5 1.1558000 2.128488 0.9670375 NA
>
> # New data
> coppie<-c(data[4:length(data)])
>
> # Length of original data
> > data[,4]
> [1] 0.9941125 1.7931375 NA 1.0840625 1.1558000
> > length(data[,4])
> [1] 5
> > 5 # Right !!!!!!!!!!!!!!!
> [1] 5
> > # Length of new data
> > coppie[1]
> $C.531
> [1] 0.9941125 1.7931375 NA 1.0840625 1.1558000
>
> > length(coppie[1])
> [1] 1
> > 1 # Why ??????????????????
>
> Thank you for your help
>
> Paolo
> Italia
>
>
> milton ruser wrote:
>
> Ciao Paolo,
>
> How about you show some row of your data?
> How many columns have your data.frame? One?
> By the way "data" is not a so good name for your data frame.
>
> We will be very happy to help you
>
> Kindly,
>
> Miltinho
> Brasile
>
> On 2/11/08, Paolo Grillo <paolo.grillo_at_guest.unimi.it> wrote:
> >
> >
> > Hi all
> > I have this problem:
> > In my database .dta, called "data" I have five rows
> > data<-read.dta("C:\\2_CO_mmobile_ALL_Rid.dta")
> > # From this database I wuold like to create another
> > coppie<-c(data[4:length(data)])
> > but I find this
> >
> > # Length of original data
> > length(data[,4])
> > 5 RIGHT!!
> > # Length of new data
> > length(coppie[1])
> > 1 WHY??
> > Thank you all for your help
> > Paolo Grillo
> > ______________________________________________
> > R-help_at_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<http://www.r-project.org/posting-guide.html>
> > and provide commented, minimal, self-contained, reproducible code.
> >
>
>

        [[alternative HTML version deleted]]



R-help_at_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. Received on Mon 11 Feb 2008 - 17:08:57 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 11 Feb 2008 - 17:30:12 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive