Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205372

How to place a condition on a variable [duplicate]

$
0
0

This question already has an answer here:

I have a sampling function of:

z = rnorm(n, 0.3, 1)

And would like my variable f to equal 1 if -pi < z_i < pi and equal 0 otherwise.

I'm not sure how to achieve this. My other idea was to use a reject function but this seems overly complicated.


Viewing all articles
Browse latest Browse all 205372

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>