List of All Functions (by Category) in CODAP
Function 
Description 
Example 
Arithmetic Functions 

abs(num)  Computes the absolute value of its argument. 
abs(3 – 5) is 2 abs(37) = 3 – 7=4 
ceil(num)  Returns the closest integer greater than or equal to its argument. 
ceil(1) returns 1 ceil(1.5) returns 2 ceil(1.5) returns 1 
exp(num)  Returns the result of raising e, the base of natural logs to a power.  exp(2) is 7.39, the same as e squared 
floor(num)  Returns the largest integer less than or equal to its numeric argument. 
floor(1) returns 1 floor(1.5) returns 1 floor(1.5) returns 2 
frac(num)  Returns the fractional or noninteger part of a number. 
frac(1.5) returns 0.5 frac(2.3) returns 0.3 
ln(num)  Returns the logarithm of a number to base e.  ln(100) is 4.61 
log(num)  Returns the logarithm of a number to base 10.  log(100) is 2.0 
pow(base, exponent)  Returns the result of a number raised to a power. 
pow(2,5) is 2^{5}, returns 32 pow(10,3) is 1 / 1000, or .001 
round(num1, num2) round(num[,places]) 
Returns the value of its argument rounded to the specified number of decimal places (default 0). This function has an optional, second argument that specifies how many decimals to round to. 
round(3.14) is 3 round(π, 4) is 3.1416 round(1276, –2) is 1300 
sqrt(num)  Returns the square root of its numeric argument. 
sqrt(100) returns 10 sqrt(2) is 1.41 sqrt(2) returns NaN, meaning Not a Number 
trunc(num)  Returns the nearest integer equal to or smaller in magnitude (closer to zero) than its argument. 
trunc(5.5) returns 5 trunc(5.5) returns 5 
Date/Time Functions 

date(year, month, day) 
Returns a date/time value corresponding to its arguments. If any argument is omitted it is defaulted to 0 (or 1 for the day). If a single large argument is specified, it is assumed to be seconds since January 1, 1970 and is converted accordingly. 
date(1969, 7, 16) returns 7/16/1969 date(1395154345) returns 3/18/2014 7:52:25 AM date(2016, 12, 19, 13, 59, 15, 26) returns 12/19/2016 1:59:15 PM date(16) returns 1/1/2016 
dayOfMonth(date)  Returns the day of the month corresponding to the given date.  If date is Aug 31, 2005, dayOfMonth(date) returns 31 
dayOfWeek(date)  Returns the day of the week (as a number) corresponding to the given date.  If date is Aug 31, 2005, dayOfWeek(date) returns 4 because August 31, 2005 is a Wednesday 
dayOfWeekName(date)  Returns the long name of the day of the week corresponding to the given date.  If date is Aug 31, 2005, dayOfWeekName(date) returns "Wednesday" 
hours(date_time)  Returns the hour (in 24hour time) corresponding to the given datetime. 
hours("8312005 8:57 PM") returns 20 (8 PM on a 24hour clock) hours(date(2017,3,20,7,1,59)) returns 7 
minutes(date_time)  Returns the minute of the hour corresponding to the given date_time.  If date_time is 3:30 PM on Aug 31, 2005, minute(date_time) returns 30 
month(date)  Returns the number of the month corresponding to the given date. 
If the date is Aug. 31, 2016, month(date) returns 8 
monthName(date)  Returns the long name of the month corresponding to the given date.  If date is Aug 31, 2005, monthName(date) returns "August" 
now  Returns the current date and time. 
At the moment this was written, now() returned 12/30/2016 9:58:15 AM 
seconds(date_time)  Returns the second corresponding to the given date_time.  If date_time is 3:30:05 PM on Aug 31, 2005, second(date_time) returns 5. 
secondsToDate(date_time)  Converts a time in seconds into a string.  If date_time is 3:30:05 PM on Aug 31, 2005, secondsToDate(date_time) returns 8/31/2005. 
today()  Returns current date with no time.  On the day this was written, today() returned 12/30/2016 
year(date)  Returns the year corresponding to the given date.  If date is Aug 31, 2005, year(date) returns 2005 
Lookup Functions 

first(num,[filter])  Returns the value of its argument evaluated for the first case. 
first(population) returns the first value of the attribute population first(population,sex="female") returns the first value for the attribute population for which the attribute sex is female 
last(num,[filter]) 
Returns the value of that expression for the last case.

