[STATSGRASS] Help - Inconsistent behavior, GRASS/R win/mac
Roger Bivand
Roger.Bivand at nhh.no
Thu May 12 05:03:31 EDT 2005
On Wed, 11 May 2005, Gregory Booma wrote:
> Answering my own post:
>
> Quoting Gregory Booma <gcb2101 at columbia.edu>:
>
> > The script runs fine on .dbf and
> > .csv files created in ArcGIS 9.0 and Excel on Windows XP, but not
> > on those created in GRASS 6.0 and Excel on MacOSX 10.3.9.
>
> This is wrong. It turns out that the error is in my 'order' line in
> the script. The two Windows files I was using had been pre-ordered,
> allowing the script to run just fine.
Well spotted! These kinds of things do happen, and only care can help. In
the sp package in R, we'll be trying to make sure the geometry objects get
associated with the correct rows in the attribute data frames, but this
isn't in place yet. Your question reinforces the need to provide help
within the objects themselves.
>
> The solution is to save the ordered data.frame as an object, as
> follows:
>
> attach(df)
> newdf <- df[order(POVID,-AREA),]
> freqtable <- as.data.frame(table(newdf$POVID))
>
> for (i in 1:nrow(freqtable)){
> match <- which(newdf$POVID==freqtable$Var1[i])
> for (j in 1:length(match)){
> newdf$newid[match[j]] <- as.integer(newdf$POVID[match[j]]*10+j)
> }
> }
>
> Note that I included attach() in the script this time. Just easier
> than having to remember.
>
> Hope this is useful,
>
> Greg
>
>
>
> _______________________________________________
> statsgrass mailing list
> statsgrass at grass.itc.it
> http://grass.itc.it/mailman/listinfo/statsgrass
>
--
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 grass-stats
mailing list