Skip to content

Instantly share code, notes, and snippets.

@shujishigenobu
Created February 18, 2012 09:32
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shujishigenobu/1858458 to your computer and use it in GitHub Desktop.
Save shujishigenobu/1858458 to your computer and use it in GitHub Desktop.
calculate N50
# len <- c(100, 120, 40, 1000, ....)
len.sorted <- rev(sort(len))
N50 <- len.sorted[cumsum(len.sorted) >= sum(len.sorted)*0.5][1]
N90 <- len.sorted[cumsum(len.sorted) >= sum(len.sorted)*0.9][1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment