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 repr oducible ex ample (reprex) illustrating your issue? Please have a look at this guide, to see how to create one:
A minimal reproducible example consists of the following items:
A minimal dataset, necessary to reproduce the issue
The minimal runnable code necessary to reproduce the issue, which can be run
on the given dataset, and including the necessary information on the used packages.
Let's quickly go over each one of these with examples:
Minimal Dataset (Sample Data)
You need to provide a data frame that is small enough to be (reasonably) pasted on a post, but big enough to reproduce your issue.
Let's say, as an example, that you are working with the iris data frame
head(iris)
#> Sepal.Length Sepal.Width Petal.Length Petal.Width Species
#> 1 5.1 3.5 1.4 0.…
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...
system
Closed
May 22, 2019, 9:17pm
6
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.