I need help, Column 0 Import data

Hi, I need your help, when i import an excel dataset, it always generate the Column 0 as a numbers serie 1,2,3....n, but i need that the first column of the excel dataset (Name of people) will be the Column 0, and i don`t know how to change it.

Thanks.

Hi Jhancarlos, welcome!

To help us help you, could you please prepare a reproducible example (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:

Thanks for your attention,

For example if you use the comand:

data("spainfoot") you get a table where the first column are the names of the football teams

but when I import an excel dataset the first column is a set of numbers (1,2,3,4..n)

That is not a column, those are row_names, Excel doesn't understand that concept that is why you get (1, 2, 3, ..n).

You could manually assign any column as row_names if you need to for some reason, see this example

library(dplyr)
df <- iris %>% group_by(Species) %>% summarise_all(max) %>% as.data.frame()
df
#>      Species Sepal.Length Sepal.Width Petal.Length Petal.Width
#> 1     setosa          5.8         4.4          1.9         0.6
#> 2 versicolor          7.0         3.4          5.1         1.8
#> 3  virginica          7.9         3.8          6.9         2.5
rownames(df) <- df$Species
df
#>               Species Sepal.Length Sepal.Width Petal.Length Petal.Width
#> setosa         setosa          5.8         4.4          1.9         0.6
#> versicolor versicolor          7.0         3.4          5.1         1.8
#> virginica   virginica          7.9         3.8          6.9         2.5

Created on 2019-05-01 by the reprex package (v0.2.1)

2 Likes

Thanks!!! I already can change the row names!!! You saved me...

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.