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 question.(5)

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

ITtutoria

ITtutoria Logo ITtutoria Logo

ITtutoria Navigation

  • Python
  • Java
  • Reactjs
  • JavaScript
  • R
  • PySpark
  • MYSQL
  • Pandas
  • QA
  • C++
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA
Home/ Questions/error in file(file, "rt") : invalid 'description' argument - Simple way to solve it
Next
Answered
Nathan Leray
  • 5
Nathan Leray
Asked: May 12, 20222022-05-12T11:36:02+00:00 2022-05-12T11:36:02+00:00In: r

error in file(file, “rt”) : invalid ‘description’ argument – Simple way to solve it

  • 5

. Advertisement .

..3..

. Advertisement .

..4..

I am tired of fixing the problem: error in file(file, “rt”) : invalid ‘description’ argument in the r; even if I get the reference from another forum, it still returns an error:

Error in file(file, "rt") : invalid 'description' argument

To identity the problem, I will show you the detail here:

> df = data.frame(A = c(“A”,”B”,”C”,”D”,”E”,”F”,”G”),

+ B = c(1, 2, 3, 4, 5, 6, 7),

+ C = c(2, 3, 4, 5, 6, 7, 8),

+ D = c(2, 4, 6, 8,10,14,16))

> df

A B C D

1 A 1 2 2

2 B 2 3 4

3 C 3 4 6

4 D 4 5 8

5 E 5 6 10

6 F 6 7 14

7 G 7 8 16

Try it and let us know how it goes.

error in file
  • 2 2 Answers
  • 82 Views
  • 0 Followers
  • 0
Answer
Share
  • Facebook
  • Report

2 Answers

  • Voted
  • Oldest
  • Recent
  • Random
  1. Best Answer
    lyytutoria Expert
    2022-05-31T22:45:45+00:00Added an answer on May 31, 2022 at 10:45 pm

    The cause: There is an argument in the read.csv2 function when the paste0 function is embedded. This is what causes the error because you cannot access more than one file by this way.

    Solution: Using separately two functions with a for loop instead of embedding them so that the read.csv2 function can read each CSV file separately.

    df = data.frame(A = c(“A”,”B”,”C”,”D”,”E”,”F”,”G”),
    + B = c(1, 2, 3, 4, 5, 6, 7),
    + C = c(2, 3, 4, 5, 6, 7, 8),
    + D = c(2, 4, 6, 8,10,14,16))
    > df
    A B C D
    1 A 1 2 2
    2 B 2 3 4
    3 C 3 4 6
    4 D 4 5 8
    5 E 5 6 10
    6 F 6 7 14
    7 G 7 8 16
    > write.csv(df, “1.csv”, row.names = FALSE)
    > write.csv(df, “2.csv”, row.names = FALSE)
             
    
    > a = paste0(1:2, “.csv”)
    > for (n in c(1,2)) {
    + print(read.csv2(a[n]))
    + cat(sep=”\n\n”)
    + }
    A.B.C.D
    1 A,1,2,2
    2 B,2,3,4
    3 C,3,4,6
    4 D,4,5,8
    5 E,5,6,10
    6 F,6,7,14
    7 G,7,8,16
    
    A.B.C.D
    1 A,1,2,2
    2 B,2,3,4
    3 C,3,4,6
    4 D,4,5,8
    
    5 E,5,6,10
    6 F,6,7,14
    7 G,7,8,16
    • 16
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report
  2. Léa Besson
    2022-05-25T19:45:59+00:00Added an answer on May 25, 2022 at 7:45 pm

    Your file path is not working correctly. The full vector ID =c (1:332) is being passed to the file path name. This line can be changed if your files are named 1.csv.csv. 3.csv., etc.

    path<-paste(directory,"/",id,".csv",sep="")

    To

    path<-paste(directory,"/",i,".csv",sep="")

    You can either leave it out or modify the id input for your function.

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

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

Sidebar

Ask A Question
  • How to Split String by space in C++
  • How To Convert A Pandas DataFrame Column To A List
  • How to Replace Multiple Characters in A String in Python?
  • How To Remove Special Characters From String Python

Explore

  • Home
  • Tutorial

Footer

ITtutoria

ITtutoria

This website is user friendly and will facilitate transferring knowledge. It would be useful for a self-initiated learning process.

@ ITTutoria Co Ltd.

Tutorial

  • Home
  • Python
  • Science
  • Java
  • JavaScript
  • Reactjs
  • Nodejs
  • Tools
  • QA

Legal Stuff

  • About Us
  • Terms of Use
  • Privacy Policy
  • Contact Us

DMCA.com Protection Status

Help

  • Knowledge Base
  • Support

Follow

© 2022 Ittutoria. All Rights Reserved.

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.