Could not find function "cbind.na" [duplicate] - r

This question already has answers here:
Error: could not find function ... in R
(10 answers)
Closed 8 years ago.
I am using R:
library(qpcR)
final<-cbind.na(datum_seq, amb.temp)
Error: could not find function "cbind.na"
I have looked on the internet, and it suggests that I need to have the up to date version of R and qpcr package.
Confirmed in the sessionInfo(), I have the latest version. Could there another reason why it cannot find the function?
R version 3.1.2 (2014-10-31)
Platform: i386-w64-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United Kingdom.1252 LC_CTYPE=English_United Kingdom.1252
[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C
[5] LC_TIME=English_United Kingdom.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] plyr_1.8.1 qpcR_1.4-0 Matrix_1.1-4 robustbase_0.92-3 rgl_0.95.1201
[6] minpack.lm_1.1-8 MASS_7.3-35
loaded via a namespace (and not attached):
[1] DEoptimR_1.0-2 grid_3.1.2 lattice_0.20-29 Rcpp_0.11.2 tools_3.1.2

cbind.na is an internal variable to the qpcR package. If you must call this function directly, you can do so using qpcR:::cbind.na.
See help(':::') for details on internal and external variables.
Before using this, note the following (from the help page):
"It is typically a design mistake to use ::: in your code since the corresponding object has probably been kept internal for a good reason. Consider contacting the package maintainer if you feel the need to access the object for anything but mere inspection."

Related

Error: 'glmnet_softmax' is not an exported object from 'namespace:glmnet'

I am trying to use this tutorial https://github.com/wvictor14/planet#infer-ethnicity and get the following error message, even when using the test data provided:
pl_infer_ethnicity(pl_betas)
[1] "1860 of 1860 predictors present."
Loading required package: Matrix
Error: 'glmnet_softmax' is not an exported object from 'namespace:glmnet'
I've tried re-installing individual packages and running in a new version or R and get the same error. I believe this is related to other errors posted with a recent update in glmnet. Any tips on how to resolve?
sessionInfo()
R version 3.6.2 (2019-12-12)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Matrix_1.2-18 planet_0.1.0
loaded via a namespace (and not attached):
[1] lattice_0.20-38 codetools_0.2-16 glmnet_3.0-2 foreach_1.4.7
[5] crayon_1.3.4 grid_3.6.2 magrittr_1.5 pillar_1.4.2
[9] rlang_0.4.2 remotes_2.1.0 iterators_1.0.12 tools_3.6.2
[13] compiler_3.6.2 pkgconfig_2.0.3 shape_1.4.4 tibble_2.1.3
I don't know why it would have worked in the first place; the NEWS file for glmnet doesn't say anything one way or the other about glmnet_softmax (e.g., it does not say "glmnet_softmax is no longer exported" or anything like that ...)
In any case, this is a non-exported function from the glmnet package. It is referred to here in the tutorial code.
If you can change that line of code to refer to glmnet:::glmnet_softmax (i.e., three colons rather than two), that should suffice (::: allows you to access a non-exported function).

Using addPosLimit and osMaxPos throws "error in PosLimit[, "MaxPos"] : incorrect number of dimensions"

