Here's an answer to your question. See this discussion for alternative formulae for nth-root calculations.
# set up the data
df <- data.frame(c(1, 777, 6), c(136, 1, 665), c(0, 100, 97))
df <- t(df)
colnames(df) <- c("V1", "V2", "V3")
rownames(df) <- NULL
# define a function to calculate the nth root
nthroot <- function(x, n){
x^(1/n)
}
# define a function to do your required transformations
cell_transformer <- function(x) {
log(x/(nthroot(sapply(apply(df, 1, prod), sum), length(x))))
}
# apply the cell_transformer to your dataframe in a row-wise fashion
apply(df, 1, function(x) cell_transformer(x))
#> [,1] [,2] [,3]
#> V1 -2.815733 2.096922 -Inf
#> V2 2.851293 -3.804147 0.8010229
#> V3 Inf Inf Inf
Created on 2020-02-04 by the reprex package (v0.3.0)