Average value of Vout
I found that when Vin > 0 then D1 is off, and D2 is on, so Vout = I1R1 = 1V. And when Vin &lt; 0 then D1 is on and D2 is off, so Vout = 1 + Vin. Is this correct?


Yes, that's correct.


  Now I think I need to use  \$f_{avg}=\frac{1}{b-a}\int_a^bf(x)dx\$


\$f\$ in this sense means function, not frequency. Because this question will give the same answer if the frequency is 1 kHz or 10 kHz, the average will be the same since everything is ideal. 

So in order to calculate \$f_{avg}\$ correctly we need to know what \$a\$ and \$b\$ are. I will write it in your way, and in my way. 



Your way

Find out when the \$V_{in}\$ is less than 0, because that's the only time we have to care about it as you stated above in the first yellow box. 

If we know that the frequency is 1 kHz and a sine wave, then the period time is 1 ms, from 0.5 ms to 1 ms it will be negative. This is \$a\$ and \$b\$.

\$f_{avg}=\frac{1}{(1-0.5)×10^{-3}}\int_{0.5×10^{-3}}^{1×10^{-3}} 10×\sin(2×\pi×1000×x)dx\$

If we continue we get that \$f_{avg}=-6.3662\$



My way

We want to get a half period of a sine wave, right? Then let's just integrate a half sine and change the sign.

\$f_{avg}=-\frac{1}{\pi}\int_{0}^{\pi}10×\sin(x)dx\$

In my opinion this one is much easier to calculate, I can even do it in my head.

\$f_{avg}=-\frac{1}{\pi}×10[-\cos(x)]_{0}^\pi = -\frac{1}{\pi}×10(1+1) = -10×\frac{2}{\pi} = -6.3662\$

Ahh! Now I see where those numbers came from. No wolframalpha here. 



We know that half of the time \$V_{out}\$ will be \$1\$ V, other half of the time it will be \$1-6.3662\$. 

So the total average for a whole period will be \$\frac{1+1-6.3662}{2}= -2.1830\$ V.