I'm trying to create table. But special one. It should be like this:
It shows logarithm base 10, where anyone could find solution. Simply it's logarithmic table.
I know, I could do it manually number by number, but it should be done better, I think.
It's possible, that I should use function sapply()
or something similar, but I'm not so sure.
I'm not pretty sure, it should be shorter, but it works:
#I'll do left side like a matrix, delete everything not needed (I left 4 rounded decimals digits
logous <- matrix((round(log(seq(10,50.9,0.1),10)-1,4)*10000),ncol=10,byrow=T)
rownames(logous) <- c(10:50)#name rows
colnames(logous) <- c(0:9)#name columns
#sprintf("%04.0f", logous)
#instead of that above, I'll do formatC() to have everywhere 4 digits
formatC(logous, width = 4, format = "d", flag = "0")
logous <- cbind(logous, md1=c(4, 4, rep(x=3, each=5, times=1), rep(x=2, each=12, times=1), rep(x=1, each=22, times=1)),
md2=c(8, 8, 7, rep(x=(6:5), each=3, times=1), rep(x=4, each=6, times=1), rep(x=3, each=10, times=1), rep(x=2, each=16, times=1)),
md3=c(12:10, 10:8, 8, rep(x=7, each=3, times=1), rep(x=6, each=4, times=1), rep(x=5, each=5, times=1), rep(x=4, each=8, times=1), rep(x=3, each=14, times=1)),
md4=c(17, 15:11, 11:9, 9, rep(x=8, each=3, times=1), rep(x=7, each=4, times=1), rep(x=6, each=5, times=1), rep(x=5, each=7, times=1), rep(x=4, each=11, times=1), 3),
md5=c(21, 19, 17:13, rep(x=12:10, each=2, times=1), rep(x=9:8, each=3, times=1), rep(x=7, each=4, times=1), rep(x=6, each=6, times=1), rep(x=5, each=9, times=1), rep(x=4, each=3, times=1)),
md6=c(25, 23, 21, 19:14, rep(x=13:10, each=2, times=1), rep(x=9:8, each=4, times=1), rep(x=7, each=5, times=1), rep(x=6, each=7, times=1), rep(x=5, each=4, times=1)),
md7=c(29, 26, 24, 23, 21, 20, 18:16, 16:14, 14:12, 12, rep(x=11:10, each=3, times=1), rep(x=9, each=4, times=1), rep(x=8, each=5, times=1), rep(x=7, each=6, times=1), rep(x=6, each=4, times=1)),
md8=c(33, 30, 28, 26, 24, 22:16, rep(x=15:12, each=2, times=1), rep(x=11, each=3, times=1), rep(x=10:9, each=4, times=1), rep(x=8:7, each=5, times=1)),
md9=c(37, 34, 31, 29, 27, 25:24, 22:17, 17:16, rep(x=15:13, each=2, times=1), rep(x=12:11, each=3, times=1), rep(x=10, each=4, times=1), rep(x=9:8, each=5, times=1)))
#I added new columns, maybe it could be shorter and easier, but this works
logous #see my result
Uff! That's it!