Do I need to create a loop, or a function?

Well, I have 27 variables that I need to analyze in the exactly same way. It's about a Likert Scale with 27 questions, that I will run a Kruskal-Wallis test for each one of them. Actually, I will do more than Kruskal-Wallis.

So, I would just do the same thing 27 times, just changing the variables.

But I thought to myself "there's any way I could just do it one time, and then the R would just do the same thing applying the other variables?"

So, I thought about loops or creating functions. I don't know about both, but I will learn if I need to.

So, do you guys know something about it? It's probably recurrent for the ones who analyze a lot of data.

Can anyone tell me what should I do, please?

Thanks in advance :slight_smile:

Hope this helps!

1 Like

The Iteration chapter in R for Data Science goes in-depth on this.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.