Question: I have a manager application that can maintain reserve state for some time for another application which has been closed. Manager application used `System.nanoTime()` to calculate reserve time, but now I need to save and restore state for this manager application (e.g. save and restore sessions in reserve and calculate time again), thus `System.nanoTime()` is not suitable anymore: it's not a good idea to summarize `System.nanoTime()` between JVM\PC reboots to maintain global timeline.
So I switched to `RuntimeMXBean` and it's `getUptime()` method for this purpose. But now I have another trouble: the time my manager application is down, there's no way to know for how long it is down. Hence if I have, for example, reserve for 60 minutes, app will be reservd for 60 minutes if manager application is up and running. And if I shut down my PC for 10 minutes, these 10 minutes will be lost and when I run manager application again, it will restore its state and count reserve as 60 minutes.
I'm looking for the way to know time since some point in the past until current time which cannot be modified by changing system or BIOS clock. Important note: manager application does not have access to web, so I can't use NTP.
Is there some ways to do that?

Answer: 
Try this, which converts all the variables to factors (which R assigns a number behind the scenes), then extracts the underlying number value:

Data

```
df <- data.frame(DistanceFromHome = c("Close", "Far", "Medium", "Far", "Close"),
                 MonthlyIncome = c("<1000", "1000-5000", "<1000", ">5000", "1000-5000"))

```

Code

```
convert_cols <- 1:ncol(df)
df[convert_cols] <- lapply(df[convert_cols], function(x) as.numeric(as.factor(x)))

```

Output:

```
#   DistanceFromHome MonthlyIncome
# 1                1             1
# 2                2             3
# 3                3             1
# 4                2             2
# 5                1             3

```

Since you didnt provide sample data, I dont know if this exact code will work, but you can change `convert_cols` to whatever columns you want to extract the numbers from (here I just did all)
Data.matrix() might do the job.
Borrowing the worked example from jpsmith's solution:

```
df <- data.frame(DistanceFromHome = c("Close", "Far", "Medium", "Far", "Close"),
                 MonthlyIncome = c("<1000", "1000-5000", "<1000", ">5000", "1000-5000"))

data.matrix(df)

```

Gives:

```
> data.matrix(df)
     DistanceFromHome MonthlyIncome
[1,]                1             1
[2,]                2             3
[3,]                3             1
[4,]                2             2
[5,]                1             3

```