SparkR filterRDD and flatMap not working
So this is actually a bug in the show method of the RDD in SparkR and I've documented this at https://issues.apache.org/jira/browse/SPARK-7512
However this bug should not affect your computation in any way. So if you instead used
filteredRDD <- SparkR:::filterRDD(textFile, function(line){ grepl("Spark", line)})
then the error message should go away