[R-sig-Geo] Error slot

Roger Bivand Roger.Bivand at nhh.no
Mon Aug 22 09:36:37 CEST 2011


On Sun, 21 Aug 2011, Gaspar Reyes Póndigo wrote:

> Hi, Dear R-SIG-GEO User
>
> I am new user R 2.13 (spgrass6) from GRASS-GIS 6.4.1-5, under Mac OS X 
> 10.68. I have the following problem, when preparing the data before run 
> R's princomp() function in R from GRASS, there was an error. The line of 
> code is copied below:
>

Please only post to one list at a time, and wait patiently for an answer.


>
> #########################################
> library(spgrass6)
>
> G <- gmeta6()
>
> ATC <- > readRAST6(c('Acrf_1993_b1','Acrf_1993_b2','Acrf_1993_b3','Acrf_1993_b4','Acrf_1993_b5','Acrf_1993_b7'))
>
> ATC.nas <- which(is.na(ATC at data$Acrf_1993_b1) & is.na(ATC at data$Acrf_1993_b2) & is.na(ATC at data$Acrf_1993_b3) & is.na(ATC at data$Acrf_1993_b4) & is.na(ATC at data$Acrf_1993_b5) & is.na(ATC at data$Acrf_1993_b7))
>

Never access columns with ... at data$... which is exactly the same as 
...$...

> ATC.ms.values <- which(!is.na(ATC at data$Acrf_1993_b1) & !is.na(ATC at data$Acrf_1993_b2) & !is.na(ATC at data$Acrf_1993_b3) & !is.na(ATC at data$Acrf_1993_b4) & !is.na(ATC at data$Acrf_1993_b5) & !is.na(ATC at data$Acrf_1993_b7))
>
> #######################################
> ####  I got the following error message
> #######################################
> ATC.ms.nonas <- ATC.ms.values at data[ATC.ms.values, ]

str(ATC.ms.values) is certainly integer. I believe that you want to say 
either (may need casting to SpatialPixelsDataFrame first):

ATC.ms.nonas <- ATC[ATC.ms.values,]

or

ATC.ms.nonas <- as(ATC, "data.frame")[ATC.ms.values,]


> Error: tentativa de obtener un slot "data" de un objeto de una clase 
> básica ("integer") sin slots

which is very clear. Do use str() or class() to check the objects you are 
using.

Roger

> #########################################
>
> Can you please point my problem? and How do I fix my problem?
> Thanks in advance for any help.
>
> NOTE:I followed the guide of http://grass.osgeo.org/wiki/Principal_Components_Analysis # Using_R.27s_princomp.28.29_function for  PRINCOMP() function.
> NOTE: the images are LANDSAT 5 TM
>
>
> Gaspar Reyes Póndigo
> Universidad del Mar, Oaxaca, México
> Campus Puerto-Ángel
> Carretera principal Puerto Ángel Zipolite km 1.5
> C.P. 70902
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Department of Economics, NHH Norwegian School of Economics,
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