Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

diegozuniga

macrumors newbie
Original poster
Oct 11, 2005
28
0
Hi,

I am using R 2.1.1 for my quality class. I need for it to read a table that i created in Text Editor. I don't know how to input the path name correctly for it to read it right. My profesor in class used Windows Notepad to put the tables and saved them as a .txt file. What should i save it as? A RFT file???

the code that he used is:
dat<-read.table("e:/sample5_4.txt")

If I go to Spotlight it gives me, that the location is as follows: /Users/diegozuniga/documents. And the name of my file is sample5_4

Can anybody possible help me. And just as a word of caution, i am probably going to have more questions like this later on. Thank you very much in advance.
 
diegozuniga said:
Hi,

I am using R 2.1.1 for my quality class. I need for it to read a table that i created in Text Editor. I don't know how to input the path name correctly for it to read it right. My profesor in class used Windows Notepad to put the tables and saved them as a .txt file. What should i save it as? A RFT file???

the code that he used is:
dat<-read.table("e:/sample5_4.txt")

If I go to Spotlight it gives me, that the location is as follows: /Users/diegozuniga/documents. And the name of my file is sample5_4

Can anybody possible help me. And just as a word of caution, i am probably going to have more questions like this later on. Thank you very much in advance.
Why don't you just use the Cocoa (MacOS X-native) version of R? FWIW, .rtf is for word-processing, not data storage. You should save your file as .txt. TextEdit and a myriad of other text editors can do this. Most spreadsheets, including Excel, and graphing/charting applications can also save or export data as tab-delimited, space-delimited, or comma-delimited (aka CSV) text files. Database apps can also do it. The point is that you have a lot of options.
 
diegozuniga said:
Hi,

I am using R 2.1.1 for my quality class. I need for it to read a table that i created in Text Editor. I don't know how to input the path name correctly for it to read it right. My profesor in class used Windows Notepad to put the tables and saved them as a .txt file. What should i save it as? A RFT file???

the code that he used is:
dat<-read.table("e:/sample5_4.txt")

If I go to Spotlight it gives me, that the location is as follows: /Users/diegozuniga/documents. And the name of my file is sample5_4

Can anybody possible help me. And just as a word of caution, i am probably going to have more questions like this later on. Thank you very much in advance.

The best strategy is to change the Working Directory in R to match the folder that contains your file and then you can just do read.table(filename.txt)

Let me know if you have any further questions, I use R is OS X all the time
 
Thanks

So basically, it doesn't matter if the file is in my documents folder i would just put the file name.

Example. The file is Under User/myname/Documents/filename

all i would have to put would be

dat<-read.table(filename.txt) ????

I would not have to put the pathname?

Sorry about this mess, i am really new to R.
 
diegozuniga said:
So basically, it doesn't matter if the file is in my documents folder i would just put the file name.

Example. The file is Under User/myname/Documents/filename

all i would have to put would be

dat<-read.table(filename.txt) ????

I would not have to put the pathname?

Sorry about this mess, i am really new to R.

In R, select Misc->Change Working Directory. (shortcut key cmnd+D)

Then change the working directory to the folder that contains your files.

Now you can use dat<-read.table(filename.txt) without needing a pathname.

Hope this helps
 
you can past the entire path as well

i.e. /Users/blah/blah/yikes.txt

if you use bbedit (or maybe textwrangler can do this?) you can copy the entire path to the clipboard.

you can also use OnMyCommand to add these kinds of options to the right click finder options

http://free.abracode.com/cmworkshop/

technically you can name the file whatever you want - read.table will open your file as a flat file.

i often have crazy names like
proteins.sortd.uniq.data
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.