在R中绘制转换后的数据

时间:2012-06-12 16:56:35

标签: r

我试图绘制最终结果。我已将我的响应变量转换为

expon=^0.2

获得描述效果的回归线。 我想保持直线并在y轴上设置指数刻度,而不是用曲线说明效果。我是否会忽略帮助页面中的某个部分?

到目前为止的相关输入是:

expon = 0.2 ## best fit for assumptions AND correlation 
tempMin = 0
dmaxDS_Summer_noSO4$response = dmaxDS_Summer_noSO4$TempChange^expon

plot(response[ind & !indClosed&!indLarge]~Sunshine[ind &!indClosed&!indLarge], 
  exp="y",data=dmaxDS_Summer_noSO4,pch=21,col="red",
  main='All Small Sites',ylab="Temperature Change^0.2",xlab="Sunshine Hrs")
abline(a[1]a[5]lwd=3,col="red")

任何指针都会受到赞赏。

1 个答案:

答案 0 :(得分:0)

您可以使用log函数的plot自变量。请参见下面的代码:

# Data Simulation
expon <- 0.2 ## best fit for assumptions AND correlation 
tempMin <- 0

dmaxDS_Summer_noSO4 <- data.frame(TempChange  = 0.2 ^ 0:100 , Sunshine = 0:100 %/% 12)
dmaxDS_Summer_noSO4$response = dmaxDS_Summer_noSO4$TempChange ^ expon
ind = seq_along(nrow(dmaxDS_Summer_noSO4))
indClosed = FALSE 
indLarge = FALSE

# Plotting
plot(response[ind & !indClosed & !indLarge] ~ Sunshine [ind & !indClosed & !indLarge], 
     data = dmaxDS_Summer_noSO4,
     pch = 21,
     col = "red",
     main = "All Small Sites",
     ylab = "Temperature Change ^ 0.2",
     xlab = "Sunshine Hrs",
     log = "y")

输出: Plot output