_ | 覦覈襦 | 豕蠏手 | 殊螳 | 譯殊碁
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

一 レ . 蠏碁覃 轟蟆 る 螳 殊 襷 襷譟煙る 蟆企. 豺蟲れ 轟 襦 轟 蠏碁れ蟆 譴る 轟 螻 至鍵 蠏碁れ 襦 譬 豺蟲れ 譴 蟆企. 襦燕襦郁 襷 豺蟲襯 螳讌る 豺蟲螳 企. (企 るΠろ "蟆壱狩讌 讀蟇一"筝)