Even if I copy paste example from blog.fosstrading.com/2011/08/tactical-asset-allocation-using.html I get this error:
error in PosLimit[, "MaxPos"] : incorrect number of dimensions
Is this a bug or am I missing something?
Output from sessionInfo():
R version 3.2.2 (2015-08-14)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 7 x64 (build 7601) Service Pack 1
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] dplyr_0.4.3 quantstrat_0.9.1687 foreach_1.4.2
[4] blotter_0.9.1695 PerformanceAnalytics_1.4.3662 FinancialInstrument_1.2.0
[7] quantmod_0.4-5 TTR_0.23-0 xts_0.9-7
[10] zoo_1.7-12
loaded via a namespace (and not attached):
[1] Rcpp_0.12.1 lattice_0.20-33 codetools_0.2-14 assertthat_0.1 grid_3.2.2
[6] R6_2.1.1 DBI_0.3.1 magrittr_1.5 iterators_1.0.7 tools_3.2.2
[11] parallel_3.2.2
You have dplyr loaded. It defines a lag function that masks the generic function, stats::lag. dplyr::lag does not do any method dispatch, so there's a lag method somewhere that isn't being called when it should be.
dplyr also masks the first and last generics defined in xts, which may also cause problems.
A short-term work-around is to call library(dplyr) first, so first and last in xts will mask their couterparts in dplyr. The long-term solution is that all packages should explicitly import all functions they use to avoid issues caused by the sequence in which packages are loaded/attached (note that user's non-packaged code will still be affected by package load/attach order).

cryptic error message in testthat

I am running testthat in Rstudio (Windows 0.98.1056), and I get the following error. It seems to have appeared after I updated Rstudio and the installed R packages, but I suspect the two may not be directly related. The error occurs also on a very simple test file. Has anyone encountered this?
file: tests/test-all.R
library(testthat)
library(matrixUtils)
test_package("matrixUtils")
file: tests/testthat/matrixUtils-test.R
context("testa")
test_that("subsetting by one dimension", {
a <-1
expect_equal(a, 1)
})
Error message:
==> Sourcing R files in 'tests' directory
Error: '\.' is an unrecognized escape in character string starting "'\." Execution halted
Exited with status 1.
sessionInfo() R version 3.1.1 (2014-07-10) Platform: x86_64-w64-mingw32/x64 (64-bit)
locale: [1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages: [1] grid stats graphics grDevices utils datasets methods base
other attached packages: [1] magrittr_1.1.0 matrixUtils_0.2 testthat_0.8.1 dplyr_0.2.0.99 reshape2_1.4 ggplot2_1.0.0 gridExtra_0.9.1 [8] zoo_1.7-11
loaded via a namespace (and not attached): [1] assertthat_0.1 colorspace_1.2-4 digest_0.6.4 gtable_0.1.2 lattice_0.20-29 MASS_7.3-34 munsell_0.4.2 [8] parallel_3.1.1 plyr_1.8.1 proto_0.3-10 Rcpp_0.11.2 scales_0.2.4 stringr_0.6.2 tools_3.1.1
>
It's hard to check your error without the package. Some ideas:
This was a similar error reported in #187 on github/hadley/testthat.
Update testthat package. Latest is 0.9.1.
Issue was closed but looks hard to reproduce. #hadley suggests a fix
check that devtools is enabled under project options in RStudio
renkun-ken added library(devtools) as a last resort in his Rprofile.
I start RStudio without .Rprofile which runs library(devtools). Test from Test package does not work, then I run devtools::test() as you suggest, and it works.
If this does not work. Check your paths and use file.path() to create paths using strings in your package. This error seems to crop up with paths misspecified.
Hope this helps gappy and you get the "woot" happy test messages soon!
M

Exporting Arabic Text from R

I'm trying to export a data frame with Arabic text in R.
When R imports Arabic text it converts it to UTF-8 codes. Like this:
<U+0627><U+0644><U+0641><U+0631><U+0639> <U+0627><U+0644><U+062A><U+0634><U+0631><U+064A><U+0639><U+064A><U+060C> <U+0627><U+0644><U+0641><U+0631><U+0639> <U+0627><U+0644><U+062A><U+0646><U+0641><U+064A><U+0630><U+064A><U+060C><U+0627><U+0644><U+0641><U+0631><U+0639> <U+0627><U+0644><U+0642><U+0636><U+0627><U+0626><U+064A>. <U+0627><U+0644><U+062D><U+0643><U+0648><U+0645><U+0629> <U+0627><U+0644><U+0641><U+062F><U+0631><U+0627><U+0644><U+064A>
Unfortunately, I can't get it to turn back into readable Arabic when exporting. Below is code I'm using...
write.csv(my.data,"data.csv", fileEncoding='UTF-8')
Anybody have a solution?
Also, here is my session info.
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ggplot2_0.9.3.1
loaded via a namespace (and not attached):
[1] colorspace_1.2-2 dichromat_2.0-0 digest_0.6.3 grid_3.0.1 gtable_0.1.2
[6] labeling_0.2 MASS_7.3-27 munsell_0.4.2 plyr_1.8 proto_0.3-10
[11] RColorBrewer_1.0-5 reshape2_1.2.2 scales_0.2.3 stringr_0.6.2 tools_3.0.1
This code worked with me so I am sharing it:
Sys.setlocale("LC_CTYPE", "arabic" )
write.csv(group$message, file = 'posts.txt', fileEncoding = "UTF-8")
If you save the file as csv it will not work. You have to save it as txt.
You'll have to install and use locales. It's difficult and sometimes doesn't work.
There's some solutions and code offered here: Writing data isn't preserving encoding
Keep in mind that you actually HAVE to install language packs for your operating system and for some Windows versions there aren't any available separately at all.

R.matlab package appears corrupted

Solution: The package R.oo used by R.matlab has a function called getDate. I was loading --another function getDate() before loading the R.matlab package.
I can't load the R package R.matlab
Anyone has the same issue? I have the following error message:
Loading required package: R.matlab
Error in as.POSIXlt.POSIXct(x, tz) : invalid 'tz' value
Error: package 'R.matlab' could not be loaded
Edit: it happens since the last update on 3rd of Feb 2011
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252 LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] grDevices datasets splines graphics stats tcltk utils methods base
other attached packages: [1] R.oo_1.7.5 R.methodsS3_1.2.1 waveslim_1.6.4 timeDate_2130.91 ncdf_1.6.5 rgl_0.92.798
[7] fields_6.3 spam_0.23-0 splancs_2.01-27 sp_0.9-76 maps_2.1-5 shapefiles_0.6
[13] foreign_0.8-41 scrapeR_0.1.6 XML_3.2-0.2 mFilter_0.1-3 RCurl_1.5-0.1 bitops_1.0-4.1
[19] outliers_0.14 chron_2.3-39 lmtest_0.9-27 PerformanceAnalytics_1.0.3.2 RODBC_1.3-2 quantmod_0.3-15
[25] TTR_0.20-2 xts_0.7-5 zoo_1.6-4 Defaults_1.1-1 rcom_2.2-3.1 rscproxy_1.3-1
[31] svSocket_0.9-51 TinnR_1.0.3 R2HTML_2.2 Hmisc_3.8-3 survival_2.36-2
loaded via a namespace (and not attached):
[1] cluster_1.13.2 grid_2.12.1 lattice_0.19-17 svMisc_0.9-61 tools_2.12.1
That's not an issue with R.matlab, but with something else. I see that it says "loading required package: R.matlab" , so the command came from somewhere else.
> library(R.matlab)
Loading required package: R.oo
Loading required package: R.methodsS3
R.methodsS3 v1.2.1 (2010-09-18) successfully loaded. See ?R.methodsS3 for help.
R.oo v1.7.5 (2011-02-01) successfully loaded. See ?R.oo for help.
R.matlab v1.3.7 (2011-02-01) successfully loaded. See ?R.matlab for help.
On Windows 7, R 2.12.1.
Please provide the full detail of the command you used that loaded R.matlab. And you might want to post this on the R-help list or R-devel list, this seems to be a bug of some kind. It's always a good idea to put the package maintainer in cc, so they know.
Session info :
> sessionInfo()
R version 2.12.1 (2010-12-16)
Platform: i386-pc-mingw32/i386 (32-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] grid grDevices datasets splines graphics stats tcltk utils methods base
other attached packages:
[1] R.matlab_1.3.7 R.oo_1.7.5 R.methodsS3_1.2.1 reshape_0.8.3 plyr_1.2.1 gplots_2.8.0
[7] caTools_1.11 bitops_1.0-4.1 gdata_2.8.1 gtools_2.6.2 RColorBrewer_1.0-2 chron_2.3-39
[13] xlsReadWrite_1.5.3 svSocket_0.9-51 TinnR_1.0.3 R2HTML_2.2 Hmisc_3.8-3 survival_2.36-2
loaded via a namespace (and not attached):
[1] cluster_1.13.2 lattice_0.19-13 svMisc_0.9-61 tools_2.12.1
Solution: The package R.oo used by R.matlab has a function called getDate. I was loading --another function getDate() before loading the R.matlab package.

Resources