If we don’t like the yarn recommended for a pattern, we can substitute it, but we must be very careful. We must check that the yarn has the same weight/meterage ratio and that the fibers are the same. Then, we must make a gauge swatch.
If a pattern asks for 400 grams of yarn, we can not buy 400 grams of any yarn. We must check how many meters each 25/50/100 grams ball is made of, then we must find a yarn with the same grams/meters ratio. This yarn will have the same weight (fingering, sport, DK, Aran and so on). This is especially important for hats, mittens, sweaters, if we make a substitution for a shawl, scarf or blanket, we can choose a yarn of a different weight, but the finished item will be smaller or bigger, of course.
After checking the weight of the yarn, we must check its composition, the fibers it’s made of: wool is often elastic, alpaca, mohair and cotton are not. So if the pattern asks for an elastic yarn, we can not choose alpaca or linen, if the pattern asks for a drapey yarn like silk or rayon, probably Shetland wool is not a wise choice. Try then to sustitute a yarn with another one made of the same fibers: wool with wool, alpaca with alpaca, mohair with mohair, hemp with hemp and so on.
Then, remember to always make and wash a gauge swatch, it will help you checking out you are matching the correct tension and also you will see how the yarn matches the pattern. Maybe you won’t like the swatch. In this case, you will be able to look for another yarn before it’s too late. It’s better not to like a swatch than a finished project.