简体   繁体   中英

How to inverse a log2 transformation

I have data in this form:

        ds           y
1   2015-12-31 51737806366
2   2016-01-01   451800500
3   2016-01-04    48503189
4   2016-01-06      221000
5   2016-01-07   542483038
6   2016-01-08   628189789
7   2016-01-09   556762005
8   2016-01-10   195672447
9   2016-01-11   279202668
10  2016-01-12   540234196
11  2016-01-13  3403591404
12  2016-01-14   610409176

the values on the 'y' column represent income, money units. I made an exploratory plot of this data in its original form and found the plot not too useful, the visual of the data was not appropriate, so in order to improve my visualizations I applied a log2() transformation to the 'y' column... it worked fine:

        ds        y
1   2015-12-31 35.59050
2   2016-01-01 28.75111
3   2016-01-04 25.53158
4   2016-01-06 17.75369
5   2016-01-07 29.01500
6   2016-01-08 29.22663
7   2016-01-09 29.05249
8   2016-01-10 27.54387
9   2016-01-11 28.05674
10  2016-01-12 29.00901
11  2016-01-13 31.66441 

The problem now is that in order to complete my analysis I need to get the 'y' values back to their original form. Is there anyway or implicit R function to reverse the log2() transformation I applied so I can get the original numbers back?

It's simple.

First, call log2:

data$y = log2(data$y)

After that, if you want to have the original y back just do:

data$y = 2^data$y

The logarithm is the inverse function to exponentiation.

The general rule is:

   logb(x) = y as by = x   

For instance:

   log2(4) = 2 as 22 = 4
   log2(8) = 3 as 23 = 8 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM