Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8868661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:19:16+00:00 2026-06-14T17:19:16+00:00

I have a function call WOE, that return a data fame with 1 row,

  • 0

I have a function call WOE, that return a data fame with 1 row, and 7 columns:

WOE(inData, splitCol, range, tgtCol, adjfac)

Where inData is a data frame, splitCol, tgtCol and adjfac are numeric, range can be a single number or a 2×1 matrix,
e.g. range = 10 or range = c(10, 20)

Now I would like to write a function that when the range is a n-row matrix, then the function will do WOE row by row and return a data frame that have n row and 7 columns.
For now i am using a for loop with cbind:

df <- rbind(df, WOE(inData, splitCol, range[i,], tgtCol, adjfac))
for (i in 2:nrow(range)) {
  df <- rbind(df, WOE(inData, splitCol, range[i,], tgtCol, adjfac))
}

But I don’t like for-loop… I want to make it simpler.
So I also have tried to use mapply like this:

 mapply(t(WOR, list(inData), list(splitCol), split(range, nrow(range)), list(tgtCol), list(adjfac))

but the above line doesn’t return a data frame as I want, it return a data frame of a lot of lists, which is very difficult for me to do further calculation.

Does anyone have suggestions for me to aggregate my for-loop into less lines?
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:19:17+00:00Added an answer on June 14, 2026 at 5:19 pm
    do.call(rbind, lapply(1:nrow(range), function(i) WOE(inData, splitCol, range[i,], tgtCol, adjfac)))
    

    I often use this idiom when I want precise control over how results from an “apply” operation are combined. This way I don’t have to remember what the rules for automatic simplification are (i.e. sapply or mapply with simplify=TRUE).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a function that can wrap any other function call.
I have function getCartItems in cart.js and I want to call that function in
I have a C program which has a function call that is defined in
I have a variable that I'm using to build a JavaScript function call, and
I have a function that needs to call a virtual method many times in
I have a function call in a program that I'm maintaining has 28 arguments
I have a function call in a query, and that result has to be
I have a function that I call with ?clear-cart appended to the end of
So I have a function call classifier that basically check all text file in
My issue is that I have a function call it function1 which runs indefinitely.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.