It's important to realize that other people may have something going on in their life that affects their mood and maybe their desire to be friends. If it is someone you know at work they may not be comfortable talking to you about the problem. I think you should always be friendly, but if someone isn't friendly back don't just assume its because of you.