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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:32:06+00:00 2026-06-11T12:32:06+00:00

I have script as below: setwd (I:/prep/Coord/RData/test) #load .csv files a.files <- grep(^Whirr, dir(),

  • 0

I have script as below:

setwd ("I:/prep/Coord/RData/test")

#load .csv files
a.files <- grep("^Whirr", dir(), value=TRUE) #pattern matching
b.files <- paste0("Files_", a.files) 

for(i in length(a.files)){
    a <- read.table(a.files[i], header=T, sep=",", row.names=1) #read files start with     Whirr_
    b <- read.table(b.files[i], header=T, sep=",", row.names=1) #read files start with Files_
    a
    b

    cr <- as.matrix(a) %*% as.matrix(t(a)
    cr


    diag(cr)<-0
    cr

    #write to file
    write.csv(cr, paste0("CR_", a.files[i], ".csv"))
}

Basically, what I want to do is to compare two files which have similar filename at the end of file name, and do the calculation, and write the result to file.

When I tried to print a.files and b.files, the output seems ok for me. The output as below:

> a.files <- grep("^Whirr", dir(), value=TRUE) #pattern matching
> b.files <- paste0("Files_", a.files, sep="") 
Error: could not find function "paste0"
> a.files
[1] "Whirr_127.csv" "Whirr_128.csv"
> b.files
[1] "Files_ Whirr_127.csv" "Files_ Whirr_128.csv"
> 

I tried to feed the script with multiple files, but I got an error msg as below:

Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") : cannot open file 'Files_ Whirr_128.csv': No such file or directory

So, I tried to use file.choose, but it also doesn’t work for me.

Appreciate help from the expert

  • 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-11T12:32:08+00:00Added an answer on June 11, 2026 at 12:32 pm

    Change the line:

    b.files <- paste0("Files_", a.files) 
    

    to:

    b.files <- paste("Files_", a.files, sep="")
    

    You are using a version of R that does not have paste0 (I see that code was given to you in an earlier answer). This means you were keeping an earlier version of b.files, perhaps one that had been constructed using paste.

    One important lesson about this is that whenever you get an error message about a line, such as Error: could not find function "paste0", that means the line did not happen! You have to fix that error before you paste the code, or tell us about the error when you do- otherwise we assume the b.files <- paste0("Files_", a.files) line works.

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

Sidebar

Related Questions

I have a NAnt script like below: <if test=${a}>${b}> <call target=target/> </if> What I
I have a script snippet looks like below: <ItemGroup> <files Include=*.txt></files> </ItemGroup> <Message Text=@(files)>
I have a small script which im using to test PHP mail(), as below:
I have the script below to subtract the counts of files between two directories
I have a powershell script below which takes a config file and deletes files
I have a jQuery script below that clears the value of an input on
I have a script as below document.getElementById('lan').innerHTML=lan; document.getElementById('city').innerHTML=city; document.getElementById('text1').value=city+'|'+lan; The variables lan and city
I have used script below and the output is X value : 123 Y
I have the following script below where I try to mimic a file upload
I have the script shown below that displays a list of records from a

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.