Ero sivun ”OpasnetBaseUtils” versioiden välillä

Opasnet Suomista
Siirry navigaatioon Siirry hakuun
(→‎Rcode generic: obs parameter added to tidy. CORRECT TO OP_EN AS WELL!)
Rivi 82: Rivi 82:
############ tidy: a function that cleans the tables from Opasnet Base
############ tidy: a function that cleans the tables from Opasnet Base
# data is a table from op_baseGetData function
# data is a table from op_baseGetData function
tidy <- function (data) {
# obs: if TRUE, keep obs column in output.
tidy <- function (data, obs = FALSE) {
data$Result <- ifelse(!is.na(data$Result.Text), as.character(data$Result.Text), data$Result)
data$Result <- ifelse(!is.na(data$Result.Text), as.character(data$Result.Text), data$Result)
if("Observation" %in% colnames(data)){test <- data$Observation != "Description"} else {test <- TRUE}
if("Observation" %in% colnames(data)){test <- data$Observation != "Description"} else {test <- TRUE}
if("Havainto" %in% colnames(data)){test <- data$Havainto != "kuvaus"}
if("Havainto" %in% colnames(data)){test <- data$Havainto != "kuvaus"}
data <- data[test, !colnames(data) %in% c("id", "obs", "Result.Text")]
if(obs) {remove <- c("id", "Result.Text")} else {remove <- c("id", "obs", "Result.Text")}
data <- data[test, !colnames(data) %in% remove]
if(sum(is.na(as.numeric(as.character(data$Result)))) == 0) {data$Result <- as.numeric(as.character(data$Result))}
if(sum(is.na(as.numeric(as.character(data$Result)))) == 0) {data$Result <- as.numeric(as.character(data$Result))}
return(data)
return(data)

Versio 25. huhtikuuta 2012 kello 06.26

This page is just a placeholder for code in op_en:OpasnetBaseUtils so that it can be used in Finnish Opasnet as well.

Rcode generic

  • Functions: dropall, PTable, opasnet.data, tidy, summary.bring

+ Näytä koodi

⇤--#: . Opasnet.data() does not work. Problems: 1) it seems to be unable to download files from M-files; 2) the read.table part does not work (error: line 2 did not have 7 elements (there were 29 columns!)), 3) error: could not find function getURL (this is maybe a problem with my own computer, as getURL has worked correctly in R-tools.) --Jouni 23:54, 28 December 2011 (EET) (type: truth; paradigms: science: attack)