[R] Length problem

Paolo Grillo paolo.grillo at guest.unimi.it
Mon Feb 11 16:50:47 CET 2008


   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 <[1]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
     ______________________________________________
     [2]R-help at r-project.org mailing list
     [3]https://stat.ethz.ch/mailman/listinfo/r-help
     PLEASE do read the posting guide
     [4]http://www.R-project.org/posting-guide.html
     and provide commented, minimal, self-contained, reproducible code.

References

   1. mailto:paolo.grillo at guest.unimi.it
   2. mailto:R-help at r-project.org
   3. https://stat.ethz.ch/mailman/listinfo/r-help
   4. http://www.R-project.org/posting-guide.html


More information about the R-help mailing list