-2

It's possibly a very stupid question, but I'm getting an error message for this very simple piece of code in R:

  S20_1 = E[sample(1:17260(E), 20),]

The error message is:

Error in sample(1:17260(E), 20) : attempt to apply non-function

E is a data frame with 17260 rows. The code is based on the one found here.

Ben Bolker
  • 211,554
  • 25
  • 370
  • 453
Oksanna88
  • 31
  • 2

1 Answers1

1

The error message tells you exactly what is wrong. Try to change the line into this:

S20_1 = E[sample(nrow(E), 20),]

or, since you already know the size of E

S20_1 = E[sample(1:17260, 20),]

though I would recommend the first method of course.

Hope this helps.

Nikos
  • 3,267
  • 1
  • 25
  • 32