Error with "for" loop from the .GlobalEnv

Hi everybody,

I am new to the community here and not a programmer so the issue I am facing is a bit hard from me to solve and have been interesting my analysis for several days now.

The issue is that whenever I try to run a for loop (even a simple for a loop as

 for(i in 1:5) print(1:i)

I get an error message

# Error in check_reserved(for_var_name) : 
# could not find function "check_reserved"

I am aware now that this problem was because I had installed the package magicfor which interrupted the regular functionality of the for loop.

I have removed the package and restarted the program and still getting the same message. The surprise is that if I applied this simple loop in R directly, it works fine without any problems.

I am sure that others have face this situation before but I could not find how did they solve it.

Ahmed Osman

Can you say more about the indirect way that you are running the code?

The indirect way is applying the code in Rstudio.
I am using Rstudio as interface for R. So I wanted to know if the problem is from R or from Rstudio.
So I applied the simple for loop above to R and it worked fine.

I just got around the for loop using while loop but I want to fix for loop for future use

What method of 'restart' of rstudio did you use?
If your global options are set to restore your state, then it likely won't work. Use ctrl shift f10 to restart R.

This topic was automatically closed 21 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.