Questions tagged [r-rownames]

The `rownames()` method in R is used to rename and replace the row names of a matrix-like object (incl. data frames) .

113 questions
0
votes
1 answer

Merging multiple csvs in R with index based on the file name

I am trying to merge several csv files with the same columns in R. I tried the solution proposed in : Merging of multiple excel files in R and works perfectly. However, I would like to add an index column (row name) to identify which file each row…
Anna
  • 177
  • 13
0
votes
1 answer

How to make name a row name in R dataframe without modifications

I am making one of the column names to be a row name in data frame in R. However, whenever I am making the same, X is adding up before the numbers, hyphens (-) are replaced by dots (.) Is there a way to handle this in R, to keep the name as it is…
0
votes
1 answer

Return corresponding row name instead of data in r

apologies in advance, I am a beginner trying to learn. I have a dataframe which I have performed the max() function to return the maximum number of a particular column however I would like to return the corresponding row name of the max number as…
Low
  • 29
  • 4
0
votes
2 answers

How to rename row names in data from Eurostat in R

I downloaded data from Eurostat to R. In one column I have abbreviated country names, I found how to display full names. But I need to change these row names to show in a different language. I don't care about a specific function, I can do it…
ozi
  • 1
0
votes
1 answer

How to use dataframes from loophole result in R

By assigning date_[c], I have 35 "date_c"'s(below code). for (c in 1:nrow(datetable2)) { assign(paste("date_",c,sep=""),dt2[which(dt2$Date==datetable2$Date[c]),]) } Now, I want to change each "date_c"'s rownames to 1:length(date_c). I used…
YJP
  • 67
  • 9
0
votes
1 answer

add_rownnames works, but rownames_to_column does not

I have a large dataframe that I summarize using describe to create a new summary dataframe df_sum <- describe(df[my_subset]) I check to see that df_sum has row names has_rownames(df_sum) [1] TRUE Browse[2]> rownames(df_sum) [1] "Q1" …
Thomas Philips
  • 935
  • 2
  • 11
  • 22
0
votes
1 answer

When I remove the first column, row.names are removed too?

df <- data.frame(col1=c('row1','row2','row3'),col2=c(1,1,1),col3=c(0,0.5,2)) > row.names(df) <- df$col1 > df col1 col2 col3 row1 row1 1 0.0 row2 row2 1 0.5 row3 row3 1 2.0 > df <- select(df, -starts_with("col1")) > df col2…
takeITeasy
  • 350
  • 3
  • 19
0
votes
1 answer

R: Surrogate for selecting rownames on a tibble column

The question is how to use a column on a tibble to select the whole row. The code below shows what I normally do using basic R functions to index rows I want to eliminate form the data frame dataMet. I was wondering if I can use tidyverse functions…
AGV
  • 17
  • 8
0
votes
1 answer

R why does matrix with duplicated / repeating rownames show up with dots and numbers?

I have made some pairwise calculations and stored them in a matrix. Now I would like to label each row and column using some group labels. name <- c("one name", "two name", "three name", "four name") group <- c("group a", "group a", "group b",…
LRO
  • 79
  • 6
0
votes
2 answers

To solve the problem of getting factor variable rather than integer after using "row_to_names" in r

series model for predicting yield and putting them into other formulas to generate cash rents forecast. I want to show the counties' names in the columns and the years in rows in a dataframe. So I have a vector containing 3 counties' names which all…
Kay Lee
  • 1
  • 1
0
votes
2 answers

USArrests data.frame in R - which state (row) presents the smallest and the largest crime rate (column)

I am using the USArrests data.frame in R and I need to see for each crime (Murder, Assault and Rape) which state presents the smallest and the largest crime rate. I guess I have to calculate the max and min for each crime and I have done that.…
Rita
  • 45
  • 3
0
votes
1 answer

Relabel of rowname column in R dataframe

When I bind multiple dataframes together using Out2 = do.call(rbind.data.frame, Out), I obtain the following output. How do I relabel the first column such that it only contains the numbers within the square brackets, i.e. 1 to 5 for each trial…
sjedi
  • 43
  • 1
  • 7
0
votes
3 answers

Filter a Data.frame based on Rownames

c <- data.frame("c1"=c(78,89,0),"c2"=c(89,89,34),"c3"=c(56,0,4)) row.names(c) <- c("zebra","fish","zucchini") c <- rm(grep("z",rownames(c))) ?? hopefully short question, short answer: What is wrong with the above code? It says me "must contain…
takeITeasy
  • 350
  • 3
  • 19
0
votes
1 answer

Adding additional Rows to DF

I have a completed working script, however i would like to add additional rows to the script. Same error happens in colnames additions adding the new ones & redirecting to fresh…
HP.
  • 37
  • 5
0
votes
1 answer

Renaming Rownames/Colnames of matrix `x` by matching column 1 in dataframe `y` and inserting column 3

I have two dataframes. One is a matrix with column and row titles, the other dataframe is the metadata of the matrix. The current row and column names of the matrix are accession numbers, but I have other names in the dataframe that I was to use in…