Could not find function "zip.file.extract" - r

library(utils)
a<-zip.file.extract("\\1\\1.csv",zipname="drivers.zip")
Error: could not find function "zip.file.extract"
What's going on?

zip.file.extract() is a defunct function as of R 2.14 (see ?"utils-defunct" help page or try brining up the ?zip.file.extract help page). Use the unzip() function instead. Perhaps
unzip("drivers.zip", files="\1\1.csv")
or you can omit the files= to extract all files in the zip archive to the current working directory.

Related

Unzipping and extracting file in R [duplicate]

library(utils)
a<-zip.file.extract("\\1\\1.csv",zipname="drivers.zip")
Error: could not find function "zip.file.extract"
What's going on?
zip.file.extract() is a defunct function as of R 2.14 (see ?"utils-defunct" help page or try brining up the ?zip.file.extract help page). Use the unzip() function instead. Perhaps
unzip("drivers.zip", files="\1\1.csv")
or you can omit the files= to extract all files in the zip archive to the current working directory.

How to load self-written package documentation with '?my_package_name'?

I made a package in R called "my_package_name". When I run ?my_package_name or ??_my_package_name, no results are found. I want a help file to be loaded in the same way that ?ggplot2 loads a package help file.
I can run ?my_function_name to obtain the help files for my functions. However, this does not work with my package name, even though the description file is complete. I found that help(package = my_package_name) loads a page that contains the description file and help pages, but I would like load a page with ?my_package_name.
I would say that the easiest way is probably to run the following from the usethis package. It will create the file needed to have your package documentation
usethis::use_package_doc()
I suggest reading the documentation of the function to understand what's going on under the hood.

Functions from my own developed R library not working

I created some functions and try to build a package/library, but run into some problems. I hoped to get some advise here on this support site.
This is how I tried to built my package.
I had some functions in an R file, including roxygen2 comments.
Then in R
library("devtools")
library(roxygen2)
setwd("C:to/my/directory")
create("myPackage")
Then I put my functions file in the R folder and changed the DESCRIPTION file.
setwd("./myPackage")
document()
setwd("..")
install("myPackage")
library(myPackage)
Then, when I want to see how a function works
?function1
I see the documentation in my browser.
But when I want to use my function I get an error.
function1
Error: object 'function1' not found
function1()
Error: could not find function "function1"
Does anyone know what I am doing wrong? I am using R 3.3.1 on Windows 7.
Your help or comments are appreciated, thanks in advance!
Ben

How to know where a R package has been installed

Good moorning
I would like to know if there is a way to find where a package is installed.
Actually, I am currently documenting a package. In my package, I have a function called "read.myfile" which reads a specific kind of file (roughly like read.table).
I have an instance of this kind of file named "myfile.txt" in my package's folder. On my documentation, I want to run an executable example of this function.
That's why I need the path, where the user has installed the package. So with this path, I can obtain the path of the file "myfile.txt" and use the function "read.myfile" in the .Rd help file, which gives help about the function "read.myfile".
Thus my example will be executable wherever the user has installed the package.
I hope my message was clear.
I don't know if it's possible to do that, but if anyone knows, thanks for helping me.
Use the function system.file.
For example:
system.file(package="ggplot2")
[1] "C:/Users/Andrie/Documents/R/win-library/3.0/ggplot2"
You can use installed.packages and subset to get the only the location of the library in which it is installed:
installed.packages()["tools","LibPath"]
[1] "C:/Program Files/R/R-2.15.2/library"

What is read.data in R? Why can't I find it in any docs?

I'm trying to debug my first R script and I came across this line:
data <- read.data(dir, indiv, label)
I've been googling "R read.data" for the past 30 minutes and absolutely nothing is coming up. Am I doing something wrong? Is there a good way to look up things I see in R scripts that I don't know what they are?
And what is this particular line doing anyway?
It's probably a function defined by the author of the script. Search for it in the code you have.
A couple of things to check:
Does your script define the function 'read.data' somewhere? read.data <- function(...
Does your script use library() or require() to load another package? In that case, the read.data function can be defined in that package.
Does your script use source to read another script? Check that script then...
package sos to the rescue:
read.data is a deprecated function in the rjags package
> library(sos)
> findFn("read.data")
Finds this result:
http://finzi.psych.upenn.edu/R/library/rjags/html/read.data.html
From this page:
Read data for a JAGS model from a file.
Usage
read.jagsdata(file)
read.bugsdata(file)
Note
Earlier versions of the rjags package had a read.data function which read data
in either format, but the function name was ambiguous (There are many data file
format in R) so this is now deprecated.
There isn't a base function named read.data. If you want to find help for an R function (for example read.table), simply type ?read.table at the interactive prompt.
This line calls a read.data function which is either defined in that script or in something else it loads (such as libraries with the library() or require(), other scripts with source()). You'll need to search those sources to find this function.

Resources