last(amountInBank) returns the last value of the attribute amountInBank last(amountInBank, year>2010) returns the last value for the attribute amountInBank for which the year is greater than 2010 
lookupByIndex("remoteDataSetName", "remoteAttributeName", index)  Returns the value of the specified attribute for the case at the specified (1based) index in the data set name. Note that dataSetName and attributeName must be strings (or expressions that evaluate to strings), while index should evaluate to an integer. 
lookupByIndex("United_States", "Full_state_name", index) looks up the attribute Full_state_name in the United_States data set at the index point. It then returns Full_state_name in your data set. 
lookupByKey("remoteDataSetName", "returnedAttributeName", "keyAttributeName", keyValue)  Returns the value of the specified returned attribute for the case with the specified keyValue as its value for the keyAttributeName attribute in the specified data set. 
lookupByKey("United_States", "State_abbreviations1", "State_abbreviations2", Full_state_name) looks up the states in the data set "United_States." The attribute "State_abbreviations1" from the first data set matches the attribute "State_abbreviations2" from the second data set. The function looks up the states "CA," "WA," "OR" and returns "California," "Washington," "Oregon." 
next(num,[filter])  Returns the value of that expression for the next case. 
next(number) is 10 next(number, City="Tucson") returns the next value for the attribute number for which the attribute City is Tucson 
prev(num)  Returns the value of that expression for the previous case. 
prev(height) returns 9 prev(height, sex="female") returns the previous value for the attribute height for which the attribute sex is female 
Other Functions 

boolean(num)  Returns the value of its argument converted to a boolean value. 
boolean(age > 60) is true or false age > 60 is true or false 
greatCircleDistance(latitude1, longitude1, latitude2, longitude2)  Returns the shortest distance between two points on the surface of the earth.  greatCircleDistance(latitude1, longitude1, latitude2, longitude2) returns 5 
if()  Returns one of two values depending on whether the result of evaluating a logical expression is true or false.  if(xx>2, "big", "small") 
isFinite(value)  Checks whether a number is a finite number.  isFinite("Dolphin") returns false. isFinite(12) returns true. isFinite(52) returns true. 
number(num)  Converts the input value to a numeric value.  number(3.5) returns the number 3.5 
random() random(max) random(min, max) 
Returns a random number drawn from a uniform distribution. 
random() returns a number between 0 and 1 random(100) returns a number between 0 and 100 random(–10, 10) returns a number between –10 and 10 
string(value)  Returns the value of its argument converted to a string.  string(6) is the string 6 
Statistical Functions 

combine(value)  Returns the aggregated concatenation of its evaluated argument values. 
combine(flip) might return "HHT" when there are three cases each with value "H" or "T" combine(1) returns 1, repeated for the number of cases in the case table 
correlation(xExpr, yExpr)  Computes Pearson's correlation coefficient for two attributes. The result does not depend on order. 
correlation(fathers_height, sons_height) computes the correlation coefficient for the two attributes. correlation(age, height, age<18) computes the correlation of age and height for those cases that have age less than 18. 
count(value)  Returns the number of cases in the collection. When used with no arguments it returns the number of child cases.  count(NumberOfPets > 0) returns the number of cases for which NumberOfPets is greater than zero. 
linRegrSlope(xExpr, yExpr)  Computes the slope of the least squares regression line (lsrl) for two attributes. 
linRegrSlope(fathers_height, sons_height) computes the slope of the lsrl for the two attributes. linRegrSlope(age, height, age<18) computes the slope of the lsrl for age and height for those cases that have age less than 18. 
linRegrIntercept(xExpr, yExpr)  Computes the yintercept of the least squares regression line (lsrl) for two attributes. 
linRegrIntercept(fathers_height, sons_height) computes the yintercept of the lsrl for the two attributes. linRegrIntercept(age, height, age<18) computes the yintercept of the lsrl for age and height for those cases that have age less than 18. 
linRegrResidual(xExpr, yExpr)  Returns the difference between the actual response and the predicted response from the leastsquares regression line of the response values against the predictor values. 
linRegrResidual(horsepower, mpg) returns, for each value of horsepower, the difference between the actual value of mpg and the predicted value. 
linRegrPredicted(xExpr, yExpr)  Returns the response predicted by a leastsquares regression line of the response values against the predictor values for each predictor value. 
linRegrPredicted(horsepower, mpg) returns, for each value of horsepower, the the predicted value of mpg. 
max(num[,filter])  Returns the maximum value of its argument evaluated for every case. 
max(100) returns 100 max(Height) returns the maximum height 
mean(expression,[filter])  Returns the arithmetic mean (sum divided by count) of its argument evaluated for every case. 
mean(Height) computes the mean of the attribute Height mean(height, Sex = "F") computes the mean height of females 
median(num)  Returns the median. Half the values of the attribute will be above this and half will be below.  median(lifetime) would return the median value for the attribute lifetime 
min(num)  Returns the smallest value in a collection. 
min(price) returns the minimum value of the attribute price min(price, quality = "good") gives the minimum value of price for cases that has quality good 
percentile(constant, num)  Returns the nth percentile from a range of values.  percentile(50,speed) is another way to compute the median percentile(95,score) will return the score corresponding to the 95th percentile. 
rSquared(xExpr, yExpr)  Computes square of the correlation coefficient for two attributes. The result does not depend on order. 
rSquared(fathers_height, sons_height) computes the square of the correlation coefficient for the two attributes. rSquared(age, height, age<18) computes the rSquared value for age and height for those cases that have age less than 18. 
stdDev(num)  Computes the sample standard deviation.  stdDev(pressure) computes the sample standard deviation of the attribute pressure 
sum(expr[,filter])  Returns the sum of its argument evaluated for every case. 
sum(grade_point) computes the sum of the grade points sum(Mass, Height>60) returns the sum of the masses for heights taller than 60 
variance(num)  Computes the variance of an attribute, that is, the square of the standard deviation.  variance(before–after) computes the variance of the difference of the two attributes before and after. 
String Functions 

