1

I am trying to get the following code to work in Google Earth Engine using the rgee package:

# Load rgee
library(rgee)

# Initialise
ee_users()
ee_Initialize()

# The incorrect use of repeat within an rgee context
ee$List$repeat(1,3)

But I get the error:

Error: unexpected 'repeat' in "ee$List$repeat"

Is it because there is some confusion with repeat in base r?

Anthony W
  • 1,289
  • 2
  • 15
  • 28

1 Answers1

3

For R reserved words use backticks/quotation marks:

    # Load rgee
    library(rgee)
    
    # Initialise
    ee_users()
    ee_Initialize()
    
    # The incorrect use of repeat within an rgee context
    ee$List$'repeat'(1,3)$map( 
        ee_utils_pyfunc( #ee_utils_pyfunc is necessary to apply a map function to an ee$List
          function(x) {
            ee$Number(x)$add(1)
          }
        )    
    )
csaybar
  • 179
  • 1
  • 5