Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 185069

R is a free, open source programming language and software environment for statistical computing and graphics.

3 votes
Accepted

Discrete event simulation for production defects

Idiomatic R I did some simple stuff first: pulled all your functions to the start of the script, reformatted some code/comments. … This side-effect is problematic in R, so I didn't include a pop_element function. To achieve pop_element you have to peek and then delete_min. …
Russ Hyde's user avatar
  • 290
2 votes

Simulating data generating process correctly

You should always strive to find ways to define pure functions in your R code, and try to use vectorisation instead of for loops. …
Russ Hyde's user avatar
  • 290
3 votes
Accepted

Plots of prior and posterior distributions for a model

The code was OK as far as base R goes. First thing I did was run styler and then lintr on your code; these two things help clean up the coding style in your scripts. … I also renamed your alpha / beta vectors - in R, these correspond to the shape and rate parameters that are passed into dgamma: # ---- experimental data num_observations <- 10 lambda <- .2 x <- rpois …
Russ Hyde's user avatar
  • 290
1 vote

Mandelbrot rendering code in R

if (r < r_escape) { x1 <- x0^2 - y0^2 + c_x[nx] y1 <- 2 * x0 * y0 + c_y[ny] s <- ifelse(r > 0, s + min(r, 1 / r), s) x0 <- x1 y0 <- y1 r <- x0^2 + y0^2 … (df, x0^2 - y0^2 + cx) y1 <- with(df, 2 * x0 * y0 + cy) df %>% dplyr::mutate( s = ifelse(r > 0, s + pmin(r, 1 / r), s), x0 = x1, y0 = y1, r = x0^2 + y0^2 …
Russ Hyde's user avatar
  • 290
3 votes
Accepted

Mandelbrot rendering code in R

There's a couple of things you can do to improve the R-style and the efficiency of your code. … } x0 <- x1 y0 <- y1 if (r > 0) { s <- s + min(r, 1 / r) } # this is what we measure instead of escape count } Mxy[nx, ny] <- s } } Mmax <- …
Russ Hyde's user avatar
  • 290