Plot size = 1/{N∗⌈log2N⌉∗[(1/70)/60]} in R?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 12:52:51

问题


size = 1/{N∗⌈log_2(N)⌉∗[(1/70)/60]}

How can I plot this function with R?

(⌈⌉= ceil)

For example:

With label "size" for y-axis and "N" for x-axis.

N >= 2, N is natural Number (2,3,4,5,6,...)


回答1:


Let's define the function

f <- function(N) 1 / (N * ceiling(log2(N)) * 1/70/60)

Plot with base R in the range [1,20]

curve(f, from = 1, to = 20, n = 10^3, type = "p", cex = 0.1)

Plot with ggplot2 in the range [1,20]

library(ggplot2)
ggplot(data.frame(N = c(1, 20)), aes(N)) + stat_function(fun = f, geom = "point")



来源:https://stackoverflow.com/questions/51337437/plot-size-1-n%e2%88%97-log2n-%e2%88%971-70-60-in-r

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!