1

我正在尝试使用该rgee软件包使以下代码在 Google Earth Engine 中工作:

# Load rgee
library(rgee)

# Initialise
ee_users()
ee_Initialize()

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

但我得到了错误:

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

是因为repeat在base r中有一些混淆吗?

4

1 回答 1

2

对于 R 保留字,请使用反引号/引号:

    # 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)
          }
        )    
    )
于 2020-11-30T16:01:26.560 回答