Doubt about concatenation in the R language

0

I want to use these variables that I'm importing from a table in my function, gecode.

The geocode function behaves like this:        geocode ("Paulista Avenue, 1578 - Bela Vista, Sao Paulo, Brazil")

I wanted to know if there are any R's to use concatenated variables like in PHP that use points.

   library(ggmap)
    library(leaflet)
    library(readxl)

     # no RStudio o diretorio de trabalho corrente do R aponta para o local
    # aonde o script está
    setwd(dirname(rstudioapi::getActiveDocumentContext()$path))

    # le arquivo excel capitais
    Pontos = read_excel("pontos_turisticos.xlsx")  

    nome = Pontos$Nome;
    bairro = Pontos$Bairro;
    endereco = Pontos$Endereço;
    cidade = "Nova Friburgo";
    estado = "RJ";



     geocode("nome[1],bairro[1],endereco[1],cidade,estado");
    
asked by anonymous 17.01.2018 / 00:25

1 answer

2

In R there is a function called paste () I do not know if it is the ideal but it has always answered me.

>paste("Eu", "Quero", "Concatenar")
[1] Eu Quero Concatenar

By default the function uses white space to concatenate vector, but you can use the collapse parameter

>paste(str, collapse = " ")
[1] Eu Quero Concatenar

In your case:

>paste(c(nome[1], bairro[1]), collapse = " ")

or

>str <- c(nome[1], bairro[1])
>paste(str, collapse = " ")

I hope I have helped

    
17.01.2018 / 03:09