rpart
rpart copied to clipboard
prune.rpart getting subscript out of bounds
prune.rpart gets a subscript out of bounds error on the last line shown here
temp <- pmax(tree$cptable[, 1L], cp)
keep <- match(unique(temp), temp)
newx$cptable <- tree$cptable[keep, , drop = FALSE]
newx$cptable[max(keep), 1L] <- cp
The values in keep may exceed the number of rows in newx$cptable. In fact, this is causing the error I've encountered where max(keep)=298 and the number of rows in newx$cptable is 295. The line probably should be altered to read:
newx$cptable[length(keep), 1L] <- cp
but I don't know the purpose of this statement so I'm not sure this would be the proper fix.
do you have a reproducible example that I can work with?
From: davavra [mailto:[email protected]] Sent: Friday, May 10, 2019 2:47 PM To: bethatkinson/rpart Cc: Subscribed Subject: [EXTERNAL] [bethatkinson/rpart] prune.rpart getting subscript out of bounds (#4)
prune.rpart gets a subscript out of bounds error on the last line shown here temp <- pmax(tree$cptable[, 1L], cp) keep <- match(unique(temp), temp) newx$cptable <- tree$cptable[keep, , drop = FALSE] newx$cptable[max(keep), 1L] <- cp The values in keep may exceed the number of rows in newx$cptable. In fact, this is causing the error I've encountered where max(keep)=298 and the number of rows in newx$cptable is 295. The line probably should be altered to read: newx$cptable[length(keep), 1L] <- cp but I don't know the purpose of this statement so I'm not sure this would be the proper fix.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/bethatkinson/rpart/issues/4, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACWQG52E2TBQIM2XF64WGFDPUXGMVANCNFSM4HMFY2DA.
Yes, but it's huge and proprietary.I don't have a simpler example. DAV
On Fri, 2019-05-24 at 13:15 -0700, Beth Atkinson wrote:
do you have a reproducible example that I can work with?
From: davavra [mailto:[email protected]]
Sent: Friday, May 10, 2019 2:47 PM
To: bethatkinson/rpart
Cc: Subscribed
Subject: [EXTERNAL] [bethatkinson/rpart] prune.rpart getting subscript out of bounds (#4)
prune.rpart gets a subscript out of bounds error on the last line shown here
temp <- pmax(tree$cptable[, 1L], cp) keep <- match(unique(temp), temp) newx$cptable <- tree$cptable[keep, , drop = FALSE] newx$cptable[max(keep), 1L] <- cp
The values in keep may exceed the number of rows in newx$cptable. In fact, this is causing the error I've encountered where max(keep)=298 and the number of rows in newx$cptable is 295. The line probably should be altered to read:
newx$cptable[length(keep), 1L] <- cp
but I don't know the purpose of this statement so I'm not sure this would be the proper fix.
???
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub< https://github.com/bethatkinson/rpart/issues/4>;, or mute the thread< https://github.com/notifications/unsubscribe-auth/ACWQG52E2TBQIM2XF64WGFDPUXGMVANCNFSM4HMFY2DA>;.
??? You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": " https://github.com/bethatkinson/rpart/issues/4?email_source=notifications\u0026email_token=AMBJFOB6O7VLLM7IFZB4VGDPXBEF5A5CNFSM4HMFY2DKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWGO4OQ#issuecomment-495775290 ", "url": " https://github.com/bethatkinson/rpart/issues/4?email_source=notifications\u0026email_token=AMBJFOB6O7VLLM7IFZB4VGDPXBEF5A5CNFSM4HMFY2DKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWGO4OQ#issuecomment-495775290 ", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]