0

How to deal with a data which * in some cells before doing a regression analysis in R. Let sata i have two columns air weight and water weight with 1000 rows , in certain rows it has this "", how to deal with this "" before doing a correlation or regression in two columns

Manish
  • 1
  • 1
  • 3

2 Answers2

0

If the data's in a dataframe, then df[df == ""] <- NA should work. This'll replace all empty cells with NA values.

If you have a specific character or string you want to replace just put it between the quotes:df[df == "whatever"] <- NA.

If you want to replace the values with something that's not NA put that between the quote marks: df[df == ""] <- whatever.

Here's a link to a similar question, with a similar answer. This answer probably should've just been a comment, but I can't make comments yet. The powers that be can just turn this into one, or do whatever they see fit with it.

Community
  • 1
  • 1
0

IF You have Excel file save it as .csv then open R and write command like:

data = read.csv(D:\"data.csv"header=TRUE)
Ulysse BN
  • 10,116
  • 7
  • 54
  • 82