Here are a few code snippets: The data frame looks like this:
kfz zeit datum latitude longitude 1 ######### 2015-02-09 07:18:33 2015-02-09 52.35234 9.881965 2 ######### 2015-02-09 07:18:34 2015-02-09 52.35233 9.881970 3 ######### 2015-02-09 07:18:35 2015-02-09 52.35232 9.881975 4 ######### 2015-02-09 07:18:36 2015-02-09 52.35232 9.881972 5 ######### 2015-02-09 07:18:37 2015-02-09 52.35231 9.881973 6 ######### 2015-02-09 07:18:38 2015-02-09 52.35231 9.881978 I call this function with a number (position in the data frame) and a data frame: dirs <- function(x, dat){ direction(startLat = dat[x,4], endLat = dat[x+1,4], startLon = dat[x,5], endLon = dat[x+1,5]) } Here I get the error with the S4 class not subsettable. This function calls another function which does the actual calculation: direction <- function(startLat, endLat, startLon, endLon){ startLat <- degrees.to.radians(startLat); startLon <- degrees.to.radians(startLon); endLat <- degrees.to.radians(endLat); endLon <- degrees.to.radians(endLon); dLon <- endLon - startLon; dPhi <- log(tan(endLat / 2 + pi / 4) / tan(startLat / 2 + pi / 4)); if (abs(dLon) > pi) { if (dLon > 0) { dLon <- -(2 * pi - dLon); } else { dLon <- (2 * pi + dLon); } } bearing <- radians.to.degrees((atan2(dLon, dPhi) + 360 )) %% 360; return (bearing); } Anything more you need? -- View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/SparkR-API-problem-with-subsetting-distributed-data-frame-tp27688p27691.html Sent from the Apache Spark User List mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe e-mail: user-unsubscr...@spark.apache.org