lundi 25 octobre 2021

Passing if_else to overlay images using R magick package

Does anyone have any experience with the magick package and running ifelse/if_else statements?

Essentially I have a column which where an observation is either "yes" or "no".

If "yes" I want to overlay a "tick" image and if "no", I want to overlay a "cross" image.

This is my code

image_composite(poster, if_else(df$col1 == "yes", tick, cross), offset = "+100+200"

the "poster" is the image that I have imported into R and so is "tick" and "cross". The offset just refers to the location of the "tick" or "cross" overlaid onto "poster".

a normal example without trying to use if_else is as follows:

image_composite(poster, tick, offset = "100+200")

In the above code, poster and tick are images imported into R

Any help would be greatly appreciated

Aucun commentaire:

Enregistrer un commentaire