Unable to write data into file

R programming language resources Forums General chat Unable to write data into file

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #946

    Hey folks,

    I am completely new to R programming and have been trying some stuff and am stuck at some places. I am not sure if this the right place to direct my queries. If not, please correct me.

    Meanwhile, I had a doubt while trying to write my data using R. I created a simple list and and am trying to write that data into a .txt file that I have already created on my Desktop. My code and error looks as follows:

    > data7 = scan ()
    1: 23 17 12.5 11 17 12 14.5 9 11 9 12.5 14.5 17 8 21
    16:
    Read 15 items
    > write(data7, file = ‘Desktop/data7.txt’, sep = ‘,’)

    However, I get the following error:

    Error in file(file, ifelse(append, “a”, “w”)) :
    cannot open the connection
    In addition: Warning message:
    In file(file, ifelse(append, “a”, “w”)) :
    cannot open file ‘Desktop/data7.txt’: No such file or directory

    I am using Mac OS.

    Does anyone have any clues?

    Thanks in advance,

    Chai

    #969
    bryan
    Participant

    Hi Chai,

    This is a path issue. My guess is you want something like:

    write(data7, file = ‘~/Desktop/data7.txt’, sep = ‘,’)

    Note the added tilde and forward slash.

    Just repost if that doesn’t help.

    • This reply was modified 10 years, 9 months ago by bryan.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Scroll to top
Privacy Policy