Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library("DBI", lib.loc="~/R/win-library/3.2");
- library("tcltk", lib.loc="C:/Program Files/R/R-3.2.0/library");
- library("RPostgreSQL", lib.loc="~/R/win-library/3.2");
- library("sqldf", lib.loc="~/R/win-library/3.2");
- library("stats", lib.loc="C:/Program Files/R/R-3.2.3/library");
- options(sqldf.RPostgreSQL.user ="postgres",
- sqldf.RPostgreSQL.password ="iq00mocb",
- sqldf.RPostgreSQL.dbname ="postgres1",
- sqldf.RPostgreSQL.host ="localhost",
- sqldf.RPostgreSQL.port =5432 )
- station = "'UKOO'";
- 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="" );
- myTable <- sqldf( qry );
- print(qry);
- correlation = cor(myTable$x_decartes, myTable$y_decartes, use = "complete" )
- m_x = mean(myTable$x_decartes, na.rm=TRUE)
- m_y = mean(myTable$y_decartes, na.rm=TRUE)
- sigma_x = sd(myTable$x_decartes, na.rm=TRUE)
- sigma_y = sd(myTable$y_decartes, na.rm=TRUE)
- variance_x = var(myTable$x_decartes, na.rm=TRUE)
- variance_y = var(myTable$y_decartes, na.rm=TRUE)
- variance_rw = var(myTable$wind_speed, na.rm=TRUE)
- m1r= (2*(sqrt(3.14))*variance_x*variance_y) / ((variance_x+variance_y)^(3/2))
- m1r2 = ((sqrt(3.14/2))*(sqrt(sigma_x*sigma_y)))
- one = 4*variance_x*sigma_x*variance_y*sigma_y
- two = (3.14*sigma_x*sigma_y)/(variance_x+variance_y)
- three = 2- two
- variance_r = (one*three) / ((variance_x+variance_y)*(variance_x+variance_y))
- variance_r1 = (sigma_x*sigma_y)*((4-3.14)/2)
- m_w = mean(myTable$wind_speed, na.rm=TRUE)
- sigma_r = sd(myTable$wind_speed, na.rm=TRUE)
- #print(m_w)
- #print(variance_rw)
- #print(m1r)
- #print(m1r2)
- #print(variance_r)
- #print(variance_r1)
- #print(m_x)
- #print(m_y)
- print(variance_x)
- print(variance_y)
- #print(correlation)
- print(sigma_x)
- print(sigma_y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement