This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ref:https://www.r-statistics.com/tag/friedman-test/ | |
friedman.test.with.post.hoc <- function(formu, data, to.print.friedman = T, to.post.hoc.if.signif = T, to.plot.parallel = T, to.plot.boxplot = T, signif.P = .05, color.blocks.in.cor.plot = T, jitter.Y.in.cor.plot =F) | |
{ | |
# formu is a formula of the shape: Y ~ X | block | |
# data is a long data.frame with three columns: [[ Y (numeric), X (factor), block (factor) ]] | |
# Note: This function doesn't handle NA's! In case of NA in Y in one of the blocks, then that entire block should be removed. | |
# Loading needed packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ref:https://sites.google.com/a/lakeheadu.ca/yong-luo/blog/convert-utm-to-longlat-in-r | |
library(rgdal) | |
# prepare UTM coordinates matrix | |
utmcoor<-SpatialPoints(cbind(utmdata$X,utmdata$Y), proj4string=CRS("+proj=utm +zone=30")) # UTM zone Central Thailand: 47P | |
#utmdata$X and utmdata$Y are corresponding to UTM Easting and Northing, respectively. | |
#zone= UTM zone | |
# converting | |
longlatcoor<-spTransform(utmcoor,CRS("+proj=longlat")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ref:https://fabiomarroni.wordpress.com/2017/03/25/perform-pairwise-wilcoxon-test-classify-groups-by-significance-and-plot-results/ | |
library(multcompView) | |
first.set<-cbind(rnorm(100,mean=1.8),1) | |
second.set<-cbind(rnorm(100,mean=0.9),2) | |
third.set<-cbind(rnorm(100,mean=1),3) | |
full<-rbind(first.set,second.set,third.set) | |
pp<-pairwise.wilcox.test(full[,1], full[,2], p.adjust.method = "none", paired = FALSE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List of useful packages | |
pkg <- c("tidyr", "dplyr", "ggplot2", "knitr", "rmarkdown") | |
# Check if packages are not installed and assign the | |
# names of the uninstalled packages to the variable new.pkg | |
new.pkg <- pkg[!(pkg %in% installed.packages())] | |
# If there are any packages in the list that aren't installed, | |
# install them | |
if (length(new.pkg)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#title: code sample for ploting polynomial model | |
# load packages | |
library(readxl) # load readxl package | |
library(ggplot2) # load ggplot2 paackage | |
library(dplyr) # load dplyr package | |
library(polynom) # load polynom | |
library(gsheet) # load gsheet | |
# load data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(desplot) | |
library(agricolae) | |
library(RColorBrewer) | |
plot.RCBD.layout <- function(trt_name, num_block){ | |
repeticion <- rep(num_block, length(trt_name)) | |
RCBD <- design.rcbd(trt_name, r = repeticion, serie = 0) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(agricolae) | |
library(desplot) | |
plot.CRD.layout <- function(trt_name, num_rep){ | |
repeticion <- rep(num_rep, length(trt)) | |
CRD <- design.crd(trt, r = repeticion, serie = 0) | |
CRD_layout <- CRD$book |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dat <- read_csv("/Users/sithjaisong/Desktop/ycom.csv") # โหลดไฟล์ที่ต้องการ | |
# ตอนนี้ข้อมูลที่ผมมีนั้น จะเห็นว่า trt ที่เรียงนั้น มันถูกเรียงตาม rep | |
head(dat) | |
Source: local data frame [6 x 15] | |
trt rep sm sm y moi hill panicle sunk mc_sunk float_sunk mc_float tgw sunk mc_tgw_sunk tgw float mc_tgw_float | |
(chr) (int) (int) (dbl) (dbl) (int) (int) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) (dbl) | |
1 PR 1 1 2.320 14.0 108 214 261.8 13.1 64.1 14.0 24.548 12.80 3.425 14.0 | |
2 PR 1 2 2.570 15.6 108 230 283.8 13.7 62.1 14.5 23.958 12.20 3.524 14.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lapply(data, shapiro.test) | |
$DH | |
Shapiro-Wilk normality test | |
data: X[[i]] | |
W = 0.4481, p-value < 2.2e-16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###########################Header############################################## | |
# title : multiggplot.R; | |
# purpose : create muti histogram of all varibles in the dataset; | |
# producer : prepared by S. Jaisong ([email protected]); | |
# last update : in Los Baños, Laguna, PHL, April 2015; | |
# inputs : "airquality" data from R; | |
# outputs : exaple.pdf; | |
# remarks 1 : ; | |
# remarks 2 : ; | |
###############################End############################################# |
NewerOlder