I created an object in with a for loop, inside a function, but get error in print object not found when trying to print it

前端 未结 1 456
感情败类
感情败类 2021-01-28 03:08

I\'ve created an object obs in the loop shown below and the loop returns obs. However when I try to print obs i get the message that obs is not found. I\'m new to programming R

相关标签:
1条回答
  • 2021-01-28 03:41

    Objects defined in a function are not available outside the function. If you return a value from a function, you must store the result somewhere. Try

    obs <- complete("specdata", ID<-c(2,4,8,10,12))
    print(obs)
    

    This prevents you from having to know the name of variables inside function that you may not have written yourself.

    0 讨论(0)
提交回复
热议问题