我的问题类似于将 R ggplot中的直方图中的y轴标准化为比例, 但我想稍微添加一下.
一般来说,我在2x3小平面设计中有6个直方图,我想分别对它们进行标准化.我将尝试在此处创建一个示例数据集以提供一个想法:
hvalues=c(3,1,3,2,2,5,1,1,12,1,4,3)
season=c("fall","fall","fall","fall","winter","winter","winter","winter","summer","summer","summer","summer")
year=c("year 1","year 1","year 2","year 2","year 1","year 1","year 2","year 2","year 1","year 1","year 2","year 2")
group=c("fall year 1","fall year 1","fall year 2","fall year 2","winter year 1","winter year 1","winter year 2","winter year 2","summer year 1","summer year 1","summer year 2","summer year 2")
all=data.frame(hvalues,season,year)
Run Code Online (Sandbox Code Playgroud)
运用
ggplot(all, aes(x=hvalues,group=group)) +
geom_histogram(aes(y=..count../sum(..count..))) +
facet_grid(season ~ year)
Run Code Online (Sandbox Code Playgroud)
给出整体比例(即组合所有方面).我希望每个组的方面都被标准化为1.在我的实际数据中,hvalues不是整数 - 它们是数字的.
我是一个使用R的新手,非常感谢一些帮助.提前致谢!
我有一个位置估计数据库,并希望计算每月内核利用率分布.我可以使用R中的adehabitat包来做到这一点,但是我想使用来自数据库的示例的引导来估计这些值的95%置信区间.今天我一直在尝试使用启动包,但我仍然是R的新手,需要更多的专家帮助!我得到的主要错误信息是:
Error in statistic(data, original, ...) : unused argument(s) (original)
Run Code Online (Sandbox Code Playgroud)
这是我一直在使用的文件:
head(all)
Num Hourbin COA_Lat COA_Lon POINT_X POINT_Y month year id
1 07/10/2010 15:00 48.56225 -53.89144 729339.9 5383461 October 2010 29912
2 07/10/2010 16:00 48.56254 -53.89121 729355.7 5383495 October 2010 29912
4 07/10/2010 18:00 48.56225 -53.89144 729339.7 5383461 October 2010 29912
5 07/10/2010 19:00 48.56225 -53.89144 729339.9 5383461 October 2010 29912
6 07/10/2010 20:00 48.56225 -53.89144 729339.8 5383461 October 2010 29912
7 07/10/2010 21:00 48.56225 -53.89144 729339.9 5383461 October 2010 …Run Code Online (Sandbox Code Playgroud) 我正在尝试将双变量位置点连接在一起以形成路线.我的观点指的是鱼的位置,所以我需要的路径只能通过水,而不是周围的土地.基本上,我需要进行多个最低成本路径分析并完全加入它们.我想在R中这样做,因为我在那里有比在ArcGIS,python,modelbuilder等方面更多的经验.
我已经使用ArcGIS创建了一个成本曲面,水编码为0,并将土地编码为"NoData",并将其导入R.
我尝试过使用gdistance pkg中的shortestPath,但是当我尝试运行它时,R总是关闭我,即使只是在两点之间.例如:
costpath=shortestPath(costtrans,c29924[1,],c29924[2,],output="SpatialLines")
Run Code Online (Sandbox Code Playgroud)
我的成本表面是"costtrans",而"c29924"是具有我的纬度/经度位置的SpatialPointsDataFrame.我曾计划运行一个循环,以便我可以为数据框中的每一行执行此操作.但是,我不知道为什么R不能很好地处理一次迭代.将我的成本表面转换为第一个争论的过渡对象时,我收到以下警告消息:
Warning messages:
1: In array(ans, c(len.a%/%d2, d.ans), if (!all(vapply(dn.ans, is.null, :
Reached total allocation of 6057Mb: see help(memory.size)
2: In array(ans, c(len.a%/%d2, d.ans), if (!all(vapply(dn.ans, is.null, :
Reached total allocation of 6057Mb: see help(memory.size)
3: In as.vector(transition.values) :
Reached total allocation of 6057Mb: see help(memory.size)
4: In as.vector(transition.values) :
Reached total allocation of 6057Mb: see help(memory.size)
5: In .TM.repl.i.mat(as(x, "TsparseMatrix"), i = i, value = value) :
number of items to replace is not …Run Code Online (Sandbox Code Playgroud)