How can I get the output as a vector in R?
For example, if I want to have
for (i in 1:1000) {if i mod 123345 = 0, a = list(i)}
a
but I would want to find all i that divide evenly into 123345 (i.e., factors), and not just the largest one.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There may be a more concise way to do this, but I would do it this way:
The resulting vector
jcontains a vector of the values in i which are factors of 12345. In R the modulo operator is %% and it’s a bit of a bitch to find when searching on your own. It’s buried in the help document for arithmetic operators and you can find it by searching for+which must be in quotes like:?"+"and then you have to read down a bit.You better add a VBA tag if you want to find a VBA answer. But I suspect it will involve the VBA modulo operator 😉