Having trouble with changing values in variable to uppercase

Hi, just a little background context. I am conducting an analysis utilizing geo-spatial dataframes. My current issue is to join dataframes together, however i need to convert my spatial join ID (name of location) to uppercase but for some reason i am having tons of trouble - i have tried toupper() but its not working. See below for my reprex and datapasta, any help appreciated.

library(tidyverse)
library(datapasta)
dp_neigh <- tibble::tribble(
~the_geom,            ~Name,  ~ID,
                  "MULTIPOLYGON (((-97.101068054847 49.904738664792, -97.101119462733 49.904456236955, -97.101257540021 49.90418431683, -97.101460136755 49.903950880562, -97.10176613496 49.903721309945, -97.102002344004 49.903593807876, -97.102993217405 49.903084546396, -97.101364500617 49.903349435214, -97.099208705274 49.903700018025, -97.098657907868 49.903789560247, -97.095258438012 49.904341988246, -97.094945805384 49.904392289705, -97.088519375967 49.905426185365, -97.088129972782 49.905498698569, -97.080791922232 49.906689245819, -97.081075493802 49.906783365386, -97.081080060473 49.906784881086, -97.081369804699 49.906884119339, -97.09366465814 49.910961085747, -97.093686602955 49.910943716666, -97.093697911443 49.910947468794, -97.093786970232 49.910977014823, -97.093940217125 49.911027855569, -97.093918257773 49.911045228152, -97.094109289129 49.911108615638, -97.100590517773 49.90597997387, -97.100776314372 49.905799072517, -97.100931449308 49.905577498982, -97.101017854888 49.905371946913, -97.101057633481 49.905126025972, -97.101068054847 49.904738664792)))",    "Talbot-Grey", 1012,
                                                                                                                                                                                             "MULTIPOLYGON (((-97.213977751417 49.768105484827, -97.188009274445 49.768178937009, -97.185490571405 49.768230153332, -97.182919126657 49.768464403909, -97.182523426765 49.768543454196, -97.192275027527 49.784920015316, -97.192711129042 49.784771081681, -97.192973912857 49.784681335708, -97.193147226559 49.78462214545, -97.194073994454 49.784305627404, -97.195892334197 49.783684577947, -97.199463300795 49.782464793264, -97.20814382323 49.77949894561, -97.213548480417 49.777651836706, -97.213967417106 49.777508645519, -97.21397609447 49.76865359624, -97.213977751417 49.768105484827)))", "Prairie Pointe", 1727
                  )
df_neigh_clean <- dp_neigh %>% 
  toupper(Name)
#> Error in toupper(., Name): unused argument (Name)

Created on 2020-02-11 by the reprex package (v0.3.0)

You just have a small syntax problem, that is not the way to use toupper(), you have to use it inside a mutate() statement.

library(tidyverse)

dp_neigh <- tibble::tribble(
    ~the_geom,            ~Name,  ~ID,
    "MULTIPOLYGON (((-97.101068054847 49.904738664792, -97.101119462733 49.904456236955, -97.101257540021 49.90418431683, -97.101460136755 49.903950880562, -97.10176613496 49.903721309945, -97.102002344004 49.903593807876, -97.102993217405 49.903084546396, -97.101364500617 49.903349435214, -97.099208705274 49.903700018025, -97.098657907868 49.903789560247, -97.095258438012 49.904341988246, -97.094945805384 49.904392289705, -97.088519375967 49.905426185365, -97.088129972782 49.905498698569, -97.080791922232 49.906689245819, -97.081075493802 49.906783365386, -97.081080060473 49.906784881086, -97.081369804699 49.906884119339, -97.09366465814 49.910961085747, -97.093686602955 49.910943716666, -97.093697911443 49.910947468794, -97.093786970232 49.910977014823, -97.093940217125 49.911027855569, -97.093918257773 49.911045228152, -97.094109289129 49.911108615638, -97.100590517773 49.90597997387, -97.100776314372 49.905799072517, -97.100931449308 49.905577498982, -97.101017854888 49.905371946913, -97.101057633481 49.905126025972, -97.101068054847 49.904738664792)))",    "Talbot-Grey", 1012,
    "MULTIPOLYGON (((-97.213977751417 49.768105484827, -97.188009274445 49.768178937009, -97.185490571405 49.768230153332, -97.182919126657 49.768464403909, -97.182523426765 49.768543454196, -97.192275027527 49.784920015316, -97.192711129042 49.784771081681, -97.192973912857 49.784681335708, -97.193147226559 49.78462214545, -97.194073994454 49.784305627404, -97.195892334197 49.783684577947, -97.199463300795 49.782464793264, -97.20814382323 49.77949894561, -97.213548480417 49.777651836706, -97.213967417106 49.777508645519, -97.21397609447 49.76865359624, -97.213977751417 49.768105484827)))", "Prairie Pointe", 1727
)

dp_neigh %>%
    mutate(Name = toupper(Name))
#> # A tibble: 2 x 3
#>   the_geom                                                     Name           ID
#>   <chr>                                                        <chr>       <dbl>
#> 1 MULTIPOLYGON (((-97.101068054847 49.904738664792, -97.10111… TALBOT-GREY  1012
#> 2 MULTIPOLYGON (((-97.213977751417 49.768105484827, -97.18800… PRAIRIE PO…  1727

Created on 2020-02-12 by the reprex package (v0.3.0.9001)

2 Likes

thank you kindly @andresrcs! The more I learn day by day :slight_smile:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.