hi ,everyone, I have a script shown as below:> bj2=bjerrdata$tyerr[bjyearnum[2]+1:bjyearnum[3]] > length(bj2)[1] 448 while> b=bjyearnum[3] > a=bjyearnum[2]+1 > bj1=bjerrdata$tyerr[a:b] > length(bj1)[1] 169 it is different with bj2 and bj1 . and the array bjyearnum is [1] 0 279 448 633 1021 1365 1813 2237 2839 3314 3798 4157 12 why bj1 is 169 while bj2 is 448 ? how to let bj2 is also array with the length 169 ? thank you . -- TANG Jie Email: totangjie@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[alternative HTML version deleted]]
interting , when I modified bj2=bjerrdata$tyerr[bjyearnum[2]:bjyearnum[3]] the length of bj2 is correct . It seems that can not put a fomula in the dimension description . 2009/7/29 Jie TANG <totangjie@gmail.com>> hi ,everyone, > > I have a script shown as below: > > > bj2=bjerrdata$tyerr[bjyearnum[2]+1:bjyearnum[3]] > > length(bj2) > [1] 448 > > while > > > b=bjyearnum[3] > > a=bjyearnum[2]+1 > > bj1=bjerrdata$tyerr[a:b] > > length(bj1) > [1] 169 > > > it is different with bj2 and bj1 . and the array bjyearnum is > [1] 0 279 448 633 1021 1365 1813 2237 2839 3314 3798 4157 12 > > why bj1 is 169 while bj2 is 448 ? > > how to let bj2 is also array with the length 169 ? > > thank you . > -- > > > TANG Jie > Email: totangjie@gmail.com > Tel: 0086-2154896104 > Shanghai Typhoon Institute,China >-- TANG Jie Email: totangjie@gmail.com Tel: 0086-2154896104 Shanghai Typhoon Institute,China [[alternative HTML version deleted]]
Try this:
bj2=bjerrdata$tyerr[ (bjyearnum[2]+1):bjyearnum[3] ]
I think it's more like what you meant to do. I believe what you wrote
actually did: bjyearnum[2]+(1:bjyearnum[3])
So the problem was with arithmetic priorities, in my opinion (":"
having a higher priority than "+").
Check this:
> (1+2):4
[1] 3 4> 1+2:4
[1] 3 4 5>
Xavier
----- Mail Original -----
De: "Jie TANG" <totangjie at gmail.com>
?: r-help at r-project.org
Envoy?: Mercredi 29 Juillet 2009 09h30:51 GMT +01:00 Amsterdam / Berlin / Berne
/ Rome / Stockholm / Vienne
Objet: [R] quetions about dimensions
hi ,everyone,
I have a script shown as below:
> bj2=bjerrdata$tyerr[bjyearnum[2]+1:bjyearnum[3]]
> length(bj2)
[1] 448
while
> b=bjyearnum[3]
> a=bjyearnum[2]+1
> bj1=bjerrdata$tyerr[a:b]
> length(bj1)
[1] 169
it is different with bj2 and bj1 . and the array bjyearnum is
[1] 0 279 448 633 1021 1365 1813 2237 2839 3314 3798 4157 12
why bj1 is 169 while bj2 is 448 ?
how to let bj2 is also array with the length 169 ?
thank you .
--
TANG Jie
Email: totangjie at gmail.com
Tel: 0086-2154896104
Shanghai Typhoon Institute,China
[[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.