I would like to recreate excel column headings in R.
So it goes from A to Z and then AA,AB,AC,AD and so on until AZ and then BA,BB,BC , etc.
thank you for any help.
I don't know what you want, but here are some ideas
Substitute names() for the column name.
library(tidyverse) LETTERS str_c(LETTERS,LETTERS) expand_grid(one = LETTERS,two = LETTERS) %>% mutate(bind = str_c(one,two))
I don't know what kind of data you want to use it for.
I don't know when you want to use it.
There is no default setting for column names to be named as such.
That's all I can tell you.
library(tidyverse) bind_list <- expand_grid(one = LETTERS,two = LETTERS) %>% mutate(bind = str_c(one,two)) %>% pull(bind) names_list <- c(LETTERS,bind_list) names(your data) <- names_list[1:ncol(your data)]
I created this example.
Thank you very much indeed @Rsky ,
I have done this:
aaa <- expand_grid(one = LETTERS,two = LETTERS) %>% mutate(bind = str_c(one,two)) %>% as.data.frame() bbb <- aaa %>% select(bind) ddd <- LETTERS %>% as.data.frame() names(ddd) <- c("bind") rbind(ddd, bbb) eee <- rbind(ddd, bbb) # in order to have all Letters in one vector (column)
and then I have got all excel columns' headings in first row (somehow in excel we can't just copy them):
This topic was automatically closed 7 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.