How to make loop for one-at-a time logistic regression in R

0 votes
The question concerns the practical difference between the == and %in% operators in R.

I have run into an instance at work where filtering with either operator gives different results (e.g. one results on 800 rows, and the other 1200). I have a problem in the past and am able to validate that ensures I get the results I desire. However, I am still stumped regarding how they are different.
Jun 1, 2022 in Data Science by avinash
• 1,840 points
1,065 views

1 answer to this question.

0 votes
You're probably looking for something similar to this:

glm(as.formula(paste0('casecontrol ', 'rs', I data = mydata, family = binomial)) lapply(1:30, function(i) glm(as.formula(paste0('casecontrol ', 'rs', I data = mydata, family = binomial))

This command will run 30 logistic regressions with the chosen predictor.

Rather of hard-coding the total number of predictors, use sum(grepl('rs', names(mydata)), which returns 30.

To get the summary in a tidy format, use the tidy function from the broom package.

data.frame(model = I tidy(glm(as.formula(paste0('casecontrol ', 'rs', I data = mydata, family = binomial))) purrr::map dfr(1:30, function(i) data.frame(model = I tidy(glm(as.formula(paste0('casecontrol ', 'rs', I
answered Jun 20, 2022 by Sohail
• 3,040 points

Related Questions In Data Science

0 votes
0 answers

how to make 2 separate substrings from strsplit in R

When it comes to accessing the elements ...READ MORE

Jun 13, 2022 in Data Science by Avinash
• 1,260 points
318 views
0 votes
0 answers

In R, how to get an object's name after it is sent to a function?

I'm trying to find the opposite of ...READ MORE

Jul 5, 2022 in Data Science by avinash
• 1,840 points
307 views
0 votes
0 answers

How to manually find the minors of a matrix in R programming?

I have to write a function that ...READ MORE

Jul 5, 2022 in Data Science by avinash
• 1,840 points
473 views
0 votes
0 answers

How to read a csv-file from an url in R?

I'm not very experienced with R, so ...READ MORE

Jul 22, 2022 in Data Science by avinash
• 1,840 points
666 views
0 votes
1 answer

Difference between the == and %in% operators in R

percent in percent "returns a vector of ...READ MORE

answered Jun 20, 2022 in Data Science by Sohail
• 3,040 points
745 views
0 votes
1 answer

Difference between the == and %in% operators in R

According to help('percent in percent'), percent in ...READ MORE

answered Jun 23, 2022 in Data Science by Sohail
• 3,040 points
513 views
0 votes
1 answer
0 votes
0 answers

Understanding the result of modulo operator: %%

Just trying to understand how the %% ...READ MORE

Jun 2, 2022 in Others by avinash
• 1,840 points
299 views
0 votes
1 answer

How To Create Vector of Vector In R

Create a list: List() on x returns x[[1]] ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
494 views
0 votes
1 answer

How to overlay density plots in R?

The second one has 104 usage lines: plot(density(MyData$Column1)) ...READ MORE

answered Jun 24, 2022 in Data Science by Sohail
• 3,040 points
1,026 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP