Questions tagged [r-colnames]

114 questions
0
votes
2 answers

Move characters from beginning of column name to end of column name

I have a dataset where column names have prefixes (corresponding to panel waves), e.g. a_age a_sex a_jbstat b_age b_sex b_jbstat I would like to convert the prefixes into suffixes, so that it becomes:…
dbartram
  • 33
  • 5
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
1 answer

R Shiny - How do You present nicely column names?

My all columns contains parameters names like: "all_application", "all_phones" "all_send_forms" It doesn't look nicely in shiny tables. How do You deal with it? I would like to change it to more human names with spaces.
brtk
  • 107
  • 7
0
votes
0 answers

Name a New Data Frame From An Extracted Column Name In A Old Data Frame

My original data frame has 311 columns and ~6,000 rows with the first column being the transaction date and columns 2:311 are the number of daily transactions. I am trying to extract specific column names to subsequently create new data frames based…
Confucion
  • 101
  • 1
  • 1
  • 4
0
votes
2 answers

for each row in a data frame print column name that contains value less than or equal to x and calculate remaining value until next greatest value

I am looking for a way to return the first column name that is greater than or equal to x but less than the next greatest value in each row of a data frame in a new column > df <- data.frame(Loc = c("3120", "3120", "3120"), fld = c("T1", "T2",…
Mlien
  • 1
  • 1
0
votes
1 answer

R - extract submatrix based on column names and row names

I have a matrix, R of the following form. 0 0.44 0.77 0.88 0.99 0 1.00 0.75 0.50 0.25 0 0.5 0.75 0.75 0.50 0.25 0 0.6 0.50 0.50 0.25 0.25 0 0.8 0.00 0.00 0.00 0.00 0 here, colnames(R) [1] "0" "0.44" "0.77" "0.88"…
vip123
  • 1
  • 1
0
votes
1 answer

R: How can one rename columnname of 5 data.frames with 35 columns each at once?

I am using the below R code to simulate time series data, moving average of order 1 to be precise. I am varying 3 variables which are: N = Number of elements in the series c(15L, 20L, 30L, 50L, 100L) SD = standard deviation c(1, 2, 3, 4, 5) ^…
Daniel James
  • 1,381
  • 1
  • 10
  • 28
0
votes
2 answers

How to add same column name for every three column in r?

The following data set has 12 columns. I would like to namebeta_0 C1,beta_1 C1,beta_2 C1 for the first three-column and beta_0 C2,beta_1 C2,beta_2 C2 for second three column, beta_0 C3,beta_1 C3,beta_2 C3 for the third three column and beta_0…
Uddin
  • 754
  • 5
  • 18
0
votes
1 answer

How to name a column using cbind, in a loop

I am using a loop to rename columns using cbind. Every time I attempt to name the column using the loop indices (i), it does not use the indices and instead puts in i for the column names. I want it to display the actual names from the original x…
Sharif Amlani
  • 1,138
  • 1
  • 11
  • 25
0
votes
1 answer

import column name and data with separate files in R

I would like to import a txt file only contains one line as table column name and append with the other csv file with only data. The simplified files are as below: txt file Precentral Frontal_Sup Frontal_Sup_Orb and the csv file 0.9938 0.96507…
kmY
  • 89
  • 1
  • 10
0
votes
1 answer

Using order in R dataframes fails after column names have been changed. how can I recover this?

Setup dataframe mta<-c("ldall","nold","ldall","nold","ldall","nold","ldall","nold") mtb<-c(491, 28581,241,5882,365,7398,512,10887) df1<-data.frame(mta,mtb) I can order my dataframe in the normal way. This works fine. df1[order(mtb),] But if I…
0
votes
1 answer

Why R Changes Special Characters In Column Name To Dots

I have a larger data set which when I import to R has column names with , and different types of special characters. When I use this data set as copy in another variable or as subset to another smaller data or performing different kind of data…
Chetan Arvind Patil
  • 854
  • 1
  • 11
  • 31
0
votes
2 answers

Create names for new columns within a loop

I am adding together every third column and putting the result in a new column, I have to do this across a data frame with over 300 columns. I can make the loop to perform the addition but I'm having trouble with naming the new columns. Here's an…
pd441
  • 2,644
  • 9
  • 30
  • 41
0
votes
1 answer

Change column names in list of list of data frames using lapply

This is a follow-up to this question: Create scatter plot with interval data in R I would like to change the column names in the following data.frames, that are part of a list of lists: other_list #a list of arbitrary length containing some…
user6475
  • 31
  • 1
  • 11
0
votes
0 answers

Change the last value of all column names of a dataframe

I have a dataframe, which looks like follows: # Example data data <- data.frame(x1.1 = rnorm(10), x2.1 = rnorm(10), x3.1 = rnorm(10)) I want to change the last value ".1" of all column names to ".2". It is…
Joachim Schork
  • 2,025
  • 3
  • 25
  • 48