Delete PDF file made in R [closed] - r

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have created a couple of pdf's using the pdf() device and I can't seem to delete them from my computer. I received the following error when I ran my code.
> pdf(file="Appendix_B_1.pdf")
> plot(1:10)
> dev.off
function (which = dev.cur())
{
if (which == 1)
stop("cannot shut down device 1 (the null device)")
.External(C_devoff, as.integer(which))
dev.cur()
}
<bytecode: 0x0000000008c7ecd0>
<environment: namespace:grDevices>
Above is my attempt to trick the computer into thinking it is a new file. It changed the file and I am able to open it. I just can't delete it.
I don't know what this means and all I want to do is delete the files. Is there some workaround for either turning off the device or deleting the files from my hard drive?

dev.off is the name of a function. When you type the name of a function, the source code for that function is printed. If you want to run the function, add parenthesis: dev.off()

Related

Is this R file path incorrect? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 days ago.
Improve this question
I'm trying to write a simple file path to my downloads folder on my macbook but I'm getting this error:
filePath <- file.path(Sys.getenv("HOME"), "Downloads")
transactionData <- fread(paste0(filePath,"QVI_transaction_data.csv"))
customerData <- fread(paste0(filePath,"QVI_purchase_behaviour.csv"))
Error in fread(paste0(filePath, "QVI_transaction_data.csv")) :
File '/Users/anitaabbot/DownloadsQVI_transaction_data.csv' does not exist or is non-readable. getwd()=='/Users/anitaabbot/Downloads'
Both files "QVI_transaction_data.csv" and "QVI_purchase_behaviour.csv" are saved in the download folder and so is the .rmd file. So I'm not sure what the problem is. Any ideas?

Reading arrays from binary file: "read end of file" error [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I am reading/writing an array to file in Julia. For example:
test_arr=zeros(3,3)
io = open("logs/test","w")
write(io,test_arr)
close(io)
To read the file I do:
load_arr=Array{Float64}(undef,3,3)
io = open("logs/test","w")
read!(io,load_arr)
close(io)
This gives a "read end of file" error.
I am a bit perplexed as this is how I have been writing/reading other arrays to/from binary files without issue. But this time I get an error.
When opening the IOStream again, I think we want a read instead of another write:
io = open("logs/test","r")
For completeness from the comments above, opening a file with just w will truncate the file, so attempting to read from it will lead to an EOF error. More examples of what different modes do can be found here: https://docs.julialang.org/en/v1/base/io-network/#Base.open

R function can't be found [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I have an R script where I use the following code:
gspcRets = diff( log( Cl( qxts ) ) )
When i run the script from RStudio everything works fine.However,when i run the script from Terminal with the command:
RScript my_script.R
I get the following error:
Error in Cl(qxts) : could not find function "Cl"
My script loads all the necessary libraries.I assume it has something to do with the fact that my system needs some kind of access to the RStudio environment.Any ideas?
I forgot to load the "quantmod" package.An RStudio's active session continues to use the packages that have been loaded previously even after i used the command:
rm(list=ls(all=TRUE))

calling a function from another script [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Improve this question
I want to use a function from one script in another script but i either get an erorr or nothing is happend, depend on my code syntax. When i use the source("file_name) i get an erorr, and when i add the if(exists("function_name", mode = "function")) i get nothing..
hope you can help
have a good day
Or
In a different way you can choose your code script file using file.choose (avoiding problems related to the working directory) like this:
source(file.choose())
Terru_theTerror is absolutely right: it looks like there is something wrong with your source folder.
You may check the current name of your working directory with getwd() and check what contains this directory by dir(). If there your source file is placed elsewhere, your should change your current directory or to include the path to your source file by using source():
source_dir_name <- "D:/Work/Sources"
source_file_name <- "file_Name.R"
source_with_path <- paste(source_dir_name,"/", source_file_name, sep = "")
#
setwd(source_dir_name)
source(source_file_name)
# or
source(source_with_path)

read.csv function unrecognised within an external script but works fine if I paste in to R console [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
In a script that I want to run part of it imports a csv file. Ideally I would like to use read.csv. However I get the error "Error in eval(expr, envir, enclos) : could not find function "read.csv"", when the script runs. However if I copy and paste the code in to the R console it works fine. Any ideas on how to get this to work in the script without intervention?
Code:
library(utils)
df <- data.frame()
df <- read.csv(Input_file, fill=TRUE, header=TRUE)
Thanks
sys.source() by default will run the code in the baseenv() which happens to be an empty environment. Generally you should really only use 'source()' which uses your current environment.

Resources