0

I've tried merge and update columns values with this code. For now the joined fields are correct. (#1)

Now I want update the fields of column.x with values in column.y.

I'm using the second part (#2) but without success.

#1 - code to merge table 'parcelas_sql' with 'tbd_con_sig' by 'codigo'

join_sig_csv <- merge(parcelas_sql, tbd_cons_sig, by.x = "codigo", by.y = "codigo", duplicateGeoms=TRUE)

#2 - update field 'n.cont.x' with 'n.cont.y' values

join_sig_csv[join_sig_csv$n.cont.x == n.cont.x] <- n.cont.y

error_message:
Error in h(simpleError(msg, call)) : 
  error in evaluating the argument 'i' in selecting a method for function '[<-': object 'n.cont.x' not found

--------------------------------------  sessionInfo() -----------------

version 4.1.2 (2021-11-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1

Matrix products: default

locale:
[1] LC_COLLATE=Portuguese_Portugal.1252  LC_CTYPE=Portuguese_Portugal.1252    LC_MONETARY=Portuguese_Portugal.1252 LC_NUMERIC=C                        
[5] LC_TIME=Portuguese_Portugal.1252    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] RODBC_1.3-19    maptools_1.1-4  sf_1.0-7        terra_1.5-21    spData_2.0.1    rgdal_1.5-32    rgeos_0.5-9     sp_1.4-6        rvest_1.0.2     showtext_0.9-5 
[11] showtextdb_3.0  sysfonts_0.8.8  classInt_0.4-3  tmap_3.3-3      lubridate_1.8.0 fs_1.5.2        forcats_0.5.1   stringr_1.4.0   dplyr_1.0.7     purrr_0.3.4    
[21] readr_2.1.1     tidyr_1.1.4     tibble_3.1.6    ggplot2_3.3.5   tidyverse_1.3.1

loaded via a namespace (and not attached):
 [1] RColorBrewer_1.1-2      httr_1.4.2              tools_4.1.2             backports_1.4.1         utf8_1.2.2              R6_2.5.1               
 [7] KernSmooth_2.23-20      DBI_1.1.2               colorspace_2.0-2        raster_3.5-15           withr_2.4.3             tidyselect_1.1.1       
[13] leaflet_2.1.1           compiler_4.1.2          leafem_0.2.0            cli_3.1.0               xml2_1.3.3              scales_1.1.1           
[19] proxy_0.4-26            digest_0.6.29           foreign_0.8-81          base64enc_0.1-3         dichromat_2.0-0.1       pkgconfig_2.0.3        
[25] htmltools_0.5.2         dbplyr_2.1.1            fastmap_1.1.0           htmlwidgets_1.5.4       rlang_0.4.12            readxl_1.3.1           
[31] rstudioapi_0.13         generics_0.1.1          jsonlite_1.7.2          crosstalk_1.2.0         magrittr_2.0.1          Rcpp_1.0.7             
[37] munsell_0.5.0           fansi_0.5.0             abind_1.4-5             lifecycle_1.0.1         stringi_1.7.6           leafsync_0.1.0         
[43] tmaptools_3.1-1         grid_4.1.2              parallel_4.1.2          crayon_1.4.2            lattice_0.20-45         stars_0.5-5            
[49] haven_2.4.3             hms_1.1.1               pillar_1.6.4            codetools_0.2-18        reprex_2.0.1            XML_3.99-0.8           
[55] glue_1.6.0              leaflet.providers_1.9.0 modelr_0.1.8            png_0.1-7               vctrs_0.3.8             tzdb_0.2.0             
[61] cellranger_1.1.0        gtable_0.3.0            assertthat_0.2.1        lwgeom_0.2-8            broom_0.7.11            e1071_1.7-9            
[67] class_7.3-19            viridisLite_0.4.0       units_0.8-0             ellipsis_0.3.2     
MrFlick
  • 195,160
  • 17
  • 277
  • 295
  • It's easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. – MrFlick Jun 02 '22 at 15:14
  • @MrFlick hope this update can provide a reproducible example as you say. – Edgar Figueira Jun 02 '22 at 16:23
  • No. this does not help. There is no data here so it's still not reproducible. We need something we can copy/paste into R so we can run and test the code ourselves. – MrFlick Jun 02 '22 at 19:16

0 Answers0