beginsWith(stringToLookIn, stringToFind)  Takes two arguments and returns true if the first begins with the second.  beginsWith(LastName, "Mc") will return true for “McBride” and false for “Binker” 
charAt(string, position)  Returns the character at the specified position.  
concat(string1, string2, ... string10)  Takes up to ten arguments and returns a string. The arguments can be numeric or strings. Note: You have to include an argument for the space to get a space in the caption.  if a case has the value “Denise” for the attribute Name and the value “likes dogs” for the attribute Hobby, then concat(Name, " ", Hobby) returns “Denise likes dogs.” 
endsWith(stringToLookIn, stringToFind)  Takes two arguments and returns true if the first ends with the second.  endsWith(LastName, "er") returns true for “Binker” and false for “McBride" 
findString(stringToLookIn, stringToFind, start)  Takes three arguments, returning the position of stringToFind in stringToFind starting from start. The first character of stringToLookIn is numbered 1. Returns 0 if stringToFind is not found. The third argument need not be present and defaults to 1. 
findString("mathematics", "the") returns 1, but findString("mathematics", "the", 2) returns 6 
includes(stringToLookIn, stringToFind)  Takes two arguments and returns true if the second argument is a substring of the first (also treated as a string).  includes("the", "he") returns true; includes("dancing", "joy") returns false; includes(1234, 23) returns true 
join(stringToLookIn, string1, string2,...,string99 )  Returns the string formed by concatenating its string arguments, each seperated by its seperator argument.  join("/", m, d, y) returns a date in format "m/d/y" 
repeatString(aString, numRepetitions)  Takes two arguments, the first a string and the second an integer ≥ 0. Returns the result of concatenating aString numRepetitions times.  repeatString("#&", 4) returns “#&#&#&#&” 
replaceChars(aString, start, numChars, substituteString)  Takes four arguments. The first is the original string. The second is an integer > 0 specifying the starting location for the substitution. The third is the number of characters to be replaced, and the last is the string that is to be substituted. If numChars is 0, substituteString is inserted.  replaceChars("computer", 3, 4, "nfus") gives “confuser”. 
replaceString(aString, stringToFind, substituteString)  Takes three string arguments and substitutes the third for all occurrences of the second in the first.  replaceString("12:30:45", ":", " and ") returns “12 and 30 and 45” 
sortItems(list) 
Sorts the items in the list. 
sortItems("2,16,3,4,3") returns "2,3,3,4,16" when comma is the regional list separator sortItems("{T;H;12;2;t;h}", "{;}") returns "{2;12;H;h;T;t}" sortItems("HTHHT", "") returns "HHHTT", because all characters are items when there are no delimiters sortItems(FirstName, caseIndex) returns an alphabetized list of first names 
split(string, seperator, index) 
Returns the string formed by splitting a string by the specified separator and then returning the element at the specified index. Given an attribute “d” that contains strings of the form “mm/dd/yyyy”, split(d,”/",1) returns the month, split(d,”/“,2) returns the day, and split(d,”/“,3) returns the year. 
split(09/01/2016, "/", 1) returns September 
stringLength(string)  Returns the number of characters in the string representation of the argument.  stringLength("Fathom") gives 6. stringLength(321) gives 3 
subString(string, position, length)  Returns a substring of the specified string, determined by its position and length arguments.  substring(abcd,2,3) returns bcd 
toLower(string)  Converts uppercase characters in its argument to lowercase.  toLower(String) returns string 
toUpper(string)  Converts lowercase characters in its argument to uppercase.  toUpper(String) returns STRING 
trim(string)  Removes leading, trailing, and redundant white space characters from its argument. (e.g. double spaces are converted to single spaces).  
Trigonometric Functions 

acos(rad)  Returns the angle in radians that corresponds to the specified arccosine value [–1, 1].  acos(1) returns 0 radians 
asin(rad)  Returns the angle in radians that corresponds to the specified arcsine value [–1, 1].  asin(1) returns 1.57, pi/2 radians 
atan(rad)  Returns the angle in radians that corresponds to the specified arctangent value [–1, 1].  atan(1) returns 0.79, pi/4 radians 
atan2(num1, num2)  Returns the angle in radians between the xaxis and the specified coordinate point. 
atan2(1,1) returns 0.79, pi/4 radians 
cos(num)  Returns the angle in radians that corresponds to the specified cosine value [–1, 1].  cos(0.5) returns 0.88 radians 
sin(rad)  Returns the angle in radians that corresponds to the specified sine value [–1, 1].  sin(pi/2) returns 1 
tan(rad)  Returns the angle in radians that corresponds to the specified tangent value [–1, 1].  tan(pi/4) returns 1 
Add new comment