Installing addmtoolbox on Windows : x is not a data.table (RStudio) - r

I'm trying to install addmtoolbox on Rstudio. every things is fine but at last i got this error:
Error: Vignette re-building failed.
Execution halted
Error: Failed to install 'addmtoolbox' from GitHub:
System command 'Rcmd.exe' failed, exit status: 1, stdout + stderr (last 10 lines):
E> Quitting from lines 80-84 (addmtoolbox_modelfit_walkthrough.Rmd)
E> Error: processing vignette 'addmtoolbox_modelfit_walkthrough.Rmd' failed with diagnostics:
E> x is not a data.table
E> --- failed re-building 'addmtoolbox_modelfit_walkthrough.Rmd'
E>
E> SUMMARY: processing the following file failed:
E> 'addmtoolbox_modelfit_walkthrough.Rmd'
E>
E> Error: Vignette re-building failed.
E> Execution halted
also i'm trying to install package from zip file. installation is successful but when i run addm_preprocess function,
i got same error:
> my.dat = addm_preprocess(choice.dat = addm_data_choice,
+ eye.dat = addm_data_eye,
+ timestep = 10,
+ rtbinsize = 100)
Error in setkeyv(x, cols, verbose = verbose, physical = physical) :
x is not a data.table
would you please help me?
thanks.
addmtoolbox:
https://rdrr.io/github/AlexanderFengler/addmtoolbox/
EDIT:
i found error code:
eye$fixdur = timestep * round(eye$fixdur/timestep)
rts = eye %>% group_by(id) %>% summarize(rt = sum(fixdur))
setkey(rts,id)
choice = choice %>% select(-rt)
choice = choice[rts]
setkey(rts,id) return error:
> rts
# A tibble: 1 x 2
id rt
* <dbl> <dbl>
1 0 0
> setkey(rts,id)
Error in setkeyv(x, cols, verbose = verbose, physical = physical) :
x is not a data.table

solution by : hdkrgr
It looks like you're providing a tibble when a data.table is expected.
You should be able to convert the object with as.data.table.
Alternatively you could also use dtyplyr for unified tibble/data.table
objects. github.com/tidyverse/dtplyr

Related

Cannot install Hmisc using renv: Installing Formula [1.2-4] ... FAILED

when trying to install Hmisc in R using renv I get the message underneath. Could somebody help me please?
I'm using:
R version 4.2.0 (2022-04-22) -- "Vigorous Calisthenics", with
RStudio 2022.02.3 Build 492, using a
Platform: x86_64-apple-darwin17.0 (64-bit), and
renv 0.14.0
--
Installing 'Hmisc' ...
[1/6] Installing Formula...
Retrieving 'https://cran.rstudio.com/bin/macosx/contrib/4.2/Formula_1.2-4.tgz' ...
OK [file is up to date]
Installing Formula [1.2-4] ...
FAILED
Error in if (eval(cond, envir = environment(dot))) return(eval(expr, envir = environment(dot))) : the condition has length > 1
Calls: sourceWithProgress ... renv_scope_install -> renv_scope_install_macos -> case
In addition: Warning message:
In system2(R(), args, stdout = TRUE, stderr = TRUE) : running command ''/Library/Frameworks/R.framework/Resources/bin/R' CMD config CC 2>&1' had status 1
Traceback (most recent calls last):
15: sourceWithProgress(script = "/var/folders/y9/8c6qs4hj6pq1nnv725g7gbxw0000gn/T/9878-ce12-709e-35eb",
encoding = "UTF-8", con = stdout(), importRdata = NULL, exportRdata = NULL)
14: eval(statements[[idx]], envir = sourceEnv)
13: eval(statements[[idx]], envir = sourceEnv)
12: renv::install("Formula")
11: renv_install_impl(records)
10: renv_install_staged(records)
9: renv_install_default(records)
8: handler(package, renv_install_package(record))
7: renv_install_package(record)
6: withCallingHandlers(renv_install_package_impl(record), error = function(e) {
vwritef("\tFAILED")
writef(e$output)
})
5: renv_install_package_impl(record)
4: r_cmd_install(package, path)
3: renv_scope_install()
2: renv_scope_install_macos(.envir)
1: case(matches("/usr/bin/clang") ~ TRUE, matches("clang") ~ Sys.which("clang") ==
"/usr/bin/clang", FALSE)
Execution halted
This part of the stack trace:
< ... >
3: renv_scope_install()
2: renv_scope_install_macos(.envir)
1: case(matches("/usr/bin/clang") ~ TRUE, matches("clang") ~ Sys.which("clang") ==
"/usr/bin/clang", FALSE)
suggests that something went wrong when renv was trying to query information about the system compiler.
Somewhat surprisingly, whenever one upgrades to a new version of macOS, any existing command line tools (CLT) installation will be removed, and needs to be manually re-installed. renv relies on these command line tools being available when querying information about the system's installation capabilities, so re-installing command line tools with:
xcode-select --install
should alleviate the issue.
I've also made some changes in the development version of renv to ensure that this situation is handled and reported better.

How to solve a R package installing problem?

When I install a r package through biomanager,
BiocManager::install("hcg110.db",ask = F,update = F)
though I already downloaded it, it has such error:
Using library: D:/Program Files/rgragh/r/R-4.0.5/library
Error in get(x, envir = ns, inherits = FALSE) :
object 'is.rserver' not found
Calls: suppressMessages ... withCallingHandlers -> .get_fun -> <Anonymous> -> get
Execution halted
How could I solve it?

