How to run a simple for loop with a function within in R?

In the following dataset, I want to computer the function decostand every 72 rows. Do this 10 times. Here is what I tried. library(vegan) library(truncnorm) df <- data.frame(set = rep(c(1:10), each = 72), sp1 = rep(rtruncnorm(72, a=0, b=800, mean = 50, sd = 20), times = 10), sp2 = rep(rtruncnorm(72, a=0, b=800, mean = 70,… Read More How to run a simple for loop with a function within in R?

All possible way of adding up number in a sequence so that it becomes a given number

I was given range n and number k. Count the possible ways so that two (not identical) number in that range add up to number k. And can this be done without nested loops? Here’s my approach, the only thing is I’m using a nested loop, which takes times and not computer-friendly. Opposite pairs like… Read More All possible way of adding up number in a sequence so that it becomes a given number

Compare string array1 with string array2 and return entries that are not present in array2

I have two arrays in my C++ code. array1 has all elements but array2 has the same elements but with a few missing. I am trying to find out the elements that are missing in array2. Instead of showing the missing elements, it is showing elements which are also present in both the arrays and… Read More Compare string array1 with string array2 and return entries that are not present in array2