Anthony W
Anthony W

Reputation: 1327

Problems with ee$List$repeat

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?

Upvotes: 1

Views: 103

Answers (1)

csaybar
csaybar

Reputation: 179

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)
          }
        )    
    )

Upvotes: 3

Related Questions