Why R CMD Check failed with weird error in winbuilder ? "type must be LANGSXP at this point"

I am trying to propose an update of my package 'antaresRead' on CRAN.
When I use the service "https://win-builder.r-project.org/upload.aspx" for R-devel to test my package, I have this error :
test_check("antaresRead")
Error in length(ans$indices) : type must be LANGSXP at this point
Calls: test_check ... eval -> eval -> suppressMessages -> withCallingHandlers
Logs are here
Why I have this error for this platform and with R-devel ? Can I correct It ?
When I use the same service with R-release and R-oldRelease, checks are OK :
Rrelease
RoldRelease
With the same code :
Travis Is
OK
appVeyor is OK for 8 combinations
rhub is also OK for 8 platforms
rhub::check(platform = 'debian-gcc-release')
rhub::check(platform = 'macos-elcapitan-release')
check_for_cran(platforms = "windows-x86_64-oldrel")
check_for_cran(platforms = "windows-x86_64-patched")
rhub::check(platform = 'fedora-clang-devel')
rhub::check(platform = 'fedora-gcc-devel')
rhub::check(platform = 'debian-gcc-patched')
rhub::check(platform = 'debian-gcc-devel')
Has anyone ever encountered this error? how to solve it?
What I did :
Download the R-devel version for Windows found here --> R 3.5.0
Build and check my pacakge antaresRead for x64 --> build and check are OK
Build and check my package for i386 --> build OK but faild in Check with the same error
Error in length(ans$indices) : type must be LANGSXP at this point
Calls: test_check ... eval -> eval -> suppressMessages -> withCallingHandlers
Solution :
- My bad, it's my code, it's my fault.
The error come from this code
districtLinks <- merge(districtLinks, districts[, .(district, x, y)],
by.x = "toDistrict", by.y = "district")
districtLinks is empty sometimes and with the new version of R and data.table this provokes an error only in Windows 32bits. I added a check before.
This error come because I wanted to merge an empty data.table with another data.table.
districtLinks <- merge(districtLinks, districts[, .(district, x, y)],
by.x = "toDistrict", by.y = "district")
What I did is to add a check before the merge
if(!dim(districtLinks)[1]==0){
districtLinks <- merge(districtLinks, districts[, .(district, x, y)],
by.x = "toDistrict", by.y = "district")
}

tutorial example fails: mismatch with alt-ergo?

I have installed frama-c using opam and homebrew, following the instructions from the frama-c site. I'm on Mac OS X (El Capitan), and the versions are:
frama-c: Magnesium-20151002
alt-ergo: 1.01
ocaml: 4.02.3
When I attempt to run with the swap.c tutorial, it fails to verify. Here's the error I get:
[ frama-c ]> frama-c -wp -wp-out temp swap.c swap1.h
[kernel] Parsing FRAMAC_SHARE/libc/__fc_builtin_for_normalization.i (no preprocessing)
[kernel] Parsing swap.c (with preprocessing)
[kernel] Parsing swap1.h (with preprocessing)
[wp] warning: Missing RTE guards
[wp] 2 goals scheduled
------------------------------------------------------------
--- Alt-Ergo (stdout) :
------------------------------------------------------------
File "temp/typed/swap_post_A_Alt-Ergo.mlw", line 786, characters 1-299:Valid (0.0093) (12 steps)
------------------------------------------------------------
[wp] [Alt-Ergo] Goal typed_swap_post_A : Failed
Error: Can not understand Alt-Ergo output.
[wp] Proved goals: 1 / 2
Qed: 1
Alt-Ergo: 0 (failed: 1)
The output message seems to suggest that alt-ergo could prove the assertion, but then frama-c could not parse the output. Could this be because the alt-ergo version is too new? Here is the goal on line 786 of the generated file, referenced in the above output:
goal swap_post_A:
forall t : (addr,int) farray.
forall a_1,a : addr.
let x = t[a] : int in
let x_1 = t[a_1] : int in
let x_2 = t[a_1 <- x][a <- x_1][a_1] : int in
is_sint32(x) ->
is_sint32(x_1) ->
(region(a.base) <= 0) ->
(region(a_1.base) <= 0) ->
is_sint32(x_2) ->
(x = x_2)
If I run alt-ergo on this generated file directly, it returns with code 0.

KnitR unable to download documents

I am able to run this code normally in R.
setInternet2(use = TRUE)
download.file("http://d396qusza40orc.cloudfront.net/dsscapstone/dataset/Coursera-SwiftKey.zip", "Coursera-SwiftKey.zip", method = "curl", mode = 'wb')
unzip("Coursera-SwiftKey.zip", files=c("final/en_US/en_US.twitter.txt", "final/en_US/en_US.news.txt", "final/en_US/en_US.blogs.txt"), exdir=".")
But when i try to use knitR it gives me this error
Quitting from lines 15-21 (milestone.Rmd)
Error in parse(text = x, srcfile = src) : <text>:5:106: unexpected ')'
4: unzip("Coursera-SwiftKey.zip", files=c("final/en_US/en_US.twitter.txt", "final/en_US/en_US.news.txt", "final/en_US/en_US.blogs.txt"), exdir=".")
5: file.copy(c("final/en_US/en_US.twitter.txt", "final/en_US/en_US.news.txt", "final/en_US/en_US.blogs.txt"?)
^
Calls: <Anonymous> ... <Anonymous> -> parse_all -> parse_all.character -> parse
Execution halted
I am using R Studio and MAC OS X.
I tried removing the s from https but it still di not work.

Resources