# R/ciJack2.R In fullfact: Full Factorial Breeding Analysis

#### Documented in ciJack2

```ciJack2 <-
function(comp,full,level=95,rnd_r=3,rnd_p=1,position=NULL,block=NULL,trait=NULL) {
if (missing(full)) stop("Need the observed values using full data")
cia<- (100-level)/100/2
n<- nrow(comp)
mater<- grep("maternal", colnames(comp))
if (!is.null(position)) { pos<- grep(paste(position), colnames(comp)) }
if (!is.null(block)) { bloc<- grep(paste(block), colnames(comp)) }
comp\$p_mat<- 100*comp[,mater]/comp\$Total
if (!is.null(position)) { comp\$p_pos<- 100*comp[,pos]/comp\$Total }
if (!is.null(block)) { comp\$p_bloc<- 100*comp[,bloc]/comp\$Total }
if (is.null(position) && is.null(block)) {
full_r<- do.call("rbind", replicate(n,full[1:3],simplify=F)) #raw
if (!is.null(position) && is.null(block)) {
full_r<- do.call("rbind", replicate(n,full[c(1:3,5)],simplify=F))
position=100*full[5]/full[4]) }
if (is.null(position) && !is.null(block)) {
full_r<- do.call("rbind", replicate(n,full[c(1:3,5)],simplify=F))
block=100*full[5]/full[4]) }
if (!is.null(position) && !is.null(block)) {
full_r<- do.call("rbind", replicate(n,full[c(1:3,5,6)],simplify=F))
position=100*full[5]/full[4],block=100*full[6]/full[4])  }
full_p<- do.call("rbind", replicate(n,full_p1,simplify=F))
if (is.null(position) && is.null(block)) {
if (!is.null(position) && is.null(block)) {
if (is.null(position) && !is.null(block)) {
if (!is.null(position) && !is.null(block)) {
lwr_r<- colMeans(pseudo_r)- qt(1-cia,n-1)*sqrt(apply(pseudo_r, 2, var)/n)
upp_r<- colMeans(pseudo_r) + qt(1-cia,n-1)*sqrt(apply(pseudo_r, 2, var)/n)
lwr_p<- colMeans(pseudo_p)- qt(1-cia,n-1)*sqrt(apply(pseudo_p, 2, var)/n)
upp_p<- colMeans(pseudo_p) + qt(1-cia,n-1)*sqrt(apply(pseudo_p, 2, var)/n)
if (is.null(position) && is.null(block)) {
rownames(ci)<- c(1,2,3)
rownames(ci_p)<- c(1,2,3) }
if (!is.null(position) && is.null(block)) {
rownames(ci)<- c(1,2,3,4)
rownames(ci_p)<- c(1,2,3,4) }
if (is.null(position) && !is.null(block)) {
rownames(ci)<- c(1,2,3,4)
rownames(ci_p)<- c(1,2,3,4) }
if (!is.null(position) && !is.null(block)) {
mean=colMeans(pseudo_r), upper= upp_r); rownames(ci)<- c(1,2,3,4,5)
mean=colMeans(pseudo_p), upper= upp_p);rownames(ci_p)<- c(1,2,3,4,5) }
ci[,2:4]<- round(ci[,2:4],rnd_r)
ci_p[,2:4]<- round(ci_p[,2:4],rnd_p)
if (is.null(trait)) { ci_obj<- list(raw=ci,percentage=ci_p); return(ci_obj) }
if (!is.null(trait)) { ci\$trait<- as.factor(trait); ci_p\$trait<- as.factor(trait);
ci_obj<- list(raw=ci,percentage=ci_p); return(ci_obj) }
}
```

## Try the fullfact package in your browser

Any scripts or data that you put into this service are public.

fullfact documentation built on March 14, 2021, 5:08 p.m.