SERVING THE QUANTITATIVE FINANCE COMMUNITY

 
User avatar
player
Topic Author
Posts: 2290
Joined: August 5th, 2002, 10:00 am

Basic Q on R

November 23rd, 2010, 3:44 pm

A real basic question on R I have a txt file and I am trying to read it into R but getting an error reading it in.I've set the path of R to where the folder is and then typed the following Santa <-read.table("IsThereASantaClaus.txt")but I get a whole host of errors Error in file(file, "rt") : cannot open the connectionIn addition: Warning message:In file(file, "rt") : cannot open file 'IsThereASantaClaus.txt': No such file or directoryI then tried puting the path direct > Santa <-read.table("C:\\Users\\Player\\IsThereASantaClaus.txt")and as > Santa <-read.table("C:\Users\Player\IsThereASantaClaus.txt")but still cant get it read.Can anyone help pleeeeease
 
User avatar
quantmeh
Posts: 5974
Joined: April 6th, 2007, 1:39 pm

Basic Q on R

November 23rd, 2010, 3:50 pm

try copying file to where your R is.
 
User avatar
tradelink
Posts: 55
Joined: March 9th, 2010, 9:55 pm

Basic Q on R

November 23rd, 2010, 3:51 pm

R uses unix forwardslashes in paths rather than windows backslashes, sosanta <-read.table("/users/player/isthereasantaclaus.txt")or santa <-read.table("c:/users/player/isthereasantaclaus.txt")should work
 
User avatar
tagoma
Posts: 18255
Joined: February 21st, 2010, 12:58 pm

Basic Q on R

November 23rd, 2010, 4:19 pm

QuoteSanta <-read.table("IsThereASantaClaus.txt")you just typed in the name of your file.what about your working directory ?you may set your working directory :example : setwd("C:/Users/WilmottForumUser/desktop")you then can open you file :data<-read.table("IsThereASantaClaus.txt")but that very depends on the actual content of your file.in any case, you should specify the way your file is organized and what your data look like using the sep, dec, heade, na.strings keywords.that way you would be sure to open your file properly.édouard
 
User avatar
player
Topic Author
Posts: 2290
Joined: August 5th, 2002, 10:00 am

Basic Q on R

November 23rd, 2010, 4:22 pm

thanks guys. Now working
 
User avatar
player
Topic Author
Posts: 2290
Joined: August 5th, 2002, 10:00 am

Basic Q on R

November 29th, 2010, 9:09 am

For some reason when I run the following on a new PC > source("http://www.rmetrics.org/Rmetrics.R")> install.Rmetrics()I get the following error msg in file(file, "r", encoding = encoding) : unable to open connectionIn addition: Warning message:unable to resolve 'www.rmetrics.org'. in: file(file, "r", encoding = encoding)Any idea what is going wrong?It worked on my old PC last week
 
User avatar
Hansi
Posts: 3300
Joined: January 25th, 2010, 11:47 am

Basic Q on R

November 29th, 2010, 9:36 am

Do you have any kind of outgoing firewall? Zonealarm etc? Which Mirror are you using? Which OS? Which R version?
Last edited by Hansi on November 28th, 2010, 11:00 pm, edited 1 time in total.
 
User avatar
player
Topic Author
Posts: 2290
Joined: August 5th, 2002, 10:00 am

Basic Q on R

July 11th, 2011, 8:02 am

There is a firewall. The version is 2.5.1
 
User avatar
player
Topic Author
Posts: 2290
Joined: August 5th, 2002, 10:00 am

Basic Q on R

July 11th, 2011, 8:18 am

I guess the issue is how do I change the intenet proxy to connect R to the web?
 
User avatar
Hansi
Posts: 3300
Joined: January 25th, 2010, 11:47 am

Basic Q on R

July 11th, 2011, 9:17 am

Set the proxy in IE and then start R with: "C:\Program Files\R\R-2.xx.0\bin\i386\Rgui.exe" --internet2 or change the shortcut accordingly.
 
User avatar
player
Topic Author
Posts: 2290
Joined: August 5th, 2002, 10:00 am

Basic Q on R

September 5th, 2011, 11:56 am

Another basic q on R I have written the following function in an R script logistic <- function(r,x) r*x*(1-x)and saved it as logistic.RIm now trying to call it in the R console. How can I do this?I've set the wd to the same path as to where logistic.R is saved but still nothing....
 
User avatar
Hansi
Posts: 3300
Joined: January 25th, 2010, 11:47 am

Basic Q on R

September 5th, 2011, 12:19 pm

You'll need to source it in. source("/path/to/file/logistic.R") or source("logistic.R") since it's in the working directory.
 
User avatar
player
Topic Author
Posts: 2290
Joined: August 5th, 2002, 10:00 am

Basic Q on R

September 6th, 2011, 5:58 am

thanks
ABOUT WILMOTT

PW by JB

Wilmott.com has been "Serving the Quantitative Finance Community" since 2001. Continued...


Twitter LinkedIn Instagram

JOBS BOARD

JOBS BOARD

Looking for a quant job, risk, algo trading,...? Browse jobs here...


GZIP: On