Support Questions
Find answers, ask questions, and share your expertise

Zeppelin+ SparkR

I'm getting an error when processing a function-sample() in SparkR on Zeppelin notebook, the error is attached below. It works fine on R commands directly on server, but the problem is when this code is running thru Zeppelin R Interpreter. Am I missing a configuration on Zeppelin Spark Interpreter?

I have spark 2.1, and HDP 2.6 running on RHL 7 OS.

%spark2.r
n<-1:100
n
cs <- sample(15)
cs

[1]   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17
 [18]  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34
 [35]  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51
 [52]  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68
 [69]  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85
 [86]  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100

Error in (function (classes, fdef, mtable) : unable to find an inherited method for function 'sample' for signature '"numeric", "missing", "missing"'


Error in eval(expr, envir, enclos): object 'cs' not found
1 REPLY 1

New Contributor

have the same error while using sparkR shell on HDP 2.4. sample() exists but doesn't work for even basic usage.

65020-sparkrsample.png

Edit: I just discovered that you have to explicitly state the package name for some functions because of naming conflicts:

https://spark.apache.org/docs/1.6.0/sparkr.html#r-function-name-conflicts

This includes sample. access with base::sample()

; ;