Skip to content

Instantly share code, notes, and snippets.

@tdsmith
Created September 15, 2014 20:20
Show Gist options
  • Save tdsmith/dd7f19eb93b80c7a7742 to your computer and use it in GitHub Desktop.
Save tdsmith/dd7f19eb93b80c7a7742 to your computer and use it in GitHub Desktop.
> a = data.frame(foo=c(1,2,3), bar=c(-1,2,-3))
> a
foo bar
1 1 -1
2 2 2
3 3 -3
> ifelse(a$bar < 0, -a$bar, a$bar)
[1] 1 2 3
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment