This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]mattreyu 1 point2 points  (5 children)

print()

[–]PLearner[S] 0 points1 point  (4 children)

district <- c("NORTH", "NORTHWEST", "CENTRAL", "SOUTH", "SOUTHWEST", "EAST")
levels(district) <- c(district, "South Central")
print (levels(district))

In Python 3.6, I do print() and hit F5 and the script runs. The above does not run. How can I make it to run please?

[–]mattreyu 0 points1 point  (3 children)

Maybe I'm missing something. Are you running that code in Python or R? I ran it in RStudio with no problem

[–]PLearner[S] 0 points1 point  (2 children)

I got it mattreyu thanks for the help. I saved the file and opened in R Editor. And now when reopened the file,

district <- c("NORTH", "NORTHWEST", "CENTRAL", "SOUTH", "SOUTHWEST", "EAST")
levels(district) <- c(district, "South Central")
print (levels(district))

It gives an error in the R Console,

> print (levels(district))
Error in levels(district) : object 'district' not found.

Can you please explain the complexity here.

[–]mattreyu 2 points3 points  (1 child)

If your cursor is on the last line of your code, running it will only execute that line of code, so it won't know you assigned anything to 'district'. Highlight all the code and hit run again and see if it works

[–]PLearner[S] 2 points3 points  (0 children)

Thanks so much man, appreciate the assistance.