  Let $X$ be a Banach space and $(e_n)_{n=1}^\infty$ be a basis. For a function
$f$ in a large collection $\mathcal{F}$ (closed under composition), we define
and characterize $f$-greedy and $f$-almost greedy bases. We study relations
among these bases as $f$ varies and show that while a basis is not almost
greedy, it can be $f$-greedy for some $f\in \mathcal{F}$. Furthermore, we prove
that for all non-identity function $f\in \mathcal{F}$, we have the surprising
equivalence $$f\mbox{-greedy}\ \Longleftrightarrow \ f\mbox{-almost greedy}.$$
We give various examples of Banach spaces to illustrate our results.
