Open lepp12 opened 4 years ago
I'm looking at the console output a bit more and I see my scripts in the /R folder are considered invalid? Is this because of the .Rmd filetype at the end of each script?
EDIT: I tried converting these to text files and that also did not work. I have tried removing digits and spaces from the names, but I still get the same results as below
`√ checking for file 'C:\Users\lepp1\Documents\Data Science II\Package\montyhall/DESCRIPTION' (374ms)
Running "C:/PROGRA~1/R/R-36~1.1/bin/x64/Rcmd.exe" INSTALL \ "C:\Users\lepp1\AppData\Local\Temp\RtmpoLBRHF/montyhall_0.0.0.9000.tar.gz" --install-tests
Can you try:
lsf.str("package::montyhall")
Instead of
lsf.str("package:montyhall")
What have you done so far? It’s hard for me to diagnose without more details. Steps you tied? Which files are in the R folder? There should be no RMD files there, just the R script you downloaded.
I was mistaken. I had placed the RMD files from Lab01 and Lab02 in that R folder. I have since removed them and placed the downloaded script in the R folder. That script is the only file in the R folder.
As for steps taken, I have gotten as far in the instructions as this step:
setwd("C:/Users/lepp1/Documents/Data Science II/Package")
devtools::install( "montyhall" )
I have not made any changes to the downloaded script. Upon attempting to run the above code, I am getting this message in the console:
√ checking for file 'C:\Users\lepp1\Documents\Data Science II\Package\montyhall/DESCRIPTION' (335ms)
- preparing 'montyhall':
√ checking DESCRIPTION meta-information ...
- checking for LF line-endings in source and make files and shell scripts
- checking for empty or unneeded directories
- building 'montyhall_0.0.0.9000.tar.gz'
Running "C:/PROGRA~1/R/R-36~1.1/bin/x64/Rcmd.exe" INSTALL \
"C:\Users\lepp1\AppData\Local\Temp\RtmpWOxUPW/montyhall_0.0.0.9000.tar.gz" --install-tests
* installing to library 'C:/Users/lepp1/Documents/R/win-library/3.6'
* installing *source* package 'montyhall' ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
Error in Rd_info(db[[i]]) :
missing/empty \title field in 'C:/Users/lepp1/AppData/Local/Temp/RtmpwRHMbU/R.INSTALL38e4625c2042/montyhall/man/change_door.Rd'
Rd files must have a non-empty \title.
See chapter 'Writing R documentation' in manual 'Writing R Extensions'.
* removing 'C:/Users/lepp1/Documents/R/win-library/3.6/montyhall'
* restoring previous 'C:/Users/lepp1/Documents/R/win-library/3.6/montyhall'
Error in (function (command = NULL, args = character(), error_on_status = TRUE, : System command error
Reading the error it looked like the problem was not having a title in the documentation for change_door.Rd. I tried to fix that and add a title in the documentation of the script, but I got the same error when running again.
@lecy I think I have this solved. The script would not be read unless each function had its own @title. After adding titles to each function and re-running all steps, I was able to get the package created correctly.
Thanks for your help; especially on a Friday evening!
@lecy I think I have this solved. The script would not be read unless each function had its own @title. After adding titles to each function and re-running all steps, I was able to get the package created correctly.
Thanks for your help; especially on a Friday evening!
@lepp12 I'm having the same problem as you but I can't seem to see what you did to get it fixed. Are you using the Montyhall R script from the 'Creating an R Package' and filling out all the information there or did you create your own script? I thought I was supposed to download that Montyhall script from the page, move it into the montyhall folder, and then update that within R and it looks like every function has a title and I've updated the titles but I am still not getting it to read the create_game()
function. Any clarification on what you were able to do would be useful!
@lepp12 Great!
@hos1995 You will download the R script from the instructions (you don't need to alter the FUNCTION code at all), move it to the R folder inside the montyhall folder you created in the first step, then document the functions in the monty-hall-problem.R file using the Roxygen comments.
The fields have already been provided. You need to fill them out, though.
Example documentation in Roxygen:
#' @title
#' Sum of vector elements.
#'
#' @description
#' `sum(x)` returns the sum of all the values present in its arguments.
#'
#' @details
#' This is a generic function: methods can be defined for it directly
#' or via the [Summary] group generic. For this to work properly,
#' the arguments `...` should be unnamed, and dispatch is on the
#' first argument.
#'
#' @param x Numeric, complex, or logical vectors.
#' @param na.rm A logical scalar. Should missing values (including `NaN`)
#' be removed?
#' @return If all inputs are integer and logical, then the output
#' will be an integer. Otherwise it will be a length-one numeric or
#' complex vector.
#'
#' Zero-length vectors have sum 0 by definition. See
#' <http://en.wikipedia.org/wiki/Empty_sum> for more details.
#'
#' @examples
#' sum(1:10)
#' sum(1:5, 6:10)
#' sum(F, F, F, T, T)
#'
#' sum(.Machine$integer.max, 1L)
#' sum(.Machine$integer.max, 1)
#'
#' \dontrun{
#' sum("a")
#' }
sum <- function(..., na.rm = TRUE) {}
@hos1995 going off what @lecy said, the documentation includes an @title
for each function that looked like this:
#' @title
#' @description
#' @details
#' @param
#' @return
#' @examples
#' @export
I had to edit it, at a minimum, to look like this:
#' @title
#' sample title 5
#' @description
#' @details
#' @param
#' @return
#' @examples
#' @export
I am trying to install my package on a different machine after uploading it to github , but I am getting that something is malformed, even though I ran it before installing and it was working. Should I delete it from github?
@malmufre Please review the Simple Rules for Clear Questions:
https://ds4ps.org/cpp-527-fall-2020/help/
It is hard to help when you provide no context or code. There are 1,000 ways to do something incorrectly - it is challenging to guess at what you might have done without seeing what you have actually done. Hope that makes sense.
Professor Lecy,
I have gotten to the testing stage of the package. I temporarily skipped past adding any documentation yet .
When I attempt to test my package in a separate R session, I am able to load the package using
library( montyhall )
However, when I test the
create_game()
function, I get the following error:Error in create_game() : could not find function "create_game"
I have gone back to Lab 01 and re-ran that code to make sure it works; and it does, as does that code in the R folder here:
C:\Users\lepp1\Documents\Data Science II\Package\montyhall\R
Using
lsf.str("package:montyhall")
I see there are no functions in the package.Given all of this, I'm a bit confused on what the problem may be and why create_game() isn't a part of the montyhall package?