jeudi 4 février 2021

Replace value with empty cell conditionally?

I've tried using similar answers to code my current approach, but I am getting a replacement of NA literally when I want the rows/cells to be missing.

I am looking to replace a column that gives a text description with empty rows depending on conditions - in order to plot the rows in a graph without text overlapping the same space.

Currently I am using:

ex$description[which(ex$plot_X > -1.25 & ex$plot_X < 1.25 & ex$plot_Y > -1.25 
& ex$plot_Y < 1.25 & ex$log10_p_value > -10.00)] = "NA"

Conditions are the row is being plotted within -1.25 and +1.25 of a graph and has an insignificant log pvalue - then for these rows I want their ex$description column to be empty so no text appears on the graph.

Unfortunately I can't give example data for this - is there a way my code can be modified so when the conditions are met the ex$description column is empty and not actually the text NA - right now when my code runs I get several of NA overlapping on my plot.

Aucun commentaire:

Enregistrer un commentaire