我有一个数据集,可以测量所有> 10cm的个体,并从<10cm的个体中取样。然后,我根据重量(<已记录重量)计算<10cm的个体样本的上升因子。
然后,我可以通过将提升因子分配为ggplot中的权重来绘制ggplot中的长度频率图。但是,现在我想计算数据集<10cm的百分比和> 10cm的百分比,并且我需要使用提升因子来说明采样系统。在下面的数据集中,长度频率图的每个值6计为6的两个条目,每个值3计为6的3值,依此类推。local defMaleInfos = {
model = "models/kerry/player/citizen/male_02.mdl",
name = randommname,
surname = randommsurname,
sex = 1,
playerColor = Vector(1,1,1),
bodygroups = {
top = "polo",
pant = "pant",
},
skin = 0,
eyestexture = {
basetexture = {
["r"] = "eyes/eyes/amber_r",
["l"] = "eyes/eyes/amber_l",
},
},
hasCostume = false,
teetexture = {
basetexture = "models/citizen/body/citizen_sheet",
hasCustomThings = false,
},
panttexture = {
basetexture = "models/citizen/body/citizen_sheet",
},
}
local infos = defMaleInfos
local defFemaleInfos = {
model = "models/kerry/player/citizen/female_01.mdl",
name = randomwname,
surname = randomwsurname,
sex = 0,
playerColor = Vector(1,1,1),
bodygroups = {
top = "polo",
pant = "pant",
},
skin = 0,
eyestexture = {
basetexture = {
["r"] = "eyes/eyes/amber_r",
["l"] = "eyes/eyes/amber_l",
},
},
hasCostume = false,
teetexture = {
basetexture = "models/humans/modern/female/sheet_01",
hasCustomThings = false,
},
panttexture = {
basetexture = "models/humans/modern/female/sheet_01",
},
}
local infosw = defFemaleInfos
*code of panel*
local DButton1 = vgui.Create( "DButton", DPanel2)
DButton1:SetSize( 80,80 )
DButton1:SetPos( w/2-80/2 -100,h/4-80/2+20 )
DButton1:SetText( "" )
DButton1.Paint = function(pnl, w, h )
local m = 1
if infos.sex != 1 then
m = 0
end
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetMaterial( male )
surface.DrawTexturedRect( 2 + (w-4)/2 - 64/2, 2 + (h-4)/2 - 64/2, 64,64 )
end
DButton1.DoClick = function( pnl )
infos.name = table.Random(listWName)
infos.surname = table.Random(listWSurname)
infos = defMaleInfos
modelPanel.Actualize()
end
local DButton2 = vgui.Create( "DButton", DPanel2)
DButton2:SetSize( 80,80 )
DButton2:SetPos( w/2-80/2 + 100,h/4-80/2 +20 )
DButton2:SetText( "" )
DButton2.Paint = function(pnl, w, h )
local m = 1
if infos.sex != 0 then
m = 0
end
surface.SetDrawColor( 255, 255, 255, 255 )
surface.SetMaterial( female )
surface.DrawTexturedRect( 2 + (w-4)/2 - 64/2, 2 + (h-4)/2 - 64/2, 64,64 )
end
DButton2.DoClick = function( pnl )
infos.name = table.Random(listWName)
infos.surname = table.Random(listWSurname)
infos = defFemaleInfos
modelPanel.Actualize()
end
是否有关于如何根据凸起因子计算长度<10cm的百分比的建议?
答案 0 :(得分:0)
这是一种方法:
with(df1, sum(Raising_factor[Length < 10] / sum(Raising_factor)))
# [1] 0.8125
我们对长度符合条件的加权事件进行过滤,并计算它们相对于所有加权事件的比例。
数据
df1 <- read.table(h=T,text="
Length Raising_factor
6 2
19 1
3 6
11 1
14 1
8 5")