Due date : 01 Dec 2019, 23:00
Objectives
- Function
- Condition Statments
- Loops
Questions
1 - A dependent function chain is defined as \(h(x)=\frac{log(x)-1}{\sqrt{x}}\), \(g(x)=e^{\sqrt{h(x)}}\) and \(f(x)=sing(x)^{cosg(x)}\). Create a function and solve \(f(x)\) for each x <- 4:250. Print and plot \(f(x)\).
exeedence <- function() {
x <- 4:250
# Fill here
plot(fx)
}
2 - Create a function that calculates number of exceedence of a specified threshold in an random x vector. If the number of exceedence is higher than threshold than print a sentence, else print another sentence for warning.
exeedence <- function(n, min, max, threshold) {
# Fill here
# You can use runif() function
}
3 - Create a function calculates the sum of digits of any integer. For instance, sum of digits of 385102 is 3 + 8 + 5 + 1 + 2 = 19. While sum is lower than 50, then add 10 to sum and print a warning sentence.
sumofdig <- function(x) {
# Fill here
# You can use strsplit() function
}
For questions or problems, please use Ninova
I inspired from Ismail SEZEN
LS0tCnRpdGxlOiAiU29mdHdhcmUgVG9vbHMsIFIgLSBIb21ld29yazMiCm91dHB1dDoKICBwZGZfZG9jdW1lbnQ6IGRlZmF1bHQKICBodG1sX25vdGVib29rOiBkZWZhdWx0Ci0tLQoKKipEdWUgZGF0ZSoqIDogMDEgRGVjIDIwMTksIDIzOjAwCgoqKioKCiMjIyMgPHNwYW4gc3R5bGU9ImNvbG9yOmdyZWVuIj4qKk9iamVjdGl2ZXMqKjwvc3Bhbj4KCi0gRnVuY3Rpb24KLSBDb25kaXRpb24gU3RhdG1lbnRzCi0gTG9vcHMKCioqKgoKIyMjIyA8c3BhbiBzdHlsZT0iY29sb3I6YnJvd24iPioqUXVlc3Rpb25zKio8L3NwYW4+CgoqKioKCioqMSoqIC0gQSBkZXBlbmRlbnQgZnVuY3Rpb24gY2hhaW4gaXMgZGVmaW5lZCBhcyAkaCh4KT1cZnJhY3tsb2coeCktMX17XHNxcnR7eH19JCwgJGcoeCk9ZV57XHNxcnR7aCh4KX19JCBhbmQgJGYoeCk9c2luZyh4KV57Y29zZyh4KX0kLiAgQ3Jl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