# Finding corrupted data in R [closed]

I have got a file that contains 1024 subjects, each have 3 data points. I need to find a corrupted data among them. I know for sure that there is just one data that is corrupted and it is quite evident when I look at the data but how do I do it through R? Need to find the row number that has the corrupted file. Thanks!

• What do you mean by "corrupted"? An invalid data point? A large value? What data structure? Mar 22 '17 at 23:27
• An invalid data point.
– A.S
Mar 23 '17 at 0:59
• As given this is too broad to reasonably answer. As phrased it is primarily about writing code "how do I do it through R? Need to find the row number..." which is off topic (see under Programming, and as also see the same link under homework -- whether you consider this homework or not, the statements there apply. If you can edit to make this narrower/clearer, to be about statistics rather than R code and to follow the guidelines for self-study posts, then it might be reopened. Mar 27 '17 at 5:39

Okay, so say that your dataframe is Patients. In R just click ...

> View(Patients) # This gives you a spreadsheet view of your dataframe.
> summary(Patients) # This gives you tabulated distribution of your columns.


Then you just click with your computer mouse on the top of the column that might be giving you the issue and it will realign all rows so that the highest datapoint is given in the first row and then the lowest data point is at the last row.

You didn't specify if the issue is a maximum or minimum outlier, but that's probably the issue.

You can also reorganize your data-frame with the order function with the argument ", decreasing = TRUE" in it, and sort.default is also a good way to do it particularly with respect to singular columns.

You can also use a boxplot to find the range of your error, so that you can use discretionary deletion.

If R is too advanced for you, then you can export your data.frame to a file as a comma separated values file (.csv) with "write.csv()", and edit it in Microsoft Excel or LibreOffice Calc, and then re-read it into R with "read.csv()" after you made some changes. If you do edit your data in a spreadsheet make sure every column has the same number of rows, or when you ask R to make a dataframe of your file then R will just proverbially scream at you.

• I don't really know what the invalid point is. The question just says there is one corrupted data.
– A.S
Mar 23 '17 at 3:00
• Can you describe what your corrupted data is like? You don't need to know what the invalid point is. A boxplot, a summary, and View will tell you. It will be the first row if you interactively sort your dataframe with respect to one suspect column. If your invalid point is the greatest point, then View() sorting will solve it. The corrupt point will be in the first row. If you make a boxplot, then the outliers will be trailing dots which you can see fit between the y-axis range of your boxplot. If you make a histogram, your outlier will be large peak with with no distribution. Mar 23 '17 at 3:06