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
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@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@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. >[[alternative HTML version deleted]]
I think that coppie is a list, so length(coppie[[1]]) On 11/02/2008, 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 > and provide commented, minimal, self-contained, reproducible code. >-- Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O
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
You were asking for the length of the first element of the vector coppie, which is of course 1. Did you mean to say lgngth(coppie)? length(data[,4]) is asking how many elements in that column, which seems to be 5. also your statement coppie <- c(data[4:length(data)]) seems strange. What did you intend to do? 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 > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem you are trying to solve?
if "data" was your data.frame, data[4:length(data)] was also a data.frame. but, c(data[4:length(data)] ) coerces it to a list. therefore coppie is a list. coppie[1] is also a list of length 1... compare that to: coppie[[1]] b On Feb 11, 2008, at 10:38 AM, 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 >> 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.