简体   繁体   English

如何反转log2转换

[英]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. 'y'列上的值代表收入,货币单位。 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: 我以原始形式对这些数据进行了探索性绘图,发现该图不太有用,数据的视觉效果不合适,因此为了改善我的可视化,我将log2()转换应用于'y'列。 ..它工作正常:

        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. 现在的问题是,为了完成我的分析,我需要将'y'值恢复为原始形式。 Is there anyway or implicit R function to reverse the log2() transformation I applied so I can get the original numbers back? 无论如何还是隐式R函数来反转我应用的log2()转换所以我可以得到原始数字?

It's simple. 这很简单。

First, call log2: 首先,调用log2:

data$y = log2(data$y)

After that, if you want to have the original y back just do: 在那之后,如果你想让原来的y回来,那就做:

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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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