I am just starting to explore the rmarkdown package. I don't use Rstudio. I use the default R environment. What I did was as follows.
I created a new R document.
Started typing few lines in rmarkdown format.
Saved the file with Rmd extension.
I saved the file in the working directory.
I installed the pandoc using the pkg file.
I installed 'rmarkdown' package. Loaded the package.
Used the following command to render the Rmd file.
rmarkdown::render("Untitled.Rmd")
I get the following error.
Error in tools::file_path_as_absolute(input) : file 'Untitled.Rmd'
does not exist
I tried all the possible ways such as giving the exact path instead of filename etc. But nothing worked out. I googled the error message and found that none had similar error. Can someone help me with this. What I am missing. What the error message mean?
Most of the time the error file not found is either a type error or a real missing file (as in your case, the real one is named in another way).
In order to discard those possibilities:
Copy the fullpath from your filebrowser.
Make sure the file exists, inside R you could type:
file.exists("/fullpath/to/file")
If that return TRUE and the error persists, then you suspect another thing is going on.
Related
I can see the table of the data set on the upper right of Data.
My code is currently:
file.exists(C:/Hollywood.xlsx)?
to see if RStudio is picking up on it.
I get an error message of
"Incomplete expression: file.exists(C:Hollywood.xlsx)?"
To take a look at the working directory, I'm doing Session>Set Working Directory>Source File Location and get "The currently active source file is not saved so doesn't have a directory to change into." If I instead try Session>Set Working Directory>To Files Pane Location, I get setwd(~) and the following is what I get and subsequent code I try:
setwd("/Users/FridasSlave/Downloads/Hollywood")
#Error in setwd("/Users/FridasSlave/Downloads/Hollywood") :
# cannot change working directory
getwd(Hollywood)
# Error in getwd(Hollywood) : unused argument (Hollywood)
getwd("Hollywood")
#Error in getwd("Hollywood") : unused argument ("Hollywood")
If I try Session>Set Working Directory>Choose Directory, I can get to my Downloads folder but the individual files are all not there.
What am I doing wrong?
(And yes, I'm very new to R.)
I have all my relevant paths and code above.
Scrolling down the list of problems:
I hope you didn't put a ? at the end of an R command. It's true that it looks like it would be a question if you were talking to a person, but that's not the case.
The argument to file.exists should be a character value. C:/Hollywood.xlsx is not recognized by the R interpreter as a character value because there are no quotes around it. It's possible that at that point you could have gotten success with
file.exists("Hollywood.xlsx") # if it is in the current working directory
From your use of "~" and setwd("/Users/FridasSlave/Downloads/Hollywood") I'm guessing that you are on a Mac. Your question should probably have included that as a specific note. (Which further raises the issue why you would use a Windows file spcification if you are on a Mac?
The reason for the error from setwd("/Users/FridasSlave/Downloads/Hollywood") is not obvious, but maybe you misspelled part of the path or maybe it should have been setwd("/Users/FridasSlave/Downloads/").
Trying getwd(Hollywood) you again failed to include quotes around the argument. And why would you even want an argument if you want information about the current working directory? Should have just been getwd()
So to get to the point: I need to use an R package called machuruku. To get familiar with the package I used the dataset provided in the original paper (https://academic.oup.com/sysbio/article/70/5/1033/6171196). While trying to run the code for the simulation I get an error message saying that the command "machu.simulation" doesn't exist. Any of you have any idea why that's happening? Am I missing a package?
I downloaded the dataset zip file, dove into the second nested zip file Guillory_and_Brown_simulation-validation.zip, then into its file code_simulation-validation.R, and noticed that this source file uses machu.simulation several times before defining the function starting in line 519.
Suggestions:
Grab lines 519 through the end, save into a different file, source that new file, then try to run the code in the beginning of the file again.
Complain (not quietly?) to the authors, the fact that they think this is reproducible means they might have missed something else, too.
Hi I'm new to R and I'm using RStudio Cloud for a university stats course.
The code I'm having trouble with will run as a chunk but when I try to knit the project it comes up with an error saying that the object 'filename' not found.
The 'filename' is listed in the global environment but it is a tbl_df, which I'm thinking is not the right kind of object for knitting.
It is difficult to answer without having all the code. And code is almost always better than a screenshot.
My guess is that you loaded the dataset X2019THBrier manually in RStudio. Thus you can access it in chunks, in the current R session, but not in the knitted R session.
You need to write commands to load the data. As you are loading an XLSX file, you might want to install the openxlsx package, and use the openxlsx::read.xlsx() command.
So I'm rather new to R, and I'm learning how to mine text from this handy website: https://eight2late.wordpress.com/2015/05/27/a-gentle-introduction-to-text-mining-using-r/
I do have my own text set of .doc, .docx, and .xlsx files and I'm trying to mine them. They're located in a folder in my working directory called 'files', but I have already encountered an error after simply writing a few lines of code.
The code I have so far is:
library(tm)
library(readtext)
data = readtext('files')
At this point, after waiting for 25 seconds or so, I get the error:
Error: System call to 'antiword' failed (1): The Big Block Depot is damaged
and the code stops running there.
I have tried searching online for solutions but it seems like a fairly rare error and so I only found 1 possible solution at https://github.com/ropensci/antiword/issues/1 but that did not work for me.
This solution suggested that one of my files were corrupt, and suggested using the code
fixInNamespace(antiword, pos="package:antiword")
to change the error to a warning to not interrupt the reading of the files. I tried that, and at first it raised the error of
Error in as.environment(pos):
no item called "package:antiword" on the search list
After which, I loaded the antiword library with a library(antiword) and changed the stop( to a warning(. However, when I ran the data = readtext('files') line again, it immediately raised the error
Error in is_windows() : could not find function "is_windows"
I'm at a loss here! Any help would be appreciated. Should I be using another package in this case?
I had the same problem with my code, where I tried to get a doc. file in R. I also used the readtext library. What helped me was converting the Word documents I was trying to get into R from doc. to docx. When I ran the same code after it worked.
When I try to use roxygen2::roxygenize() in RStudio, I get an error message. The message I am coming across is this:
Warning message:
trainModel.Rd not generated by roxygen2. Skipped.
I have tried so much to fix this, but it just won't get fixed unless I remove all of the #' comments out (which would remove the purpose of using roxygen2 in the first place). I even took out everything except for the parts describing the title, description, and details and the error still persists (which makes me imagine that the error is in one of those three parts. But how?). My other document's Rd file gets generated just fine, but this one does not. Can somebody please help?
Try deleting the current Rd file.
I replicated this warning by creating file with your function, roxygenizing the code, and then removing the lines from the resulting Rd file
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/trainmode.R
It looks like roxygen2 doesn't want to overwrite files it didn't create. If you delete the current trainmode.Rd file, roxygen2 will generate a new .Rd file the next time roxygenize your code.