2018年6月18日月曜日

get UNDCONTSA data from www.census.gov


Download "the total number housing under construction" from here.

  1. choose "New Residential Construction"
  2. "1970 from 2018"
  3. choose "Housing Units under Construction"
  4. "Total Units" and "United States"

Open CSV file and chop unnecessary lines at header and footer. The result must be like below.


Period,Value
Jan-1970,889
Feb-1970,888
Mar-1970,890
<.........>
Mar-2018,1124
Apr-2018,1124


When file name is "~/iCloud/R/UC-1970-2018.csv" and contains data from 1970-04-01 to 2018-04-01.

as.xts(read.csv("~/iCloud/R/UC-1970-2018.csv")[,2],seq(as.Date("1970-01-01"),as.Date("2018-04-01"),by="months"))

The below calculate data length and the date of termination accordingly.

as.xts(read.csv("~/iCloud/R/UC-1970-2018.csv")[,2],as.Date(seq(mondate(as.Date("1970-01-01")),mondate(as.Date("1970-01-01"))-1+length(read.csv("~/iCloud/R/UC-1970-2018.csv")[,2]))))


           [,1]
1970-01-01  889
1970-02-01  888
1970-03-01  890
<snipet>
2018-03-01 1124
2018-04-01 1124

0 件のコメント: