ply
March 10, 2022, 2:01pm
1
How do I pass an extra two arguments to a purrr:map function
This works ( not real code )
test -> function(.value) {
print value
}
purrr::map(values,test)
but how do I send two extra parameters A and B to the function
test -> function(.value) { ( 2nd and 3rd parameter ??? )
print value
...do something with a A
...do something with a B
}
purrr::map(values,test,??? )
I think I have seen the tilde character used ie ~test
Thanks
purrr::map(values, ~test(.,A,B))
run test for every member of values, when you run test put the member of values as the first parameter (where the . shortcut is, and use A and B as the other parameters)
ply
March 10, 2022, 2:32pm
3
Thanks..does the function change
ie test -< function(.value, A,B) ?
I dont understand your question... ?
ply
March 10, 2022, 2:44pm
5
Its ok..I worked out..thanks
system
Closed
March 31, 2022, 2:44pm
6
This topic was automatically closed 21 days after the last reply. New replies are no longer allowed. If you have a query related to it or one of the replies, start a new topic and refer back with a link.