For loop in R programming

0 votes

Hi Guys,

I want to create a loop in R. But I don't know the syntax for a loop. How can I do that?

Oct 6, 2020 in Data Analytics by akhtar
• 38,170 points
72 views

1 answer to this question.

0 votes

Hi@akhtar,

You can create a loop in R in the same way. This below structure is used when a loop is to be executed a fixed number of times. It is commonly used for iterating over the elements of an object (list, vector).

for(i in 1:4){
     print (y[i])
}
answered Oct 6, 2020 by MD
• 95,160 points

Related Questions In Data Analytics

0 votes
2 answers

Installing MXNet for R in Windows System

You can install it for python in ...READ MORE

answered Dec 3, 2018 in Data Analytics by Kalgi
• 52,310 points
964 views
0 votes
1 answer

AUC for 3-Class prediction in R

Use type='probs' inside predict() function, so that ...READ MORE

answered Apr 4, 2018 in Data Analytics by Bharani
• 4,620 points
479 views
0 votes
1 answer

What are the options for deploying models in production with R?

Well, I could say that the answer ...READ MORE

answered Apr 12, 2018 in Data Analytics by DataKing99
• 8,240 points
785 views
0 votes
2 answers

How to use group by for multiple columns in dplyr, using string vector input in R?

data = data.frame(   zzz11def = sample(LETTERS[1:3], 100, replace=TRUE),   zbc123qws1 ...READ MORE

answered Aug 5, 2019 in Data Analytics by anonymous
9,922 views
+1 vote
1 answer

Can we have an if loop inside a for loop in R programming?

You're If loop doesn't have any condition ...READ MORE

answered Dec 21, 2018 in Data Analytics by Sophie may
• 10,550 points
111 views
0 votes
1 answer

Error in library(randomForest) : there is no package called ‘randomForest’

Hi@akhtar, You need to install the library in ...READ MORE

answered Oct 6, 2020 in Data Analytics by MD
• 95,160 points
591 views
0 votes
1 answer

Error in library(Metrics) : there is no package called ‘Metrics’

Hi@akhtar, The matrics library is not available in ...READ MORE

answered Oct 6, 2020 in Data Analytics by MD
• 95,160 points
443 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
1,251 views
+4 votes
3 answers

How to sum a variable by group in R?

You can also try this way, x_new = ...READ MORE

answered Jul 31, 2019 in Data Analytics by Cherukuri
• 32,930 points
59,177 views
+1 vote
2 answers

Which function can I use to clear the console in R and RStudio ?

Description                   Windows & Linux           Mac Clear console                      Ctrl+L ...READ MORE

answered Apr 17, 2018 in Data Analytics by anonymous
29,194 views