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

  • Home
  • SEARCH
  • 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 9279913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:44:42+00:00 2026-06-18T17:44:42+00:00

In the reproducible code below (last line), the ‘update’ function doesn’t work if I

  • 0

In the reproducible code below (last line), the ‘update’ function doesn’t work if I replace ‘Income’ with ‘fieldToRemove’. How can I make this function work? I need to run that line in loop.

state.x77                          
tmpData = as.data.frame(state.x77) 
colnames(tmpData)[4] = "Life.Exp"  
colnames(tmpData)[6] = "HS.Grad"
cnames = colnames(tmpData)
cnames
lenCnames = length(cnames)

rhsOfFormula = paste(cnames[1:(length(cnames)-1)],collapse= "+")
lhsOfFormula = cnames[length(cnames)]
(fmla <- as.formula(paste(lhsOfFormula , " ~ ", rhsOfFormula )) )
modelTmp <- glm(formula = fmla, data=tmpData)

fieldToRemove = 'Income'
newModel <- update(modelTmp, .~.-Income )
  • 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-18T17:44:43+00:00Added an answer on June 18, 2026 at 5:44 pm

    update expects a formula as the second argument, so you have to use the same trick you used earlier: as.formula:

    newModel <- update(modelTmp, as.formula(paste(".~.-", fieldToRemove)) )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is the complete reproducible code. <?php class console{ public static function log($msg, $arr=array()){
Reproducible example below. I have a simulation loop, within which I occasionally have rows
Given the stress toward reproducible science, I was wondering if my recent work warrants
I am seeking some simple (i.e. - no maths notation, long-form reproducible code) examples
How can i get a series of reproducible pseudorandom numbers in PHP? In older
Update: Subject updated - this is now reproducible on EF 4.3.1 under .NET 4
As the termplot function in R is containing some weird code that is giving
Reproducible code: library(quantmod) getSymbols('SPY', from = '1950-01-01') Y <- Cl(to.monthly(SPY)) start <- c(1993, 1)
Here's my code: a function to be optimized with DEoptim algorithm; the function is
The only available reproducible example I can find to share with the board is

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.