[R] remove failure

Duncan Murdoch murdoch.duncan at gmail.com
Sun Sep 1 21:30:33 CEST 2013


On 13-09-01 12:46 PM, Rguy wrote:
> Platform: Windows 7, "R version 3.0.1 Patched (2013-06-19 r62992)"
>
> I have been running the following code (part of a larger program) for many
> months without problem:
>
>   if ((gname %in% ls(envir=.GlobalEnv)) & !is.null(cols)) {
>   if (!identical(cols, names(get(gname, envir=.GlobalEnv)))) remove(gname,
> envir=.GlobalEnv)
> }
>
> For some reason today I started to get the following error:
>
> Error in remove(gname, envir = .GlobalEnv) :
>    (converted from warning) object 'gname' not found

That tries to remove gname, not the variable whose name is stored in 
gname.  Use list=gname in the call to get what you want.

Duncan Murdoch

>
> The error is illogical as the call to remove can only occur if gname is in
> the global environment. Furthermore, when I go into the debugger and run
> gname %in% ls(envir=.GlobalEnv) manually the expression returns TRUE. When
> I manually inspect the output of ls(envir=.GlobalEnv) I find that the value
> of gname is, indeed, present.
>
> I have tried re-booting my machine, but the error recurs even after a
> re-boot.
>
> Any insight on this error would be appreciated.
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list