diff --git a/R/rnblight/example.md b/R/rnblight/example.md index 0954611227680d9b62880ddc8ebba291e715cd26..92022864dc4eb9082f50f1680cbeacdeb726c99e 100644 --- a/R/rnblight/example.md +++ b/R/rnblight/example.md @@ -99,7 +99,6 @@ Confidence around proportions Formula: > If the samples size n and population proportion p satisfy the condition that np ≥ 5 and n(1 − p) ≥ 5, than the end points of the interval estimate at (1 − α) confidence level is defined in terms of the sample proportion as follows. - ![](.example_images/prop_ci.png) CI math is detailed out under http://www.statisticslectures.com/topics/ciproportions/ diff --git a/R/rnblight/example_raw.md b/R/rnblight/example_raw.md index 49d2fd29e0517445d42d72d5a50b54761b22280e..5e3a340fe55244156ca120ca4afb62566c59ef82 100644 --- a/R/rnblight/example_raw.md +++ b/R/rnblight/example_raw.md @@ -31,7 +31,6 @@ prop.test(x=c(19,15), n=c(34,34), correct=FALSE) ## also works for single proportion #prop.test(x=c(19), n=c(34), correct=FALSE) #prop.test(x=c(19,15,20), n=c(34,34,34), correct=FALSE) - ``` Also see diff --git a/R/rnblight/strip_chunk_results.kt b/R/rnblight/strip_chunk_results.kt new file mode 100644 index 0000000000000000000000000000000000000000..a00c3ac10a1bc297997653370c5693ca1bcc8901 --- /dev/null +++ b/R/rnblight/strip_chunk_results.kt @@ -0,0 +1,37 @@ +import java.io.File + +val kotlin.Boolean.int + get() = if (this) 1 else 0 + +fun main(args: Array) { + + //val mdFile = File(args[0]) + val mdFile = File("/Users/brandl/Dropbox/projects/datautils/R/rnblight/example.md") + + // + //var chunkCounter = 0 + //var isInChunk = false + //val filtMd = mdFile.readLines().groupBy{ line-> + // + // if(line.startsWith("```")) { + // chunkCounter++ + // isInChunk = !isInChunk + // } + // + // chunkCounter + //}.filterNot { (_, group) -> + // group.filterNot{it.startsWith("```")}.all { it.startsWith("## ") } + //} + // + //File("result.md").writeText( filtMd.flatMap { it.value }.joinToString("\n")) + + + fun List.cumSum(removeNA: Boolean = false): Iterable { + return drop(1).fold(listOf(first().toDouble()), { list, curVal -> list + (list.last().toDouble() + curVal.toDouble()) }) + } + + val lines = mdFile.readLines().take(50) + lines.map { it.startsWith("```").int } + lines.map { it.startsWith("```").int }.windowed(2) { (a, b) -> if (a > b) a else b } + lines.map { it.startsWith("```").int }.cumSum().zipWithNext { a, b -> a } +} diff --git a/R/rnblight/strip_chunk_results.kts b/R/rnblight/strip_chunk_results.kts deleted file mode 100644 index 79c88b34f1a08fdb09d4bb8a8f9ce5a4f351a95b..0000000000000000000000000000000000000000 --- a/R/rnblight/strip_chunk_results.kts +++ /dev/null @@ -1,35 +0,0 @@ -import java.io.File - - -//val mdFile = File(args[0]) -val mdFile = File("/Users/brandl/Dropbox/projects/datautils/R/rnblight/example.md") - -// -//var chunkCounter = 0 -//var isInChunk = false -//val filtMd = mdFile.readLines().groupBy{ line-> -// -// if(line.startsWith("```")) { -// chunkCounter++ -// isInChunk = !isInChunk -// } -// -// chunkCounter -//}.filterNot { (_, group) -> -// group.filterNot{it.startsWith("```")}.all { it.startsWith("## ") } -//} -// -//File("result.md").writeText( filtMd.flatMap { it.value }.joinToString("\n")) - - -val Boolean.int - get() = if (this) 1 else 0 - -fun List.cumSum(removeNA: Boolean = false): Iterable { - return drop(1).fold(listOf(first().toDouble()), { list, curVal -> list + (list.last().toDouble() + curVal.toDouble()) }) -} - -val lines = mdFile.readLines().take(50) -lines.map { it.startsWith("```").int } -lines.map { it.startsWith("```").int }.windowed(2){ (a,b) -> if(a>b) a else b} -lines.map { it.startsWith("```").int }.cumSum().zipWithNext{ a,b -> a} \ No newline at end of file