开发者

How write to file using rapache?

We are trying some tables data to a file with no success.

using write.csv.

Here is some example code that we try:

> <%
> 
> X<-c(1:666)
> 
> print(X)
> 
> write.csv(X,"hh")
> 
> %>

Here are the rapache errors, that we can't figure:

RApache Warning/Error!!!

Error in file(file, ifelse(append, "a", "w")) : cannot open the connection
RApache Warning/Error!!!

In addition:
RApache Warning/Error!!!

Warning messages:
RApache Warning/Error!!!

1: In readLines(icon, 1) : incomplete final line found on '/var/www/brew/sampleplan/step1_5.php'
RApache Warning/Error!!!

2: In readLines(icon, 1) : incomplete final line found on '/var/www/brew/sampleplan/step1_5.php'
RApache Warning/Error!!!

3: In readLines(icon, 1) : incomplete final line found on '/var/www/brew/sampleplan/step1_5.php'
RApache Warning/Error!!!

4: In readLines(icon, 1) : inco开发者_StackOverflow社区mplete final line found on '/var/www/brew/sampleplan/writefile.php'
RApache Warning/Error!!!

5: In file(file, ifelse(append, "a", "w")) : cannot open file 'hh': Permission denied
RApache Warning/Error!!!

Function brew returned an object of 'try-error'. Returning HTTP response code 500.

If some one can write us a simple example or correct our code it will be awesome.

Thank's,

Yoni & Tsvi.


To make your life easier, get your code working on its own first, then introduce rApache.

The error that you are seeing means that write.csv cannot write to the location that you specified. Since writing to file is a common source of problems, you should add some checking and error handling code to make things more robust. For example,

  1. Specify an absolute path (path.expand) or at least make sure you know where the current working directory is (getwd).

  2. Check that the directory you are writing to exists (file.exists) and that you can write to it (file.access, with mode = 2).

  3. Wrap your call to write.csv in a call to try or tryCatch.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