Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make .I available in i #4695

Open
jan-glx opened this issue Sep 6, 2020 · 1 comment
Open

Make .I available in i #4695

jan-glx opened this issue Sep 6, 2020 · 1 comment

Comments

@jan-glx
Copy link
Contributor

jan-glx commented Sep 6, 2020

From the documentation:

.SD, .BY, .N, .I, and .GRP are read-only symbols for use in j. .N can be used in i as well.

But like .N, .I could be made available in i as well. (As in j?,) it would be mostly syntactic sugar for seq_len(.N).
For example,

> DT <- data.table::data.table(letters[1:5])
> DT
   V1
1:  a
2:  b
3:  c
4:  d
5:  e
> DT[seq_len(.N) < 3]
   V1
1:  a
2:  b
> DT[.I < 3]
Empty data.table (0 rows and 1 cols): V1

If implemented, DT[.I < 3] would return

   V1
1:  a
2:  b

as well.

I've searched extensively and unsuccessfully for an existing issue but searching for two symbol words is not so easy so I might have missed it; In that case: sorry for the noise.

> sessioninfo::session_info()
─ Session info ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 4.0.0 (2020-04-24)
 os       CentOS Linux 7 (Core)       
 system   x86_64, linux-gnu           
 ui       RStudio                     
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Europe/Berlin               
 date     2020-09-06                  

─ Packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 package        * version    date       lib source                            
 data.table     * 1.12.8     2019-12-09 [1] CRAN (R 4.0.0)        
@ColeMiller1
Copy link
Contributor

#4585 seems unrelated, but includes a way to evaluate i with constants. Currently .N is in there but there is discussion regarding .SD. It would be trivial to have .I. See this discussion regarding .SD in i

#4585 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants