Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Rolf Turner
See fortunes::fortune(36). cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Stats. Dep't. (secretaries) phone: +64-9-373-7599 ext. 89622 Home phone: +64-9-480-4619 __ R-help@r-project.org

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Peter Dalgaard via R-help
Heh. Did anyone bring up negative indices yet? -pd > On 22 Apr 2024, at 10:46 , Rolf Turner wrote: > > > See fortunes::fortune(36). > > cheers, > > Rolf Turner > > -- > Honorary Research Fellow > Department of Statistics > University of Auckland > Stats. Dep't. (secretaries) phone: >

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Hans W
Thanks for pointing out the 'Oarray' package which indeed for me works slightly better than the 'index0' package. library(Oarray) x <- Oarray(data=c(2,3,5,7,11,13,17,19), offset=0) x #> [0,] [1,] [2,] [3,] [4,] [5,] [6,] [7,] #>2357 11 13 17 19 Though

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Spencer Graves
Convert to character: goofy <- 1:9 names(goofy) <- (-4):4 goofy[as.character(0)] goofy["-2"] sg On 4/22/24 10:31 AM, Ebert,Timothy Aaron wrote: You could have negative indices. There are two ways to do this. 1) provide a large offset. Offset <- 30 for (i in -29 to 120) {

Re: [R] x[0]: Can '0' be made an allowed index in R?

2024-04-22 Thread Ebert,Timothy Aaron
You could have negative indices. There are two ways to do this. 1) provide a large offset. Offset <- 30 for (i in -29 to 120) { print(df[i+Offset])} 2) use absolute values if all indices are negative. for (i in -200 to -1) {print(df[abs(i)])} Tim -Original Message- From: R-help On