I managed to remove the error by ordering the columns in the correct order, as indicated in the pdf
On Fri, Mar 7, 2025, 4:55 PM Enrico Schumann <[email protected]> wrote: > On Fri, 07 Mar 2025, Arnaud Gaboury writes: > > > I have one tibble 'journal_tb' with this structure: > > > > gabx@magnolia [R] str(journal_tb) > > tibble [72 × 4] (S3: tbl_df/tbl/data.frame) > > $ timestamp : POSIXct[1:72], format: "2024-12-16 18:00:00" "2024-12-16 > > 18:00:00" "2024-12-16 18:00:00" "2024-12-16 18:00:00" ... > > $ instrument: chr [1:72] "FTMUSDT" "SUIUSDT" "ETHUSDT" "ENAUSDT" ... > > $ amount : num [1:72] 284270 80024 91.9 207836 9.34 ... > > $ price : num [1:72] 1.38 4.73 4038 1.19 107012 ... > > > > When transforming to a PMwR journal: > > > > gabx@magnolia [R] my_journal <- as.journal(my_journal_tb) > > > > I have this error: Error in names[[i]] : subscript out of bounds > > > > I have double checked my columns but everything looks fine. > > > > How can I solve this out of bounds error? > > > > Thnak you for help > > Hm, the 'str' output is for 'journal_tb', but below you > try to coerce 'my_journal_tb'. Is this simply a typo? > > In any case, we would need a small reproducible example to > see why it does not work, e. g. by using > dput(my_journal_tb). [Ideally only a few rows.] > > I can do this, for instance, without problems: > > library("PMwR") > d <- data.frame(timestamp = c("2024-12-16 18:00:00", > "2024-12-16 18:00:00"), > instrument= c( "FTMUSDT", "SUIUSDT"), > amount = c(284270, 80024), > price = c(1.38, 4.73)) > as.journal(d) > ## 1 FTMUSDT 2024-12-16 18:00:00 284270 1.38 > ## 2 SUIUSDT 2024-12-16 18:00:00 80024 4.73 > ## > ## 2 transactions > > library("tibble") > d <- as_tibble(d) > as.journal(d) > ## 1 FTMUSDT 2024-12-16 18:00:00 284270 1.38 > ## 2 SUIUSDT 2024-12-16 18:00:00 80024 4.73 > ## > ## 2 transactions > > > > -- > Enrico Schumann > Lucerne, Switzerland > https://enricoschumann.net > [[alternative HTML version deleted]] _______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.
