在R中创建间隔
我想在R中创建间隔,我已经有一些代码来获得特定的数字。
例如,以下内容:
"33" "45" "77" "82" "85"
作为我想获得以下内容的结果,最重要的是要获得范围,它不必像这样:
c(0,33), c(34,45), c(46,77), c(78,82), c(83,85), c(86,100)
如何在任何给定的数字示例中实现这一目标? 0应该始终是最小值,而100始终是最大值。
我已经尝试过这样的事情,但是显然这是不起作用的,因为k没有定义:
for(number in numbers) {
interval = c(number[k] +1, number[k+1])
I want to create intervals in R, I already got some code to get specific numbers.
For example the following:
"33" "45" "77" "82" "85"
As the result I want to get the following, the most important is to get the ranges, it doesnt have to look like this exactly:
c(0,33), c(34,45), c(46,77), c(78,82), c(83,85), c(86,100)
How can I achieve this for any given example of numbers? 0 should always be the minimum and 100 always the max.
I have tried something like this, but obviously this can't work because k is not defined:
for(number in numbers) {
interval = c(number[k] +1, number[k+1])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在矩阵中
In a matrix