How to use the result of lp() as a value [closed] - r

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
I am using the lp() function, but would like to use the optimal parameter as an input for following functions. Is there a way to get them?

You could also use missing() to test whether or not the argument b was supplied:
myFunc <- function(a,b){
if(missing(b)) {
a
} else {
a + b
}
}
myFunc(3,1.5)
# [1] 4.5
myFunc(3)
# [1] 3

Related

generate all possible k-mers from a vector and also remaining in r [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 1 year ago.
Improve this question
Suppose we have a vector [1:10] of players, I want to generate all possible roommates for these playes (not combn(10, 2))
Can you help me?
Thank you
You can iterate over combn(with different ks)
x= 1:10
lapply(1:length(x), function(k) combn(x,k))

How to integrate following function in R? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I am not able to integrate this function.
I am getting an error: argument "y" is missing, with no default. The answer to this problem is 1.
First of all, your expression is actually a function of y.
If you want to write the double integral, you can make it with integrate (but you need to simplify the integral a bit in advance)
f <- function(y) 6*integrate(function(x) x,0,1)$value*integrate(function(z) z**2,0,y)$value/y**2
Mathematically, you can derive that, the function f can be further simplified to
f <- function(y) y

Create a function within a function [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
How to make a function within a function?
My goal is to insert the function inside the function.
Here is an example of function inside a function
f <- function(n) {
g <- function(x) {
x**n
}
}
such that
> f(3)(4)
[1] 64
But I have no idea what you are exactly after...

How to print a character vector 'pretty' in R Markdown? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
Is there a function such as kable to output character vectors in a way that doesn't look as ugly as the default console type?
See eg p from the pander package or the generic pander method:
> pander::pander(sample(letters, 5))
_p_, _r_, _v_, _f_ and _t_
If you want to override the default formatting, see panderOptions or specify directly in the p function.

Variable path in a loop [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I would like to get this loop to work. I am trying to save different dataframes with different names at once. I don't know how to get the path part of the code to vary with i:
for (i in specific) {
write.dta(get(paste0("degreeS", i)), "D:/Educacion/PeerEffects/",paste0( "degreeS", i,".dta"))
}
I needed to use the command file.path(). This solved the problem
for (i in specific) {
write.dta(get(paste0("degreeS", i)), file.path("D://Educacion//PeerEffects//", paste0("degreeS", i,".dta")))
}

Resources