Skip to content

Instantly share code, notes, and snippets.

View alpo-p's full-sized avatar
🖖

Alpo Panula alpo-p

🖖
  • Helsinki, Finland
View GitHub Profile
@alpo-p
alpo-p / tracker_test
Created December 6, 2016 09:14
R googlesheets api
library("googlesheets")
suppressPackageStartupMessages(library("dplyr"))
gs_auth() #authorizes through browser
#register the spreadsheet and the show it to be sure it worked
urlForWt <- "<<add url for google sheet>>"
test <- gs_url(urlForWt)
test
@alpo-p
alpo-p / iris.R
Created December 6, 2016 08:12
K nearest neighbours, test with Iris dataset
iris <- read.csv(url("http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data"), header = FALSE)
View(iris)
names(iris) <- c("Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width", "Species")
library(ggvis)
iris %>% ggvis(~Sepal.Length, ~Sepal.Width, fill = ~Species) %>% layer_points()
iris %>% ggvis(~Petal.Length, ~Petal.Width, fill = ~Species) %>% layer_points()
prop.table(table(iris$Species))
@alpo-p
alpo-p / prostate_cancer.R
Created December 6, 2016 08:10
R: K nearest neighbours test
setwd("~/R/harjottelut/prostate cancer")
library(class)
library(gmodels)
prc <- read.csv("Prostate_Cancer.csv", stringsAsFactors = FALSE)
#str(prc)
prc <- prc[-1]
#View(prc)
#table(prc$diagnosis_result)
prc$diagnosis_result <- factor(prc$diagnosis_result, levels = c("B", "M"), labels = c("Benign", "Malignant"))