Advertisement
Guest User

jhnfjhg

a guest
Mar 11th, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 1.84 KB | None | 0 0
  1. library("DBI", lib.loc="~/R/win-library/3.2");
  2. library("tcltk", lib.loc="C:/Program Files/R/R-3.2.0/library");
  3. library("RPostgreSQL", lib.loc="~/R/win-library/3.2");
  4. library("sqldf", lib.loc="~/R/win-library/3.2");
  5. library("stats", lib.loc="C:/Program Files/R/R-3.2.3/library");
  6.  
  7.  
  8.  
  9. options(sqldf.RPostgreSQL.user ="postgres",
  10.         sqldf.RPostgreSQL.password ="iq00mocb",
  11.         sqldf.RPostgreSQL.dbname ="postgres1",
  12.         sqldf.RPostgreSQL.host ="localhost",
  13.         sqldf.RPostgreSQL.port =5432 )
  14.  
  15. station = "'UKOO'";
  16. qry = paste( "SELECT wind_speed, x_decartes, y_decartes  FROM statistics WHERE EXTRACT( MONTH FROM date )::INTEGER IN (1,2,12)  AND station_number = ", station, sep="" );
  17.  
  18.   myTable <- sqldf( qry );
  19.  
  20.   print(qry);
  21.  
  22.  
  23. correlation = cor(myTable$x_decartes, myTable$y_decartes, use = "complete" )
  24. m_x = mean(myTable$x_decartes, na.rm=TRUE)
  25. m_y = mean(myTable$y_decartes, na.rm=TRUE)
  26. sigma_x = sd(myTable$x_decartes, na.rm=TRUE)
  27. sigma_y = sd(myTable$y_decartes, na.rm=TRUE)
  28. variance_x = var(myTable$x_decartes, na.rm=TRUE)
  29. variance_y = var(myTable$y_decartes, na.rm=TRUE)
  30. variance_rw = var(myTable$wind_speed, na.rm=TRUE)
  31.  
  32. m1r= (2*(sqrt(3.14))*variance_x*variance_y) / ((variance_x+variance_y)^(3/2))
  33. m1r2 = ((sqrt(3.14/2))*(sqrt(sigma_x*sigma_y)))
  34.  
  35. one = 4*variance_x*sigma_x*variance_y*sigma_y
  36. two = (3.14*sigma_x*sigma_y)/(variance_x+variance_y)
  37. three = 2- two
  38. variance_r = (one*three) / ((variance_x+variance_y)*(variance_x+variance_y))
  39. variance_r1 = (sigma_x*sigma_y)*((4-3.14)/2)
  40.  
  41. m_w = mean(myTable$wind_speed, na.rm=TRUE)
  42. sigma_r = sd(myTable$wind_speed, na.rm=TRUE)
  43.  
  44.  
  45.  
  46.  
  47.  
  48. #print(m_w)
  49. #print(variance_rw)
  50.  
  51.  
  52. #print(m1r)
  53. #print(m1r2)
  54.  
  55. #print(variance_r)
  56. #print(variance_r1)
  57.  
  58. #print(m_x)
  59. #print(m_y)
  60.  
  61. print(variance_x)
  62. print(variance_y)
  63. #print(correlation)
  64.  
  65. print(sigma_x)
  66. print(sigma_y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement