小编Nan*_*Nan的帖子

R-将数据从小数转换为小数

有没有一种简单的方法将数据帧中的数据从小数格式转换为小数格式?我有一列数据记录为分数:

级别:1/2 1/3 1/4 1/5 1/8 2/3

有没有快速的方法将其转换为.5 .333 25 .2 .125 .67?

r

12
推荐指数
1
解决办法
3065
查看次数

R:在多列中查找模式 - 可能重复()?

我试图隔离数据框中具有共同值的条目:请参阅下面的内容以重建我的df的一部分:

Stand<-c("MY","MY","MY","MY","MY")
Plot<-c(12,12,12,12,12)
StumpNumber<-c(1,2,3,3,7)
TreeNumber<-c(1,2,3,4,8)
sample<-data.frame(Stand,Plot,StumpNumber,TreeNumber)
sample
Run Code Online (Sandbox Code Playgroud)

并获得一个输出,告诉我哪些条目具有共同的值.换句话说,为了给定的Stand,Plot,StumpNumber组合快速隔离存在多个TreeNumber(或多于一行)的情况.在示例代码中,StumpNumber 3具有TreeNumber 3和TreeNumber 4.

我对duplicated()的理解是可以找到在一列中出现重复值的实例 - 我该怎么做才能找到常见的列组合出现的情况?

谢谢.

r

2
推荐指数
1
解决办法
2996
查看次数

一起填充ggplot2 legend- geom_point和geom_abline

我知道我不是第一个在这个领域提出问题的人,但我无法找到解决我特殊困境的办法.这是我的问题的精简示例.

    data<-data.frame(Est=c(1:20,1:20),Measured=c(1:5,5:9,1:6,3:6,1:6,3:6,1:4,4,4:8),variable=c(rep("Plot1",20),rep("Plot2",20)))

p<-ggplot(data,aes(y=Est,x=Measured,shape=variable))
p<- p + geom_point(stat="identity") +coord_fixed(xlim=c(0,25),ylim=c(0,25)) + theme_bw() 

p #If you plot the figure at this point, the points stand alone in the legend
p<-p+ geom_abline(intercept=0,slope=1,aes(linetype="1:1",color="1:1"),show_guide=TRUE)

p # Once the geom_abline is added, there are lines through the points. :(

p<-p+scale_color_manual(name="Lines",
                        values=c("1:1"="black"))
p<- p + scale_linetype_manual(name="Lines",
                              values=c("1:1"=2))              

p<-p + scale_shape_manual(values=c(0,20), name = "")

p<- p+xlab(expression(paste("Measured volume(",ducks^{3},"",ha^{-1},")",sep=""))) 
p<-p+ ylab(expression(paste("Estimated volume (",ducks^{3},"",ha^{-1},")",sep="")))
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,这些点的图例包括斜线(我认为它实际上是一条直线),我真的更喜欢这些点是独一无二的.

虽然示例代码只有1行和linetype,但我所做的实际数字包括五种不同颜色和线型的不同行,因此我需要一个解决方案,允许我包含多个指定颜色和线型的geom_abline调用.

不,我不是真正测量鸭子中任何东西的体积,尽管这对学习来说真的很有趣......

r ggplot2

1
推荐指数
1
解决办法
426
查看次数

标签 统计

r ×3

ggplot2 ×1