[R] error with the expand.grid command

MacQueen, Don m@cqueen1 @end|ng |rom ||n|@gov
Thu Aug 9 18:45:32 CEST 2018


In my experience, error messages that reference a closure usually mean that you have supplied a function where you aren't supposed to.

In this case, I'd look and see if lon, lat, or time is a function (by accident, of course).

More specifically, right now in one of my R sessions, I get:

> class(time)
[1] "function"
> find('time')
[1] "package:stats"

--
Don MacQueen
Lawrence Livermore National Laboratory
7000 East Ave., L-627
Livermore, CA 94550
925-423-1062
Lab cell 925-724-7509
 
 

On 8/8/18, 11:20 PM, "R-help on behalf of Mayur Tade" <r-help-bounces using r-project.org on behalf of mayur.tade using gmail.com> wrote:

     hello sir...
    i am trying to extract the chlorophyll data of particular lat and lon from
    the world chlorophyll data from the netcdf file in R. as i am new to R i am
    facing the problem related to it when i am trying expand.grid command it is
    showing me this message.....message is followed.....its my kind request
    please help me with the same
    ttt<-expand.grid(lon,lat,time)
    Error in paste0(nmc[i], "=", if (is.numeric(x)) format(x) else x) :
      cannot coerce type 'closure' to vector of type 'character'
    
    here is the print of my netcdf file for you kind information.....follow...
    
    > print(tt)
    File E:\chlorophyll data research student..mayur
    t..KUFOS\1997\ESACCI-OC-L3S-CHLOR_A-MERGED-1M_MONTHLY_4km_
    GEO_PML_OCx-199709-fv3.1.nc
    <http://esacci-oc-l3s-chlor_a-merged-1m_monthly_4km_geo_pml_ocx-199709-fv3.1.nc/>
    (NC_FORMAT_NETCDF4_CLASSIC):
    
         9 variables (excluding dimension variables):
            float MERIS_nobs_sum[lon,lat,time]
                _FillValue: 0
                long_name: Count of the number of observations from the MERIS
    sensor contributing to this bin cell
                number_of_files_composited: 19
            float MODISA_nobs_sum[lon,lat,time]
                _FillValue: 0
                long_name: Count of the number of observations from the MODIS
    (Aqua) sensor contributing to this bin cell
                number_of_files_composited: 19
            float SeaWiFS_nobs_sum[lon,lat,time]
                _FillValue: 0
                long_name: Count of the number of observations from the SeaWiFS
    (GAC and LAC) sensor contributing to this bin cell
                number_of_files_composited: 19
            float VIIRS_nobs_sum[lon,lat,time]
                _FillValue: 0
                long_name: Count of the number of observations from the VIIRS
    sensor contributing to this bin cell
                number_of_files_composited: 19
            float chlor_a[lon,lat,time]
                _FillValue: 9.96920996838687e+36
                long_name: Chlorophyll-a concentration in seawater (not
    log-transformed), generated by SeaDAS using a blended combination of OCI
    (OC4v6 + Hu's CI), OC3 and OC5, depending on water class memberships
                units: milligram m-3
                ancillary_variables: chlor_a_log10_rmsd chlor_a_log10_bias
                grid_mapping: crs
                standard_name: mass_concentration_of_chlorophyll_a_in_sea_water
                units_nonstandard: mg m^-3
                parameter_vocab_uri:
    http://vocab.nerc.ac.uk/collection/P04/current/
            float chlor_a_log10_bias[lon,lat,time]
                _FillValue: 9.96920996838687e+36
                long_name: Bias of log10-transformed chlorophyll-a concentration
    in seawater.
                grid_mapping: crs
                rel: uncertainty
                comment: Uncertainty lookups derived from file:
    /data/datasets/CCI/v3.1-production/stage09b-uncertainty_tables/chlor_a/
    cci_chla_bias.dat
                ref: http://www.esa-oceancolour-cci.org/?q=webfm_send/581
            float chlor_a_log10_rmsd[lon,lat,time]
                _FillValue: 9.96920996838687e+36
                long_name: Root-mean-square-difference of log10-transformed
    chlorophyll-a concentration in seawater.
                grid_mapping: crs
                rel: uncertainty
                comment: Uncertainty lookups derived from file:
    /data/datasets/CCI/v3.1-production/stage09b-uncertainty_tables/chlor_a/
    cci_chla_rmsd.dat
                ref: http://www.esa-oceancolour-cci.org/?q=webfm_send/581
            int crs[time]
                grid_mapping_name: latitude_longitude
            float total_nobs_sum[lon,lat,time]
                _FillValue: 0
                long_name: Count of the total number of observations
    contributing to this bin cell
                number_of_files_composited: 19
    
         3 dimensions:
            time  Size:1
                axis: T
                standard_name: time
                units: days since 1970-01-01 00:00:00
            lat  Size:4320
                units: degrees_north
                long_name: latitude
                standard_name: latitude
                valid_min: -89.9791641235352
                valid_max: 89.9791641235352
                axis: Y
            lon  Size:8640
                units: degrees_east
                long_name: longitude
                standard_name: longitude
                valid_min: -179.97917175293
                valid_max: 179.97917175293
                axis: X
    
        47 global attributes:
            Metadata_Conventions: Unidata Dataset Discovery v1.0
            cdm_data_type: Grid
            comment: See summary attribute
            creator_email: help using esa-oceancolour-cci.org
            creator_name: Plymouth Marine Laboratory
            creator_url: http://esa-oceancolour-cci.org
            geospatial_lat_max: 90
            geospatial_lat_min: -90
            geospatial_lat_resolution: .04166666666666666666
            geospatial_lat_units: decimal degrees north
            geospatial_lon_max: 180
            geospatial_lon_min: -180
            geospatial_lon_resolution: .04166666666666666666
            geospatial_lon_units: decimal degrees east
            geospatial_vertical_max: 0
            geospatial_vertical_min: 0
            institution: Plymouth Marine Laboratory
            keywords: satellite,observation,ocean,ocean colour
            keywords_vocabulary: none
            license: ESA CCI Data Policy: free and open access.  When
    referencing, please use: Ocean Colour Climate Change Initiative dataset,
    Version <Version Number>, European Space Agency, available online at
    http://www.esa-oceancolour-cci.org.  We would also appreciate being notified
    of publications so that we can list them on the project website at
    http://www.esa-oceancolour-cci.org/?q=publications
            naming_authority: uk.ac.pml
            number_of_optical_water_types: 14
            platform: Orbview-2,Aqua,Envisat,Suomi-NPP
            processing_level: Level-3
            project: Climate Change Initiative - European Space Agency
            references: http://www.esa-oceancolour-cci.org/
            sensor: SeaWiFS,MODIS,MERIS,VIIRS
            source: NASA SeaWiFS L2 R2014.0 LAC and GAC, MODIS-Aqua L1A, MERIS
    L1B 3rd reprocessing inc OCL corrections, NASA VIIRS L2 R2014.0.1 (data
    identical to R2014.0.2)
            spatial_resolution: 4km nominal at equator
            standard_name_vocabulary: NetCDF Climate and Forecast (CF) Metadata
    Conventions Version 1.6
            title: ESA CCI Ocean Colour Product
            number_of_files_composited: 19
            creation_date: Tue Aug 23 09:00:23 2016
            date_created: Tue Aug 23 09:00:23 2016
            time_coverage_resolution: P1M
            time_coverage_duration: P1M
            start_date: 01-SEP-1997 00:00:00.000000
            stop_date: 30-SEP-1997 23:59:00.000000
            time_coverage_start: 199709010000Z
            time_coverage_end: 199709302359Z
            netcdf_file_type: NETCDF4_CLASSIC
            history: Source data were:
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970904-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970904-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970906-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970906-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970909-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970909-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970910-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970910-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970915-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970915-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970916-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970916-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970918-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970918-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970919-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970919-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970920-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970920-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970921-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970921-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970922-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970922-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970923-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970923-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970924-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970924-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970925-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970925-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970926-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970926-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970927-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970927-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970928-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970928-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970929-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970929-fv3.1.nc/>
    ,
    ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1D_DAILY_4km_GEO_PML_
    OCx_QAA-19970930-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1d_daily_4km_geo_pml_ocx_qaa-19970930-fv3.1.nc/>
    ;
    netcdf_compositor_cci composites  Rrs_412, Rrs_443, Rrs_490, Rrs_510,
    Rrs_555, Rrs_670, water_class1, water_class2, water_class3, water_class4,
    water_class5, water_class6, water_class7, water_class8, water_class9,
    water_class10, water_class11, water_class12, water_class13, water_class14,
    atot_412, atot_443, atot_490, atot_510, atot_555, atot_670, aph_412,
    aph_443, aph_490, aph_510, aph_555, aph_670, adg_412, adg_443, adg_490,
    adg_510, adg_555, adg_670, bbp_412, bbp_443, bbp_490, bbp_510, bbp_555,
    bbp_670, chlor_a, kd_490, chlor_a_log10_bias, Rrs_412_bias, Rrs_443_bias,
    Rrs_490_bias, Rrs_510_bias, Rrs_555_bias, Rrs_670_bias, aph_412_bias,
    aph_443_bias, aph_490_bias, aph_510_bias, aph_555_bias, aph_670_bias,
    adg_412_bias, adg_443_bias, adg_490_bias, adg_510_bias, adg_555_bias,
    adg_670_bias, kd_490_bias with --mean,  chlor_a_log10_rmsd, Rrs_412_rmsd,
    Rrs_443_rmsd, Rrs_490_rmsd, Rrs_510_rmsd, Rrs_555_rmsd, Rrs_670_rmsd,
    aph_412_rmsd, aph_443_rmsd, aph_490_rmsd, aph_510_rmsd, aph_555_rmsd,
    aph_670_rmsd, adg_412_rmsd, adg_443_rmsd, adg_490_rmsd, adg_510_rmsd,
    adg_555_rmsd, adg_670_rmsd, kd_490_rmsd with --root-mean-square, and
    SeaWiFS_nobs, MODISA_nobs, MERIS_nobs, VIIRS_nobs, total_nobs - with --total
    1471940520 Subsetted from
    standardised_geo/ESACCI-OC-L3S-OC_PRODUCTS-MERGED-1M_
    MONTHLY_4km_GEO_PML_OCx_QAA-199709-fv3.1.nc
    <http://esacci-oc-l3s-oc_products-merged-1m_monthly_4km_geo_pml_ocx_qaa-199709-fv3.1.nc/>
    to only include variables
    MERIS_nobs_sum,MODISA_nobs_sum,SeaWiFS_nobs_sum,VIIRS_
    nobs_sum,chlor_a,chlor_a_log10_bias,chlor_a_log10_rmsd,
    crs,lat,lon,time,total_nobs_sum
            Conventions: CF-1.6
            product_version: 3.1
            summary: Data products generated by the Ocean Colour component of
    the European Space Agency Climate Change Initiative project. These files are
    daily composites of merged sensor (MERIS, MODIS Aqua, SeaWiFS LAC & GAC,
    VIIRS) products.  MODIS Aqua and MERIS were band-shifted and bias-corrected
    to SeaWiFS bands and values using a temporally and spatially varying scheme
    based on the overlap years of 2003-2007.  VIIRS was band-shifted and
    bias-corrected in a second stage against the MODIS Rrs that had already been
    corrected to SeaWiFS levels, for the overlap period 2012-2013.  VIIRS and
    SeaWiFS Rrs were derived from standard NASA L2 products; MERIS and MODIS
    from a combination of NASA's l2gen (for basic sensor geometry corrections,
    etc) and HYGEOS Polymer v3.5 (for atmospheric correction).  The Rrs were
    binned to a sinusoidal 4km level-3 grid, and later to 4km geographic
    projection, by Brockmann Consult's BEAM.  Derived products were generally
    computed with the standard SeaDAS algorithms.  QAA IOPs were derived using
    the standard SeaDAS algorithm but with a modified backscattering table to
    match that used in the bandshifting.  The final chlorophyll is a combination
    of OC4, Hu's CI and OC5, depending on the water class memberships.
    Uncertainty estimates were added using the fuzzy water classifier and
    uncertainty estimation algorithm of Tim Moore as documented in Jackson et al
    (2017).
            tracking_id: 659b397a-953c-4814-a3e2-460d6218fcfa
            id:
    ESACCI-OC-L3S-CHLOR_A-MERGED-1M_MONTHLY_4km_GEO_PML_OCx-199709-fv3.1.nc
    <http://esacci-oc-l3s-chlor_a-merged-1m_monthly_4km_geo_pml_ocx-199709-fv3.1.nc/>
    
    	[[alternative HTML version deleted]]
    
    ______________________________________________
    R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
    https://stat.ethz.ch/mailman/listinfo/r-help
    PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
    and provide commented, minimal, self-contained, reproducible code.
    



More information about the R-help mailing list