[R-sig-Geo] error "not a numeric vector" when use function "localG"
Roger Bivand
Roger.Bivand at nhh.no
Thu Mar 12 22:16:01 CET 2009
On Thu, 12 Mar 2009, Huang Juying wrote:
> Dear list members,
>
> I am a new R user and spdep user. I tried to use function "localG" to
> calculate Getis Gi. My targeted variable is log(SalePrice) for over 1000
> houses. The listw is the number of neighbors within 3000m.
>
>> SalePrice.Gi <- localG(SalePrice, nb3000m.W, zero.policy=TRUE)
>
> Then I got this error:? SalePrice is not a numeric vector
When you don't know how the object of interest actually got represented in
the workspace, try str(), here str(SalePrice). It may be that this is a
factor (because the decimal sign wasn't what you thought, as Marcelino
already suggested). It may also be that you did SalePrice <- read.csv(),
in which case it is a data frame, with column(s). If so, look for its
names(), and use the one you need, such as SalePrice$var1. The str()
digest method is very powerful for browsing objects, and has extra
arguments when the output is too voluminous.
Roger
>
> I don't understand why. All SalePrice data is numeric, with 6 decimal
> precision. I tried to import SalePrice from .dat or .txt or .csv file,
> but got the same error. I tried to play with the header and column/row
> argument, still no use.
>
> I am really frustrated. I guess there is a simple solution, but I just
> cannot find it!!! Please help me! Thank you in advance!
>
> Christina
> USC Geography department
>
>
>
>
>
> [[alternative HTML version deleted]]
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list