When using jmv code, it would be helpful if the with() function could pass in data. Currently it generates an error:
> with(mydata100,
+ contTables(rows = "workshop",
+ cols = "gender",
+ pcRow = TRUE)
+ )
Error in super$initialize(package = "jmv", name = "contTables", version = c(1, :
argument "data" is missing, with no default
> contTables(data = mydata100,
+ rows = "workshop",
+ cols = "gender",
+ pcRow = TRUE)
Compatability with R's with() function
- BobMuenchen
- Posts: 16
- Joined: Thu Jan 18, 2018 6:24 pm
- Location: Knoxville
- Contact:
Re: Compatability with R's with() function
righto, i'll take a look at the `with()` function.
(although i am having difficulty getting jmvcore updates to CRAN at the moment. it works everywhere except their debian environment, but they won't tell me why, and i can't reproduce on any of my VMs )
(although i am having difficulty getting jmvcore updates to CRAN at the moment. it works everywhere except their debian environment, but they won't tell me why, and i can't reproduce on any of my VMs )
- BobMuenchen
- Posts: 16
- Joined: Thu Jan 18, 2018 6:24 pm
- Location: Knoxville
- Contact:
Re: Compatability with R's with() function
hi bob,
do you understand how `with()` works?
but all that's printed is an empty character() vector
any tips?
with thanks
do you understand how `with()` works?
so i would expect the following to create a new environment containing the variables 'len', 'dose' and 'supp', and ls() to show as much:with is a generic function that evaluates expr in a local environment constructed from data
Code: Select all
data('ToothGrowth')
callback <- function(...) {
print(ls())
}
with(ToothGrowth, callback())
any tips?
with thanks
- BobMuenchen
- Posts: 16
- Joined: Thu Jan 18, 2018 6:24 pm
- Location: Knoxville
- Contact:
Re: Compatability with R's with() function
Wow, that is freaky! I thought I knew a fair amount about with(), but I don't know why that's not giving you a list of the variables as will happen using:
> with(ToothGrowth, ls())
[1] "dose" "len" "supp"
I've tried every variation I can think of in creating a function and the only thing that doesn't screw it up is just a straight copy into a new function name. Here's what I know about how with() affects R's search order, though I don't know if there's a clue in that or not:
http://r4stats.com/2012/09/25/specifyin ... bles-in-r/
> with(ToothGrowth, ls())
[1] "dose" "len" "supp"
I've tried every variation I can think of in creating a function and the only thing that doesn't screw it up is just a straight copy into a new function name. Here's what I know about how with() affects R's search order, though I don't know if there's a clue in that or not:
http://r4stats.com/2012/09/25/specifyin ... bles-in-r/