0

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

How can I plot this function with R?

(⌈⌉= ceil)

For example: enter image description here

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

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

GenXGer
  • 67
  • 8
  • `curve(1 / (x * ceiling(log2(x)) * ((1/70)/60)))`? Possible duplicate of [How to plot a function curve in R](https://stackoverflow.com/questions/26091323/how-to-plot-a-function-curve-in-r) – jay.sf Jul 14 '18 at 10:19
  • Not really... because this one is not a simple function :/ I draw an example of this - see above... it should looks like this... – GenXGer Jul 14 '18 at 10:37
  • @GenXGer Yes, really! ;-) You just need to show the function for the same range. Take a look at my example below. – Maurits Evers Jul 19 '18 at 07:23

1 Answers1

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)

enter image description here

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")

enter image description here

Maurits Evers
  • 49,617
  • 4
  • 47
  • 68