Error in R package that need C program to complie - r

I would like to work with R package SampleSizeBinomial_1.0.tar.gz.This package includes a C program which will need be compiled. I am working in Windown 7 (64 bit) and I got the following error:
> prop.acc(len=200, alpha=20.5, beta=18.5, level=0.95, exact=TRUE,
sim.size=1000, precision=1e-6, mcs=3)
Error in .C("OutcomeEstimation", as.integer(n), as.double
(fixed.parm.target), : C symbol name "OutcomeEstimation" not in load table
How could i solve this problem? What should i do in this regards? All the information about this package and install instruction is here.

Related

R: Encoding issues when installing package from Github

I am trying to install the dcStockR package from Github, which is an htmlwidgets wrapper around the dc.js dimensional visualization library: devtools::install_github("yutannihilation/dcStockR").
I get the following encoding error:
* installing *source* package 'dcStockR' ...
** R
Error in parse(outFile) :
C:/Users/tirthankarc/AppData/Local/Temp/Rtmpcz8pHX/devtools153839438c/yutannihilation-dcStockR-c6091c8/R/dc.R:11:59: unexpected input
10: #' #export
11: dc <- function(data, chartRecipe = c("yearlyBubbleChart",ã€
^
ERROR: unable to collate and parse R files for package 'dcStockR'
* removing 'C:/Users/tirthankarc/Documents/R/R-3.2.5/library/dcStockR'
Error: Command failed (1)
The offending lines of the file in question can be viewed here: https://github.com/yutannihilation/dcStockR/blob/master/R/dc.R#L11.
Two questions:
Is this error reproducible for others?
If so, is there a way to fix this by passing an explicit encoding option to install.packages? If not, what other options are available to fix this issue?

TCL error with "unfold" function in survival analysis

I am trying to use the unfold function from package RcmdrPlugin.survival.
I used the following command:
long.df <- unfold(testdf,time="deathint", event="death",
cov=list(31:70,71:110), cov.names=c("adopted","age"))
However, R is returning the following error message:
Error in structure(.External(.C_dotTcl, ...), class = "tclObj") :
[tcl] wrong # args: should be "winfo rootx window".
I am using R version 3.2.4. Any suggestions?
I had the same problem in R studio. This is how I solved it:
intall.packages("Rcmdr")
It installed R commander gui for me,then I went to R commander gui, installed and loaded RcdmrPlugin.survival and then I ran unfold from there and it worked.

rWishart function not found in R

I am using R version 2.13.1 (2011-07-08) on Windows 7 and wish to use the function rWishart.
When I enter, say, rWishart(1,2,3), I get
Error: could not find function "rWishart"
Entering just rWishart, however, displays a matrix:
[,1] [,2]
[1,] 1 0
[2,] 0 1
To check that this object is not interfering with the function, I did rm(rWishart), and now rWishart gives
Error: object 'rWishart' not found"
but I still get the function-not-found error when using it as a function.
A search of my hard drive finds no rWishart.* file. I Googled and downloaded an rWishart.R file from
https://projects.cs.kent.ac.uk/projects/cxxr/svn/branches/sqlite/src/library/stats/R/
to the directory shown by getwd().
When I did load("<DIRECTORY>/rWishart.R") , I got
Error: bad restore file magic number (file may be corrupted) -- no data loaded
In addition: Warning message:
file 'rWishart.R' has magic number '# Fi'
Use of save versions prior to 2 is deprecated
Would someone be able to tell me how I can get the rWishart function running?
rWishart wasn't introduced in base R until 2.15. So you should update your version of R or find a package that adds the functionality.

Rcpp inline package error in compileCode

I have R installed along with these two packages Rcpp and inline. (I am doing a project that consists of speeding up a painfully slow program in R and I decided to use Rcpp)...I know I am doing something wrong...probably missing a step but i cannot figure it out. Props to Dirk if you're reading this! Thanks for Rcpp and the brand new inline package pdf but...it's still not running.
Please note that I'm a newbie. As stated before I cleaned out all other packages and only R is installed with Rcpp and inline (of course I have c++ installed as well).
library(Rcpp)
library(inline)
x<-as.numeric(1:10)
n<-as.integer(10)
code<-"
integer i
do 1 i=1, n(1)
1 x(i)=x(i)**3
"
cubefn<- cfunction(signature(n="integer",x="numeric"),code,convention=".Fortran")
ERROR(s) during compilation: source code errors or compiler configuration errors!
Program source:
1: #include <R.h>
2:
3:
4: extern "C" {
5: void filef2424e34d61 ( int * n, double * x );
6: }
7:
8: void filef2424e34d61 ( int * n, double * x ) {
9:
10: integer i
11: do 1 i=1, n(1)
12: 1 x(i)=x(i)**3
13:
14: }
Error in compileCode(f, code, language, verbose) :
Compilation ERROR, function(s)/method(s) not created!
In addition: Warning message:
running command 'C:/R/R-2.15.2/bin/x64/R CMD SHLIB filef2424e34d61.cpp 2> filef2424e34d61.cpp.err.txt' had status 1
If it is the construction of a package skeleton missing: i tried the simple rcpp_hello_world() example:
rcpp_hello_world <- function(){
.Call( "rcpp_hello_world", PACKAGE = "mypackage" )
}
Folder PATH listing for volume OS
Volume serial number is 769C-A616
C:.
The rest was a long list of odd symbols but what I could read was the name of c++ projects I have, I didn't include them as it would be too lengthy
rcpp_hello_world <-function(){
.Call("rcpp_hello_world",PACKAGE="mypackage")
}
rcpp_hello_world()
Error in .Call("rcpp_hello_world", PACKAGE = "mypackage") :
"rcpp_hello_world" not available for .Call() for package "mypackage"
Anything would help please, also I have linux installed as well so if that is a better option please do tell. I am open to anything right now, the slightest progress makes is a delight
Do you actually have a Fortran compiler installed?
If you don't, or you don't know, try your Linux box. R on Windows must be able to compile source packages if you want to build with Rcpp and inline. A good quick test is to try something like
R> myroot <- cppFunction('double myroot(double x) { return ::sqrt(x); }')
R> myroot(16)
[1] 4
R>
or equivalently via inline (where rcpp is a wrapper for the cxxfunction(..., plugin="Rcpp") call, you need the most recent inline package for that)
R> myroot2 <- rcpp(signature(xs="numeric"),
+ body='double x=as<double>(xs); return wrap(::sqrt(x));')
R> myroot2(16)
[1] 4
R>
If this does not work, read up on the R basics of installing Rtools for Windows etc. We have a few additional notes in the Rcpp FAQ as well.

Rcpp reports an error: C symbol name "sourceCppContext" not in DLL for package "Rcpp"

I am trying Rcpp 0.10.0 on Mac OS 10.8.2, and use the example here about estimating \pi. However, when I run the following code in R:
sourceCpp("piSugar.cpp")
an error message says:
Error in .Call("sourceCppContext", PACKAGE = "Rcpp", file, code, .Platform) :
C symbol name "sourceCppContext" not in DLL for package "Rcpp"
Did I miss something? I double checked that the piSuger.cpp file is in current directory. Thanks!
I suspect you are calling an older Rcpp version. Maybe you have several in your .libPaths()? Or maybe you didn't restart your session?
It all works here -- and piBySimulation.r is the example from my blog post from an hour or two ago which you are trying to replicate here:
edd#max:~/svn/rcpp/pkg/Rcpp/inst/examples/Misc$ Rscript piBySimulation.r
test replications elapsed relative
2 piSugar(N) 100 5.639 1.000
1 piR(N) 100 11.147 1.977
edd#max:~/svn/rcpp/pkg/Rcpp/inst/examples/Misc$

Resources