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 in Data Science by avinash
• 940 points
21 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 by Sohail
• 2,960 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 in Data Science by Avinash
• 1,260 points
5 views
0 votes
1 answer

How to implement Knn-algorithm without using k-nn function in r?

I created an example that demonstrates the ...READ MORE

answered Jun 24 in Data Science by Sohail
• 2,960 points
8 views
0 votes
1 answer

grepl in R to find matches to any of a list of character strings

Inside of a grepl regular expression, you ...READ MORE

answered Jun 24 in Data Science by Sohail
• 2,960 points
7 views
0 votes
0 answers
0 votes
1 answer

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

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

answered Jun 20 in Data Science by Sohail
• 2,960 points
16 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 in Data Science by Sohail
• 2,960 points
11 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 in Others by avinash
• 940 points
21 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 in Data Science by Sohail
• 2,960 points
11 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 in Data Science by Sohail
• 2,960 points
17 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP