-2

I am trying to format my presence/absence data in a way that I can input it into RPresence. I have a dataframe that consists of 0,1, and 2's. For the Presence software I need to have a dataframe that consists of 0,1, and "." or "-" to represent missing data. I am able to replace all of the 2 with 1 and 1 with 0, but haven't been able to convert the 0 to a character. I was just looking for a simple way in order to perform this conversion.

Devin Mendez
  • 101
  • 8
  • Are they really 0s or are they missing data? What have you tried already? – Sven May 17 '19 at 15:30
  • They are all 0s. I have tried converting them to NA with the na_if function in dplyr, but then when I exported to excel all of the NA's were converted to 0's. I think the problem is that I have my data is all numeric and I'm trying to convert specific cells to characters? – Devin Mendez May 17 '19 at 15:40
  • Are you sure this is what you want to do? If you replace `0` with `.` you'll turn it into character type. Wouldn't logical, with `NA` for missing values make more sense? – AkselA May 17 '19 at 15:40
  • I agree I think that would make more sense. The presence software only reads "." or "-" as missing data. – Devin Mendez May 17 '19 at 15:44

1 Answers1

1

Perhaps you could do:

df[df == 0] <- "-"
Lennyy
  • 5,932
  • 2
  • 10
  • 23