Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9092891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:57:03+00:00 2026-06-16T22:57:03+00:00

my apologies if this is a duplicate, i couldn’t find it anywhere.. say i’ve

  • 0

my apologies if this is a duplicate, i couldn’t find it anywhere..

say i’ve got a bunch of data frames, and i want to convert all of their column names to lowercase. what’s the most efficient way to do this? it’s straightforward with assign and get but i’m wondering if there’s a faster way?

if i’ve just got ChickWeight and mtcars, the non-dynamic operation would simply be..

names( ChickWeight ) <- tolower( names( ChickWeight ) )
names( mtcars ) <- tolower( names( mtcars ) )

..and then here’s how i would make this process dynamic, but i wonder if there’s a more efficient solution?

# column headers contain uppercase
head(ChickWeight)

# start with a vector of data frame names..
# this might contain many, many data frames
tl <- c( 'ChickWeight' , 'mtcars' )

# loop through each data frame name..
for ( i in tl ){
    # save it to a temporary object name
    x <- get( i )

    # main operations here..

    # perform the operation(s) you want to run on each data frame
    names( x ) <- tolower( names( x ) )

    # ..end of main operations


    # assign the updated data frame to overwrite the original data frame
    assign( i , x )
}

# no longer contains uppercase
head(ChickWeight)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:57:04+00:00Added an answer on June 16, 2026 at 10:57 pm

    I don’t think you’re likely to gain a whole lot of speed by changing approaches. A more idiomatic way to do this would be to store all of your data frames in a list and use something like `

    dlist <- list(mtcars,ChickWeight)
    

    (or)

    namevec <- c("mtcars","ChickWeight")
    dlist <- lapply(namevec,get)
    

    then:

    dlist <- lapply(dlist,function(x) setNames(x,tolower(names(x))))
    

    … but of course in order to use this approach you have to commit to referring to the data frames as list elements, which in turn affects the whole structure of your analysis. If you don’t want to do that then I don’t see anything much better than your get/assign approach.

    If you want to assign the values of the list back to the global environment you can do:

    invisible(mapply(assign,namevec,dlist,MoreArgs=list(envir=.GlobalEnv)))
    

    I want to emphasize that this is not necessarily faster or more transparent than the simple approach presented in the original post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Apologies if this is a duplicate but I couldn't find anything concrete as an
Apologies if this is answered elsewhere; couldn't find enough information to convince myself of
I apologize if this is a duplicate but I couldn't find any solutions that
I apologize if this is a duplicate, but I couldn't find any concrete examples
Apologies if this is a duplicate, but I've not managed to find this question
Firstly: apologies if this is a duplicate post. Things got a bit confusing as
Apologies if this is a duplicate, but I haven't found this info anywhere. Phonegap
Frstly my apologies if this is a duplicate question. I have tried to find
I apologize if this is a duplicate post, but I couldn't find the answer
I apologize if this is a duplicate question, I searched a bit and couldn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.