(17 intermediate revisions by 3 users not shown) Line 1:
Line 1:
{{variable|moderator=Ehac}}
<math>
\alpha + 444444 + \beta + \omega
</math>
jepjepjepjep
[[:File:aditro.PNG]]
[[Image:kuvatiedostonmitähäan.jpg]]
	jepjep
<display_map type="terrain">
62.904602, 27.647781
62.891918, 27.680013
</display_map>
Wikitab
{{mfiles}}
http://ytoswww/yhteiset/YMAL/Projects/
<t2b index="Make" unit="kg" desc="Description">
Lata|100|
Toyota|88|Toijota
< /t2b>
Edited by ehacfff
{{variable|moderator=Ehac}}
math ei jekkase
mitä tapahtuu!
<math>
L_{Aeq} = 10 \log \int_{t_0}^{t_1} \frac{p_A^2(t)}{p_0^2} dt
</math>
<math>\alpha + 8884444</math>
<math>\alpha + 8884444</math>
Line 23:
Line 36:
</math>
</math>
== Live Code Test ==
<rcode live=1 graphics=1 name='live_test' variables='name:breaks|description:Breaks|options:10;10;20;20;35;35;50;50|type:selection|default:10'>
hist(faithful$eruptions,
probability = TRUE,
breaks = as.numeric(breaks),
xlab = "Duration (minutes)",
main = "Geyser eruption duration")
</rcode>
== Sotkanet ==
== Sotkanet ==
<rcode name='sotkanet_test'>
<rcode name='sotkanet_test'>
library(OpasnetUtils)
library(OpasnetUtilsExt)
library(OpasnetUtilsExt)
library(xtable)
# collect makes a data.frame out of the list object from Sotkanet
# collect makes a data.frame out of the list object from Sotkanet
Line 67:
Line 90:
e <- merge(d, e)
e <- merge(d, e)
print(xtable(e),type='html')
oprint (e)
</rcode>
</rcode>
Line 86:
Line 109:
<rcode embed="1" variables="name:test|type:table">
<rcode embed="1" variables="name:test|type:table">
library(xtable)
library(OpasnetUtils )
print(xtable(test),type='html', html.table.attributes="class='sortable'")
oprint (test)
</rcode>
</rcode>
Line 94:
Line 117:
<rcode>
<rcode>
library(OpasnetUtils)
library(OpasnetUtils)
a <- new("ovariable", output = data.frame(dummy=NA))
b <- new("ovariable", output = data.frame(a=1:4))
merge(a,b)
aa <- new("ovariable", output = data.frame(dummy=NA))
bb <- new("ovariable", output = data.frame(a=1:4))
#cc <- new("ovariable", output = data.frame(a=1:4))
cc <- ''
test <- Ovariable(
name='test',
dependencies = data.frame(
Name = c("aa", "bb", "cc"),
Ident = c(NA, NA, NA)
),
formula = function(dependencies, ...) {
ComputeDependencies(dependencies, ...)
out <- merge(aa , bb)
return(out)
}
)
oprint(test )
</rcode>
</rcode>
Line 109:
Line 152:
library(RColorBrewer)
library(RColorBrewer)
library(classInt)
library(classInt)
library(OpasnetBaseUtils)
library(OpasnetUtils)
library(OpasnetUtilsExt )
shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','kuopio_house')
shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','kuopio_house')
Line 178:
Line 222:
legend("topleft", legend=names(attr(colcode, "table")),title="Ika", fill=attr(colcode, "palette"), cex=1.0, bty="y",bg="white")
legend("topleft", legend=names(attr(colcode, "table")),title="Ika", fill=attr(colcode, "palette"), cex=1.0, bty="y",bg="white")
</rcode>
</rcode>
== Kuopio buildings on Google maps test ==
== Kuopio buildings on Google maps test ==
Line 189:
Line 231:
library(RColorBrewer)
library(RColorBrewer)
library(classInt)
library(classInt)
library(OpasnetBaseUtils)
library(OpasnetUtils)
library(OpasnetUtilsExt )
library(RODBC)
library(RODBC)
Line 265:
Line 308:
</rcode>
</rcode>
== GoogleMaps Sorvi MML TEST ==
== GoogleMaps Sorvi MML TEST ==
Line 271:
Line 313:
<rcode name='gmapspsqltest3'>
<rcode name='gmapspsqltest3'>
library(OpasnetBaseUtils)
library(OpasnetUtils)
library(OpasnetUtilsExt )
library(sorvi)
library(sorvi)
library(rgdal)
library(rgdal)
Line 306:
Line 349:
library(RColorBrewer)
library(RColorBrewer)
library(classInt)
library(classInt)
library(OpasnetBaseUtils)
library(OpasnetUtils)
library(OpasnetUtilsExt )
shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','watson_wkt')
shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','watson_wkt')
Line 336:
Line 380:
<rcode name='gmapspsqltest'>
<rcode name='gmapspsqltest'>
library('OpasnetBaseUtils')
library(OpasnetUtils)
cat("<span style='font-size: 1.2em;font-weight:bold;'>PostgreSQL Test</span>\n")
library(OpasnetUtilsExt )
cat("PostgreSQL Test\n")
google.show_data_on_maps()
google.show_data_on_maps()
Line 348:
Line 393:
<rcode name='opcsvtest'>
<rcode name='opcsvtest'>
library(OpasnetBaseUtils)
library(OpasnetUtils )
csv <- opasnet.csv("2/25/Russian_elections_2011_results.csv")
csv <- opasnet.csv("2/25/Russian_elections_2011_results.csv")
Line 359:
Line 404:
<rcode name='odabugstest' graphics=1>
<rcode name='odabugstest' graphics=1>
library(OpasnetBaseUtils)
library(OpasnetUtils )
pumps.model <- opasnet.data('c/cc/Test_bugs_model.txt')
pumps.model <- opasnet.data('c/cc/Test_bugs_model.txt')
Line 434:
Line 479:
name:divisions2|description:Minkä yhden tekijän halua eritellä kuvaajassa?|type:selection|options:'Katalyytin määrä';Katalyytin määrä;'Ikä';Ikä;'Kastelu';Kastelu;'Käytetty puristin';Käytetty puristin|default:'Kastelu'
name:divisions2|description:Minkä yhden tekijän halua eritellä kuvaajassa?|type:selection|options:'Katalyytin määrä';Katalyytin määrä;'Ikä';Ikä;'Kastelu';Kastelu;'Käytetty puristin';Käytetty puristin|default:'Kastelu'
">
">
library(OpasnetBaseUtils)
library(OpasnetUtils )
library(ggplot2)
library(ggplot2)
library(xtable)
library(xtable)
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \alpha + 444444 + \beta + \omega }
jepjepjepjep
File:aditro.PNG
File:Kuvatiedostonmitähäan.jpg
<display_map type="terrain">
62.904602, 27.647781
62.891918, 27.680013
</display_map>
<mfanonymousfilelist></mfanonymousfilelist>
mitä tapahtuu!
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \alpha + 8884444}
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \textstyle L_{Aeq} = 10 \log \int_{t_0}^{t_1} \frac{p_A^2(t)}{p_0^2} dt }
Live Code Test
Sotkanet
Objects save test
Giving tables via user interface
ovariable merge testing
Static GoogleMaps test
+ Show code - Hide code
#code goes here
library(RgoogleMaps)
library(rgdal)
library(maptools)
library(RColorBrewer)
library(classInt)
library(OpasnetUtils)
library(OpasnetUtilsExt)
shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','kuopio_house')
plotvar<-shp@data$ika
nclr<-8
plotclr<-brewer.pal(nclr,"Spectral")
class<-classIntervals(plotvar,nclr,style="quantile")
colcode<-findColours(class,plotclr)
epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
proj4string(shp)<-("+init=epsg:3067")
shp2<-spTransform(shp,epsg4326String)
#get marker information first 10 points
mymarkers<-cbind.data.frame(lat=c(shp2@coords[,2]),lon=c(shp2@coords[,1]),color=colcode);
#get the bounding box:
bb <- qbbox(lat = mymarkers[,"lat"], lon = mymarkers[,"lon"])
#MyMap function without the "file destination" parameter
MyRmap<-function (lonR, latR, center, size = c(640, 640),
MINIMUMSIZE = FALSE, RETURNIMAGE = TRUE, GRAYSCALE = FALSE,
NEWMAP = TRUE, zoom, verbose = 1, ...)
{
if (missing(zoom))
zoom <- min(MaxZoom(latR, lonR, size))
if (missing(center)) {
lat.center <- mean(latR)
lon.center <- mean(lonR)
}
else {
lat.center <- center[1]
lon.center <- center[2]
}
if (MINIMUMSIZE) {
ll <- LatLon2XY(latR[1], lonR[1], zoom)
ur <- LatLon2XY(latR[2], lonR[2], zoom)
cr <- LatLon2XY(lat.center, lon.center, zoom)
ll.Rcoords <- Tile2R(ll, cr)
ur.Rcoords <- Tile2R(ur, cr)
if (verbose > 1) {
cat("ll:")
print(ll)
print(ll.Rcoords)
cat("ur:")
print(ur)
print(ur.Rcoords)
cat("cr:")
print(cr)
}
size[1] <- 2 * max(c(ceiling(abs(ll.Rcoords$X)), ceiling(abs(ur.Rcoords$X)))) +
1
size[2] <- 2 * max(c(ceiling(abs(ll.Rcoords$Y)), ceiling(abs(ur.Rcoords$Y)))) +
1
if (verbose)
cat("new size: ", size, "\n")
}
return(GetMap(center = c(lat.center, lon.center), zoom = zoom,
size = size, RETURNIMAGE = RETURNIMAGE,
GRAYSCALE = GRAYSCALE, verbose = verbose, ...))
}
MyMap<-MyRmap(bb$lonR,bb$latR,maptype="mobile")
PlotOnStaticMap(MyMap)
PlotOnStaticMap(MyMap,lat=mymarkers[,"lat"],lon=mymarkers[,"lon"],pch=19,cex=0.3,col=colcode,add=T)
legend("topleft", legend=names(attr(colcode, "table")),title="Ika", fill=attr(colcode, "palette"), cex=1.0, bty="y",bg="white")
Kuopio buildings on Google maps test
+ Show code - Hide code
library(rgdal)
library(maptools)
library(RColorBrewer)
library(classInt)
library(OpasnetUtils)
library(OpasnetUtilsExt)
library(RODBC)
shp <- spatial_db_query(paste('SELECT * FROM kuopio_house WHERE ika >= ',age,';',sep=''))
coordinates(shp)=c("y_koord","x_koord")
#shp<-readOGR('PG:host=localhost user=postgres dbname=spatial_db','kuopio_house')
plotvar<-shp@data$ika
nclr<-8
plotclr<-brewer.pal(nclr,"BuPu")
class<-classIntervals(plotvar,nclr,style="quantile")
colcode<-findColours(class,plotclr)
epsg4326String <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")
proj4string(shp)<-("+init=epsg:3067")
shp2<-spTransform(shp,epsg4326String)
kmlname<-"Kuopio house data"
kmldescription<-"Random stuff about here"
icon<-"http://maps.google.com/mapfiles/kml/pal2/icon18.png"
name<-paste("Value: ",shp2$ika)
description <- paste("<b>Ikä:</b>",shp2$ika,"<br><b>Rakennustunnus:</b>",shp2$rakennustunnus)
MyPointKML<-function(obj = NULL, kmlname = "", kmldescription = "", name = NULL, description = "", icon = "http://maps.google.com/mapfiles/kml/pal4/icon24.png",col=NULL)
{
if (is.null(obj))
return(list(header = c("<?xml version=\"1.0\" encoding=\"UTF-8\"?>",
"<kml xmlns=\"http://earth.google.com/kml/2.2\">",
"<Document>", paste("<name>", kmlname, "</name>",
sep = ""), paste("<description><![CDATA[", kmldescription,
"]]></description>", sep = "")), footer = c("</Document>",
"</kml>")))
if (class(obj) != "SpatialPointsDataFrame")
stop("obj must be of class 'SpatialPointsDataFrame' [package 'sp']")
if (is.null(name)) {
name = c()
for (i in 1:nrow(obj)) name <- append(name, paste("site",
i))
}
col2kmlcolor <- function(col) paste(rev(sapply(col2rgb(col, TRUE), function(x) sprintf("%02x", x))), collapse = "")
kml <- kmlStyle <- ""
kmlHeader <- c("<?xml version=\"1.0\" encoding=\"UTF-8\"?>","<kml xmlns=\"http://earth.google.com/kml/2.2\">", "<Document>")
kmlFooter <- c("</Document>", "</kml>")
for (i in 1:nrow(obj)) {
point <- obj[i, ]
pt_name = name[i]
pt_description = description[i]
pt_style <- paste("#style", ifelse(length(icon) == 1, 1, i), sep = "")
kml <- append(kml, "<Placemark>")
kml <- append(kml, paste(" <description><![CDATA[",pt_description, "]]></description>", sep = ""))
#kml <- append(kml, "<Style><IconStyle>")
#kml <- append(kml, paste("<color>", col2kmlcolor(col[i]), "</color>", sep =""))
#kml <- append(kml, paste(" <Icon><href>", icon, "</href></Icon>", sep = ""))
#kml <- append(kml, "<scale>0.300000</scale>")
#kml <- append(kml, "</IconStyle></Style>")
kml <- append(kml, " <Point>")
kml <- append(kml, " <coordinates>")
kml <- append(kml, paste(point@coords[1], point@coords[2], sep = ","))
kml <- append(kml, " </coordinates>")
kml <- append(kml, " </Point>")
kml <- append(kml, "</Placemark>")
}
return(paste(paste(c(kmlHeader, kmlStyle, kml, kmlFooter), sep = "", collapse = "\n"), collapse="\n", sep = ""))
}
data <- MyPointKML(shp2,kmlname,kmldescription,name,description,icon,colcode)
google.show_kml_data_on_maps(data)
GoogleMaps Sorvi MML TEST
GoogleMaps PostgreSQL test 2
GoogleMaps PostgreSQL test
Opasnet.csv test
Opasnet.data and BUGS test
Failed to parse (SVG (MathML can be enabled via browser plugin): Invalid response ("Math extension cannot connect to Restbase.") from server "https://wikimedia.org/api/rest_v1/":): {\displaystyle \alpha 444 + 9999 / 123}
R-tools code include example
+ Show code - Hide code
library(OpasnetUtils)
library(ggplot2)
library(xtable)
saanto.siemenet <- op_baseGetData("opasnet_base", "Op_fi2633")[,-c(1,2,7)] # Jatropan siementen saanto viljelystä
saanto.öljy <- op_baseGetData("opasnet_base", "Op_fi2634")[,-c(1,2,5)] # Öljyn saanto jatropan siemenistä
saanto.diesel <- op_baseGetData("opasnet_base", "Op_fi2632")[,-c(1,2,5)] # Biodieselin saanto jatropaöljystä
viljelyala <- op_baseGetData("opasnet_base", "Op_fi2642")[,-c(1,2)] # Jatropan viljelyalueet
päästö.ilmasto <- op_baseGetData("opasnet_base", "Op_fi2547")[,-c(1,2)] # Jatropan viljelyn ilmastovaikutukset
päästö.sosiaali <- op_baseGetData("opasnet_base", "Op_fi2552")[,-c(1,2)] # Jatropan viljelyn sosiaaliset vaikutukset
päästö.ekosyst <- op_baseGetData("opasnet_base", "Op_fi2548")[,-c(1,2)] # Jatropan viljelyn ekosysteemivaikutukset
P <- op_baseGetData("opasnet_base", "Op_fi2539")[,-c(1,2,7)] # Jatropan käyttö bioenergian lähteenä
colnames(saanto.siemenet)[4] <- "siemenet"
colnames(saanto.öljy)[2] <- "öljy"
colnames(saanto.diesel)[2] <- "diesel"
saanto <- merge(saanto.siemenet, saanto.öljy)
saanto <- merge(saanto, saanto.diesel)
saanto[,9] <- saanto$siemenet * saanto$öljy * saanto$diesel * ala
colnames(saanto)[9] <- "saanto (kg/a)"
P <- PTable(P, n)
saanto <- merge(P, saanto)
if(length(divisions)>1) divisions <- as.list(saanto[, divisions]) else divisions <- saanto[, divisions]
out1 <- as.data.frame(as.table(tapply(saanto[, 10], divisions, mean)))
out1 <- dropall(out1[!is.na(out1$Freq), ])
print(xtable(out1), type = 'html')
out2 <- as.data.frame(as.table(tapply(saanto[, 10], list(saanto[, divisions2], saanto$obs), mean)))
out2 <- dropall(out2[!is.na(out2$Freq), ])
out2[1:10, ]
ggplot(out2, aes(x = Freq, weight = 1, fill = Var1)) +geom_density()
## Jostain syystä vain osa kuvista piirtyy oikein, riippuen mitä parametreja valitaan. En ymmärrä syytä.
+ Show code - Hide code
######################################
## dropall pudottaa data.framesta pois kaikki faktorien sellaiset levelit, joita ei käytetä.
## parametrit: x = data.frame
dropall <- function(x){
isFac <- NULL
for (i in 1:dim(x)[2]){isFac[i] = is.factor(x[ , i])}
for (i in 1:length(isFac)){
x[, i] <- x[, i][ , drop = TRUE]
}
return(x)
}
########################################
#########################################
## PTable muuntaa arvioinnin todennäköisyystaulun sopivaan muotoon arviointia varten.
## Parametrit: P = todennäköisyystaulu Opasnet-kannasta kaivettuna.
## n = iteraatioiden lukumäärä Monte Carlossa
## Todennäköisyystaulun sarakkeiden on oltava: Muuttuja, Selite, Lokaatio, P
## Tuotteena on Monte Carloa varten tehty taulu, jonka sarakkeina ovat
## n (iteraatio) ja kaikki todennäköisyystaulussa olleet selitteet, joiden riveille on arvottu
## lokaatiot niiden todennäköisyyksien mukaisesti, jotka todennäköisyystaulussa oli annettu.
PTable <- function(P, n) {
Pt <- unique(P[,c("Muuttuja", "Selite")])
Pt <- data.frame(Muuttuja = rep(Pt$Muuttuja, n), Selite = rep(Pt$Selite, n), obs = rep(1:n, each = nrow(Pt)), P = runif(n*nrow(Pt), 0, 1))
for(i in 2:nrow(P)){P$Result[i] <- P$Result[i] + ifelse(P$Muuttuja[i] == P$Muuttuja[i-1] & P$Selite[i] == P$Selite[i-1], P$Result[i-1], 0)}
P <- merge(P, Pt)
P <- P[P$P <= P$Result, ]
Pt <- as.data.frame(as.table(tapply(P$Result, as.list(P[, c("Muuttuja", "Selite", "obs")]), min)))
colnames(Pt) <- c("Muuttuja", "Selite", "obs", "Result")
Pt <- Pt[!is.na(P$Result), ]
P <- merge(P, Pt)
P <- P[, !colnames(P) %in% c("Result", "P", "Muuttuja")]
P <- reshape(P, idvar = "obs", timevar = "Selite", v.names = "Lokaatio", direction = "wide")
colnames(P) <- ifelse(substr(colnames(P), 1, 9) == "Lokaatio.", substr(colnames(P), 10,30), colnames(P))
return(P)
}
######################################
Rectangle area test
MassHEIS test
Moved to MassHEIS .
MassHEIS test multilayer NOT WORKING YET