This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Plotting graphs using R - how to 'omit' specific values?

Hello, Asking for help from R experts here. I'm totally new in R and I'm just spending lots of time to figure out how to plot scatter plots on R. I have a large data set (>10K rows) which I wish to plot out the data using a scatter plot using this function on the tutorial: http://www.statmethods.net/graphs/scatterplot.html

plot(wt, mpg, main="Scatterplot Example", xlab="Car Weight ", ylab="Miles Per Gallon ", pch=19)

However, my dataset contains many '0' which causes the plot to look strange and wish to have them omitted. How can I do that please? Thanks!

r

1 answer

Most straightforward is to first create a new matrix/dataframe/vector from which you remove those values you don't like. So this problem comes down to subsetting your data container. But make sure to be transparent in these changes, since you are more or less 'manipulating' your data.

Hi thank you for your reply. However, there are more than 100k 0 values in the data and it's too labour intensive to remove them one by one. Is there another way which I can do this without manipulating data?

You can slice or subset your dataframe, obviously not manually but with an R command.

Hi, Genosa,

is there any function in Microsoft Excel to remove zero values from your matrix before importing it into R ?

~ Best

Doing this in R is one or two lines of code and the solution can easily be found using google or every R tutorial.

Log in to answer this question.