[R-sig-Geo] stConstruct returning error message "undefined columns selected"

Laura Cabral lcabral at ualberta.ca
Fri May 4 21:33:27 CEST 2018


Hello,

I have been following the R documentation for stConstruct {spacetime} to make my own spacetime object from a long table (Data_Sept5). The space ID is stored in the Location column (char) and the time is stored in Datetime as POSIXct. The data of interest is Prop_Strava, and since only some spacetime values are available, this should generate a STIDF object 

> head(Data_Sept5)
                       Location            Datetime Count_Mio Edge_ID Count_Strava Prop_Strava
1 100 Avenue West of 106 Street 2017-09-05 00:00:00         2   54789           NA          NA
2 100 Avenue West of 106 Street 2017-09-05 01:00:00         2   54789           NA          NA
3 100 Avenue West of 106 Street 2017-09-05 02:00:00         0   54789           NA          NA
4 100 Avenue West of 106 Street 2017-09-05 03:00:00         1   54789           NA          NA
5 100 Avenue West of 106 Street 2017-09-05 04:00:00         0   54789           NA          NA
6 100 Avenue West of 106 Street 2017-09-05 05:00:00         1   54789           NA          NA

The spatial object is a SpatialPointsDataFrame loaded from a shapefile using readOGR, called Counters. Counters contains 13 observations of one variable (Name) which corresponds to the locations names in Data_Sept5 as shown above.

I used this line to generate the spacetime object, however, it generates the error shown below:

ST_Sept5<-stConstruct(Data_Sept5, "Location", "Datetime", Counters, interval = T)

Error in `[.data.frame`(x at data, i, j, ..., drop = FALSE) : 
  undefined columns selected

Any idea what might be the cause? As far as I call tell, all my data is equivalent to the example given in the stConstruct R documentation. I also tried giving the column index instead of the name, but received the same error.

Thank you for your help,

Laura Cabral

 

MSc Candidate in Transportation Engineering

Dept of Civil and Environmental Engineering

University of Alberta

lcabral at ualberta.ca <mailto:lcabral at ualberta.ca>
819 993-1901


The University of Alberta is located in ᐊᒥᐢᑿᒌᐚᐢᑲᐦᐃᑲᐣ (Amiskwacîwâskahikan) on Treaty 6 territory, homeland of the Papaschase and the Métis Nation


	[[alternative HTML version deleted]]



More information about the R-sig-Geo mailing list