Hello, i don't know how to make a for loop to show the population from 1952~2007
i made like that way. but it totally wrong.
can i get a hint or solution?
You've been given the correct answers. Lets have a look at why yours doesn't work.
1] for does not take a data argument. data %>% func(x,y,z) is equivalent to func(data, x, y, z). So what you wrote is equivalent to for (gapminder, i in 1952:2007) which makes no sense.
2] i==num(i) is a tautology. i is taken from a range of integers (1952:2007), so it is always an integer and will always match itself cast as double precision floating point number (numeric), regardless of what the actual number is.
3] your code does not subset the dataframe anywhere.
Maybe you should familiarize yourself more with basic R and get the step-by-step logic fundamentals clear in your head before rushing to do
more complex stuff with dplyr.
For future reference, you should include any warning and error messages your code causes when asking for help.