How to store table names in a Vector in R

Asked

Viewed 86 times

2

I need to store the names of a table in an array, as I will need to make combinations with the names. Here is an example for understanding:

Table:

Carro  preço  cor
Gol   15000  vermelho
uno   14000  azul
corsa 13000  verde

vector I want at the end:

Vetor --> (Carro,preço,cor)

I will work with tables with many columns, which will change name many times, so I need a code to let automatic vector creation.

1 answer

5

Table names can be accessed with the function names().

nomes <- names(Tabela)

nomes
# [1] "Carro" "preço" "cor"

Browser other questions tagged

You are not signed in. Login or sign up in order to post.