rpart icon indicating copy to clipboard operation
rpart copied to clipboard

prune.rpart getting subscript out of bounds

Open davavra opened this issue 5 years ago • 2 comments

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.

davavra avatar May 10 '19 19:05 davavra

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.

bethatkinson avatar May 24 '19 20:05 bethatkinson

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" } } ]

davavra avatar May 25 '19 19:05 davavra