Monthly Archives: April 2011

R function for sorting NAs and data in each row of a Matrix

by Chris Fariss

# —– naSortMatrix function —————————— #
# —– by Chris Fariss ———————————— #
#
# Takes a data frame or matrix as an argument
# and returns another matrix after moving any NAs
# within each matrix row to the right of the data
# in that row without changing the order of the
# data. Also calculates the time taken to complete
# the sort and saves it as a global variable:
# naSortMatrix.time
#
# Just copy and paste this during an R session to
# use the function
#
# ——————————————————– #
Continue reading