I want a function that returns -1 for negative numbers and +1 for positive numbers. http://en.wikipedia.org/wi
I have the following JavaScript syntax: var discount = Math.round(100 - (price / listprice) * 100)
Today I needed a simple algorithm for checking if a number is a power of 2. The algorithm needs to be: Simpl
I was trying various methods to implement a program that gives the digits of pi sequentially. I tried the Tayl
I can't get my head around this, which is more random? rand() OR: rand() * rand() I´m finding it a
Is this defined by the language? Is there a defined maximum? Is it different in different browsers?
In JavaScript, how do I get: The whole number of times a given integer goes into another? The remainder?
Given two date ranges, what is the simplest or most efficient way to determine whether the two date ranges ove
I'm looking for the fastest way to determine if a long value is a perfect square (i.e. its square root is
Consider the following code: 0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004
In R, I have an element x and a vector v. I want to find the first index of an element in v that is equal to x
How to find the length of a string (number of characters in a string) without splitting it in R? I know how to
I am having some troubles with leading and trailing white space in a data.frame. For example, I like to take a
I seem to be sharing a lot of code with coauthors these days. Many of them are novice/intermediate R users and
How can I concatenate (merge, combine) two values? For example I have: tmp = cbind("GAD", "AB") tmp # [,
A friend sent me along this great tutorial on webscraping NYtimes with R. I would really love to try it. Howev
I want to write trycatch code to deal with error in downloading from the web. url <- c( "http://stat.e
In R, mean() and median() are standard functions which do what you'd expect. mode() tells you the intern