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 9010063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:21:38+00:00 2026-06-16T02:21:38+00:00

I am very new to programming with R, but I am trying to read

  • 0

I am very new to programming with R, but I am trying to read in multiple files for a directory and give them each a unique name. I am reading the files in using the Dendrochronology Program Library in R (package dpIR) and the read.tucson function. Although I’m using a specific package, I think my question is fairly general:

Within the loop, I want to create files by concatenating a "t" with each individual files name. So, if I have a file named "2503" in my directory, I want to create a dataframe in R called "t2503". Next, I want to read the data in using the r.tucson function to each dataframe. Rather than assigning the read-in data to the dataframe, I’m just overwriting the concatenation with the data. Can someone help me figure out what step I am missing?

Here is the code I am trying to use:

#set to appropriate directory
setwd("C:/work")

#get a list of files in the directory
files <- list.files()
numfiles <- length(files)

for (i in 1:numfiles)
{
    name<-paste("t",files[i],sep="")
    name<-read.tucson(files[i],header=NULL)
}
  • 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-16T02:21:40+00:00Added an answer on June 16, 2026 at 2:21 am

    I think you gave the answer yourself: you have to use ?assign.

    Try something like that:

    for (i in 1:5) {
      assign(paste0("DF", i), data.frame(A=rnorm(10), B=rnorm(10)))
    }
    

    This loops through the integers from 1 to 5 and creates five data.frames “DF1” to “DF5”. For your example, you should just replace

    name<-read.tucson(files[i],header=NULL)
    

    with

    assign(name, read.tucson(files[i],header=NULL))
    

    Note, however, that name is a base function in R, so I would use another naming convention or just skip the first line:

    assign(paste("t",files[i],sep=""), read.tucson(files[i],header=NULL))
    

    I hope this is what you are looking for.

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

Sidebar

Related Questions

I'm very new to jquery and programming in general but I'm still trying to
I'm very new to iPhone programming, but am trying to delve into it. I
I'm very new to programming and I am trying to write a program that
I am very new to programming with jQuery and I am trying to retrieve
I am very new to programming in general, while reading about PHP I saw
I am very new to MPI programming, I am trying to run a program
I am fairly new to Objective C and iOS programming but am constantly trying
Let me start off by saying, I'm not new to programming but am very
I'm very new to programming in Android, but have been struggling all day with
I very new to C++ programming and trying to understand this polymorphic assignment thing.

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.