_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
FrontPage › 讌覦讌Loop

install.packages("lubridate")
install.packages("strinr")
library("lubridate")
library("stringr")
library("RODBC")

bdt <- as.POSIXlt("2013-03-28 00:00:00", format="%Y-%m-%d %H:%M:%S")
loopset <- seq(bdt, as.POSIXlt("2013-04-05 00:00:00"), by=3600)

for(i in loopset)
{
  tmp <- as.POSIXlt(i, origin="1970-01-01")
  ymd <- format(tmp, format="%Y-%m-%d")
  hh <- str_sub(str_replace(paste("00", hour(tmp)), " ", ""), -2, -1)
  #mi <- str_sub(str_replace(paste("00", minute(tmp)), " ", ""), -2, -1)
  #dt <- paste(ymd, " ", hh, ":", mi, ":00", sep = "")
  #print(dt)
  
  sql1 <- paste(
    "select acnt1, acnt2 ",
    "from temp.dbo.sna_animal ",
    "where std_dt = '",ymd,"' ",
    "and hh = '", hh, "'",
    sep = "")
  
  #print(sql1)
  edgelist <-  sqlQuery(conn, sql1)
  g <- graph.data.frame(edgelist, directed=T)
    
  sql2 <- paste(
    "insert temp.dbo.sna_result_01 values(",
    "'", dt, "',",
    graph.density(g), ",", 
    transitivity(g), ",", 
    reciprocity(g), ",",
    clusters(g, mode="strong")$no, ",'",
    hh, "')"
    , sep = "")
  
  print(sql2)
  sqlQuery(conn, sql2)
}
蠍 蠍郁鍵..
企: : るジ讓曙 襦螻豺 企Ν 譯殊語. 襦螻豺
EditText : Print : Mobile : FindPage : DeletePage : LikePages : Powered by MoniWiki : Last modified 2018-04-13 23:12:52

豺蟲襯 視 觜蟆一 豺蟲 螳 蟆企. (覯 覯)