Home > Software design >  pander function inside sapply in r
pander function inside sapply in r

Time:12-07

How we use pander() function inside a sapply() to knit a table into HTML/ word?

Here is my code

Data <- data.frame(A = sample(1:2,10,replace = TRUE),
                   B = sample(1:3,10,replace = TRUE),
                   C = sample(1:5,10,replace = TRUE),
                   D = rnorm(10),
                   E = rnorm(10, 10, 3))

Var_Cat <- 1:3
Var_obsn <- 4:5

sapply(Var_obsn, function(i){
  sapply(Var_Cat, function(j){
    print(Data[,c(i,j)] |> names())
    Data[,c(j,i) ] |> 
      kruskal.test() |> pander() |> print()})})

enter image description here

  • Related