[R-SIG-Finance] as.journal returns subscript out of bounds

Arnaud Gaboury @rn@ud@g@boury @end|ng |rom gm@||@com
Fri Apr 11 19:46:46 CEST 2025


On Fri, 2025-04-11 at 19:33 +0200, Enrico Schumann wrote:

I was just writing the same observation: it is when I run view().

gabx using magnolia [R] short_j <- journal(
...   timestamp = short$value,
...   amount = short$executed_qty,
...   price = short$price,
...   instrument = short$symbol
... )
gabx using magnolia [R] View(short_j)
Error in names[[i]] : subscript out of bounds

As you can see, I can build the short_j journal with no error, but it
is when I want to view it.
I use Rstudio on Archlinux.
When running 
R > utils::View(btc_journal)

a pop up window open with the journal in a correct view.

So there is something wrong with Rstudio ? Or any package of my linux
distro?



> On Fri, 11 Apr 2025, Arnaud Gaboury writes:
> 
> > Even in a new empty environment, anf after a rebuild of ally my
> > data
> > frames which bring me to the final ones, I still get this error:
> > gabx using magnolia [R] btc_journal <- as.journal(btc_op)
> > gabx using magnolia [R] View(btc_journal)
> > Error in names[[i]] : subscript out of bounds
> > gabx using magnolia [R] str(btc_journal)
> > ‘journal’:	 78 transactions
> >  $ instrument: chr [1:78] "BTCUSDC" "BTCUSDC" "BTCUSDC" "BTCUSDC"
> > ...
> >  $ timestamp : POSIXct[1:78], format: "2024-12-16 18:10:00" "2024-
> > 12-17
> > 09:01:30" "2024-12-18 20:32:53" "2025-01-02 09:33:18" ...
> >  $ amount    : num [1:78] 9.3372 0.0481 0.1232 -0.065 0.9656 ...
> >  $ price     : num [1:78] 107012 107359 101423 96408 96606 ... 
> > 
> > 
> > 
> > I am afraid I must learn to use traceback() as I can't see any
> > obvious
> > reasons for the error.
> 
> I cannot reproduce with recent Rs on GNU/Linux.
> 
> But I _can_ reproduce it on Windows with RStudio. And
> the error is not thrown by `as.journal`, but when I try
> to call `View`.  Which is RStudio's own variant of the
> function.  What happens when you say
> 
>     utils::View(btc_journal)
> 
> ?
> 
> 
>     Enrico
> 
> > On Fri, 2025-04-11 at 07:40 -0500, Dirk Eddelbuettel wrote:
> > > 
> > > On 11 April 2025 at 14:16, Arnaud Gaboury wrote:
> > > > I can't see any reason why the command returns an error.
> > > 
> > > It does not error for me:
> > > 
> > >   > class(btc_op)
> > >   [1] "tbl_df"     "tbl"        "data.frame"
> > >   > class(as.journal(btc_op))
> > >   [1] "journal"
> > >   > head(as.journal(btc_op))
> > >      instrument            timestamp    amount     price
> > >   1     BTCUSDC  2024-12-16 12:10:00   9.33721  107012.0
> > >   2     BTCUSDC  2024-12-17 03:01:30   0.04811  107358.8
> > >   3     BTCUSDC  2024-12-18 14:32:53   0.12324  101422.9
> > >   4     BTCUSDC  2025-01-02 03:33:18  -0.06504   96408.2
> > >   5     BTCUSDC  2025-01-02 04:15:12   0.96557   96606.1
> > >   6     BTCUSDC  2025-01-14 05:34:28   2.42992   96526.3
> > >   
> > >   6 transactions  
> > >   > 
> > > 
> > > So maybe your local setup is borked. I am 'CRAN-current' here and
> > > used the
> > > `structure()` command you posted.
> > > 
> > > You may want to learn about traceback(), and things like
> > > browser(),
> > > to debug
> > > functions.  It's all open source so you can play with it.
> > > 
> > > Dirk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20250411/a749c305/attachment.sig>


More information about the R-SIG-Finance mailing list