Read the help page for the names function: ?names
... note particularly the examples section. You might also find the fact that the paste0 function works on vectors to be helpful: paste0( "bp_", 1:6 ) --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnew...@dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. On January 12, 2015 6:17:07 AM PST, Kuma Raj <pollar...@gmail.com> wrote: >I want to rename columns 1 to 6 in the sample data set as bp_1 to >bp_6. How could I do that in R? > >Thanks > >> dput(dff) >structure(list(one = c(1.00027378507871, 0.982313483915127, >1.1531279945243, >1.07400410677618, 1.22710472279261, 1.19762271047046, 1.10904859685147, >1.32060232717317), two = c(1.04707392197125, 1.00998288843258, >1.17598904859685, 1.09595482546201, 1.28599589322382, 1.26632675564591, >1.12986995208761, 1.30704654346338), three = c(1.06301619895049, >1.02743782797171, 1.1977093315081, 1.11466803559206, 1.2949441022131, >1.28365657768591, 1.1305452886151, 1.32089436459046), four = >c(1.06994010951403, >1.03489904175222, 1.19799452429843, 1.1172022587269, 1.28742984257358, >1.27650013346977, 1.12265058179329, 1.30723134839151), five = >c(1.07019712525667, >1.03722792607803, 1.19174811772758, 1.11514168377823, 1.26594387405886, >1.25720010677582, 1.11339630390144, 1.29178507871321), six = >c(1.11111909650924, >1.08407027150354, 1.24785877253023, 1.16373032169747, 1.31150581793292, >1.31042514031455, 1.16205338809035, 1.37122975131189), idd = 1:8), >.Names = c("one", >"two", "three", "four", "five", "six", "idd"), row.names = c(NA, >-8L), class = c("tbl_df", "data.frame")) >> > >______________________________________________ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >https://stat.ethz.ch/mailman/listinfo/r-help >PLEASE do read the posting guide >http://www.R-project.org/posting-guide.html >and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.