Skip to main content

Questions tagged [r-colnames]

The tag has no usage guidance.

r-colnames
2 votes
5 answers
65 views

How to access row and column names (year and month) from a (monthly) time series, when rownames and colnames fail?

In monthly time series (frequency = 12), R prints out the years and months automatically, arranging them to look like row names and column names. But they are not accessible through rownames or ...
dolphingang's user avatar
1 vote
4 answers
73 views

Replacing elements of column names with associated strings

I have a data.table with automatically generated column names. The names take the form: N.x.y.z Where N is a character (literally N), and the remaining variables are integers. I also have a .csv which ...
Digitalis2512's user avatar
0 votes
3 answers
39 views

create new columns based on the column names in tidyverse

My data set has columns where the variable categories are mentioned, for eg: column name is "Shrawan 2071 -Dog Bite". Here "Shrawan" is the month "2071" is a year and &...
Rakesh Chand's user avatar
0 votes
1 answer
34 views

colnames() inconsistent with name in dataframe

I have the oddest problem, it's never happened to me before and I haven't found any solution yet. I'm working on a dataframe where several columns have similar names (S1Q1.pre / S1Q1.post, S1Q2.pre/...
Vetepi's user avatar
  • 11
2 votes
2 answers
54 views

loop regression when column names have special characters

Dummy data shown below. I tried amending my loop regression code to account for spaces in the column names, but it still gives an error. Additionally, I'm not sure how to adjust .x to account for ...
sjedi's user avatar
  • 67
0 votes
2 answers
50 views

print column name when specific row of a column contains string in R

I have the following dataset A B C D 1! 0! 1! 0! 0! . 1! 1! I need to print the column name to each match as follows matches_1 matches_0 A,C B,D C,D A I'...
Gabriel G.'s user avatar
1 vote
2 answers
47 views

Ordering rows and columns of R Matrix

I have a matrix in R like this: bio1 bio10 bio11 bio12 bio13 bio14 bio15 bio16 bio17 bio18 bio19 bio2 bio3 bio4 bio5 bio6 bio7 bio8 bio9 bio1 1.00 0.90 0.91 -0.40 -0.21 -0.54 0.71 -0.22 -...
Burak Suiçmez's user avatar
2 votes
4 answers
81 views

Why does R colnames ignore the vector with specified names and only pay attention to the index?

I came across some weird behavior in R. Imagine that I have this data frame, and I want to change the names of the columns by using colnames and a vector: df <- data.frame(a = seq(1,10), b = seq(11,...
mauraeh's user avatar
  • 37
1 vote
2 answers
75 views

Merge multiple dataframes while retaining their names as column names?

I'm trying to import multiple CSV files in the RStudio while keeping their filenames. library(readr) library(dplyr) library(purrr) #importing all csv files at once csv_files = list.files(pattern =&...
Debajyoti Kabiraj's user avatar
2 votes
3 answers
123 views

cbind() - how to label a vector dynamically in one line

Consider: cbind("1" = 1:4) ## giving. 1 [1,] 1 [2,] 2 [3,] 3 [4,] 4 What I am trying to achieve is replacing "1" with a function that returns a character expression, e.g. ...
clp's user avatar
  • 1,460
1 vote
2 answers
57 views

Concatenate 2 dataframe in alternate way ( first column of first dataframe, first column of second dataframe and so on but with column names unchanged

Hello i am new to R programming and i am stuck with one problem. I would like to combine 2 dataframe into a new one in this way. First column of first dataframe, first column of second dataframe and ...
Tommaso Roncacci's user avatar
1 vote
2 answers
60 views

When is it necessary to use quotation marks to refer to a column in my dataframe and when can I do it without?

I'm fairly new in working with R, so I might not be naming so things right ;-) I would like to plot the results of three different linear models. To do so, I loop over my column names, which I saved ...
tobix100's user avatar
0 votes
0 answers
8 views

How to use recode() in a loop?

I'm currently working with a big dataframe and I need to recode the values of some columns (0, 1 or 8 to N, Y, U). For one column, I can use: df %>% mutate(colname = recode(colname, "0" = ...
Arne Witdouck's user avatar
0 votes
1 answer
46 views

How to paste individual column names in front of column means in R?

I want to paste the names of the month in front of the monthly mean temperatures from my dataset but nothing I try works. I can't use very complex code because its for my class and we are starting ...
Lily Cowper's user avatar
0 votes
0 answers
16 views

Create a new variable showing names of columns matching a certain value in data.table r

I want to create a new variable that shows the names of columns within a defined vector , which are matching a certain row value in data table R. my_data_table <- data.table( Column1 = c(1, 2, 3,...
Christian Langenohl's user avatar

15 30 50 per page
1
2 3 4 5
9