[R-sig-Geo] get() in raster ?

Carson Farmer carson.farmer at gmail.com
Fri Nov 19 20:53:14 CET 2010


Agus, according to ?get, x should be a variable name (given as a
character string). So one *should* expect the behaviour that Matthew
describes:

> v = c("r1","r2","r3")
> v
[1] "r1" "r2" "r3"
> get(v)
Error in get(v) : object 'r1' not found
> get('v')
[1] "r1" "r2" "r3"

Carson


On 19 November 2010 19:41, Agustin Lobo <alobolistas at gmail.com> wrote:
> Thanks,
> Kind of weird, isn't it?
> I don't understand the behavior of get() in your case either. I would
> expect get(v) just returning the value of v, not going down to evaluate r1
>
> And you remind me I should have posted the result
> of sessionInfo():
>
>> v <- c("r1","r2","r3")
>> get(v)
> Loading required package: raster
> Loading required package: sp
> raster version 1.6-22 (17-November-2010)
> class       : RasterLayer
> nrow        : 18
> ncol        : 36
> ncell       : 648
> projection  : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
> xmin        : -180
> xmax        : 180
> ymin        : -90
> ymax        : 90
> xres        : 10
> yres        : 10
>> str(v)
>  chr [1:3] "r1" "r2" "r3"
>> sessionInfo()
> R version 2.12.0 (2010-10-15)
> Platform: i486-pc-linux-gnu (32-bit)
>
> locale:
>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C
>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8
>  [5] LC_MONETARY=C              LC_MESSAGES=en_US.UTF-8
>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C
>  [9] LC_ADDRESS=C               LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] raster_1.6-22 sp_0.9-72
>
> loaded via a namespace (and not attached):
> [1] grid_2.12.0     lattice_0.19-13
>>
>
>
>
> 2010/11/19 Matthew Landis <landis at isciences.com>:
>> On 11/19/2010 2:24 PM, Agustin Lobo wrote:
>>>
>>> Even not having loaded raster, it gets automatically loaded once I
>>> call get(). Is this a bug?
>>
>> Agus, that doesn't occur for me.  Here's what happens on my machine (and I
>> do have raster installed, but not loaded).   Note the difference in behavior
>> between get(v) and get('v') .
>>
>>> v = c("r1","r2","r3")
>>> v
>> [1] "r1" "r2" "r3"
>>> get(v)
>> Error in get(v) : object 'r1' not found
>>> get('v')
>> [1] "r1" "r2" "r3"
>>> sessionInfo()
>> R version 2.11.1 (2010-05-31)
>> x86_64-pc-mingw32
>>
>> locale:
>> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United
>> States.1252
>> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>> [5] LC_TIME=English_United States.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> loaded via a namespace (and not attached):
>> [1] tools_2.11.1
>>
>>
>> --
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~
>> Matthew Landis, Ph.D.
>> Research Scientist
>> ISciences, LLC
>> 61 Main St. Suite 200
>> Burlington VT 05401
>> 802.864.2999
>> ~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Carson J. Q. Farmer
ISSP Doctoral Fellow
National Centre for Geocomputation
National University of Ireland, Maynooth,
http://www.carsonfarmer.com/



More information about the R-sig-Geo mailing list