Question

This is part of my code.

library(reshape2)
setwd("C:/Users/Desktop/WildFires/FedFire8004/FedFire8004")
load("fedfire8004.rda")
library(reshape2)
Acres <- melt(fedfire8004$acres)

It reads data which has lat,lon,time(monthly) and value and converts data to below format(Acres). The problem is that in output there is no difference between month 1 and month 10. They both are stored under for example 1983.10 for month 1 and 10 of 1980.Is it possible that I store them in different format like 1980.1 and 1980.10 for month 1 and 10.

     lat  lon  month      Acre
1  -118.5 48.5 1983.10    1692.9
2  -117.5 48.5 1983.10      11.1
3  -116.5 48.5 1983.10       0.0
4  -115.5 48.5 1983.10       1.1
5  -114.5 48.5 1983.10       0.0
6  -113.5 48.5 1983.10     151.2
7  -112.5 48.5 1983.10       5.0
Was it helpful?

Solution

I think the problem comes from melt applying type.convert to the dim names of your data. To avoid character to numeric conversion, you can replace the . by a -. Try:

dimnames(fedfire8004$acres)$month <- sub("\\.", "-",
                                         dimnames(fedfire8004$acres)$month)

Then apply melt again and you should see 1980-1 and 1980-10.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top