首页 \ 问答 \ 在R中分配一个数字二进制类的列表(Assigning a list of numbers binary class in R)

在R中分配一个数字二进制类的列表(Assigning a list of numbers binary class in R)

我正在尝试根据以下参数将数字列表转换为二进制类:

如果该值大于3那么0

如果该值为3或小于3那么1

目前我已将下面的if else命令放在一起。 但这是一个错误。

if (df$DaysOverdue[df$daysoverdue == ">3"]) {
df$DaysOverdue[df$DaysOverdue] <- 0 
}
else {
df$DaysOverdue[df$DaysOverdue] <- 1 
}

I'm attempting to transform a list of numbers a binary class based on the below parameters:

IF the value is greater than 3 THEN 0

IF the value is 3 or less than 3 THEN 1

Currently I've put together the below if else command. But this is coming back as an error.

if (df$DaysOverdue[df$daysoverdue == ">3"]) {
df$DaysOverdue[df$DaysOverdue] <- 0 
}
else {
df$DaysOverdue[df$DaysOverdue] <- 1 
}

原文:https://stackoverflow.com/questions/46940219
更新时间:2024-05-02 06:05

最满意答案

CreateCommand属性是否触发PropertyChanged事件? 如果没有,当您指定它时,UI将不会收到通知...

尝试使用像Snoop这样的工具来检查按钮的Command属性是否已设置


Does the CreateCommand property trigger the PropertyChanged event ? If it doesn't, the UI won't be notified when you assign it...

Try to use a tool like Snoop to check whether the Command property of the button is set

相关问答

更多
  • 我也有这种问题,但不是在wpf,而是在POCO课程中。 我做的是我在两个不同的程序集中创建了两个部分类。 就像你在VM项目中创建一个不依赖于presentationcore.dll的部分类,并在另一个实现ICommand内容的程序集(比如WPFVM)中创建它的部分类。 现在对于Winforms来说,只需要向View项目添加VM项目引用,对于WPF,可以向View项目添加VM和WPFVM的引用。 我希望这将有所帮助。 I also had this kind of problem but not in wpf ...
  • 由于您的PrintDocumentCommand位于PrintViewModel但您将此Binding的Source设置为PrintDocumentCommand PrintViewModel的实例,因此无法找到它,因为Binding正在PrintDocument -Class中查找PrintDocument 。 如果要从另一个窗口打开PrintWindow,请将PrintDocument -Property和PrintDocumentCommand放在另一个Window的ViewModel中。 现在,通过 ...
  • 编辑:查看我的博客文章以获得更详细的解释。 当我需要实现这一点时,我使用我创建的IRequestCloseViewModel接口。 此接口只包含一个事件:RequestClose。 ViewModel(它继承自ViewModelBase类并实现IRequestCloseViewModel)引发此事件,当它要关闭其关联视图时。 在我的应用程序中,所有窗口都继承自抽象类ApplicationWindow。 每次DataContext改变时都会通知这个抽象类,处理程序会检查DataContext是否支持IRequ ...
  • 如果要保持干净的图层模型,则不应包含public Model model {get; set;} 在ViewModel public Model model {get; set;} 。 因此,例如,如果您有一个命令,针对某些业务模型,您的结构应该是这样的: //you don't have this one... but well, maybe other cases have public class SomeService : ISomeService { //member of ISomeSe ...
  • 我能想到的三个选择: 您可以将命令放在主窗口中,然后使用子视图中的相对源绑定到主窗口中的命令。 {Binding Path = PathToProperty,RelativeSource = {RelativeSource AncestorType = {x:Type Window}}} 如果您使用的是mvvm框架,则通常有一种方法可以在视图模型之间进行消息传递。 这通常不是最佳解决方案,但可以在适当的环境中使用。 使用IOC / Dependecy Injection创建一个在viewmodellocat ...
  • 很难说这是否是一个很好的解决方案,因为有很多关于您的应用程序架构的缺失细节。 基于前提“我有一个包含3个用户控件的窗口,我希望窗口上的按钮激活控件的视图模型上的命令”,一个解决方案可能是:
  • CreateCommand属性是否触发PropertyChanged事件? 如果没有,当您指定它时,UI将不会收到通知... 尝试使用像Snoop这样的工具来检查按钮的Command属性是否已设置 Does the CreateCommand property trigger the PropertyChanged event ? If it doesn't, the UI won't be notified when you assign it... Try to use a tool like Snoo ...
  • 我做了一个快速演示,展示了一种做法。 我保持尽可能简单,以给出一般的想法。 有很多不同的方法来完成同样的事情(例如,您可以在LoginViewModel保存对MainWindowViewModel的引用,处理其中的所有内容,然后在MainWindowViewModel上调用方法以触发工作区更改,或者您可以使用事件/消息等)。 绝对可以阅读使用MVVM的导航 。 这是一个非常好的介绍,当我开始使用它时,我发现它很有帮助。 要解决这个问题的关键是拥有一个外部MainWindowViewModel或Applica ...
  • 你需要这样的东西: 您在函数定义中缺少的是指定您期望的参数类型:) private RelayCommand _dropCommand; public RelayCommand DropCommand { get { return _dropCommand ?? (_dropCommand = new RelayCommand(Drop)); } } private static void Drop(D ...
  • 鉴于你有一系列推动指挥的物品,我建议使用类似Will的第二个建议,如下所示: 在ViewModel端,您可以使用DelegateCommand或RelayCommand来挂接处理程序方法。 这使您可以检查菜单项的数据,并根据其中的内容做所需的任何操作。 public DelegateCo ...

相关文章

更多

最新问答

更多
  • python的访问器方法有哪些
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。
  • 响应navi重叠h1和nav上的h1链接不起作用(Responsive navi overlaps h1 and navi links on h1 isn't working)
  • 在C中读取文件:“r”和“a +”标志的不同行为(Reading a File in C: different behavior for “r” and “a+” flags)
  • NFC提供什么样的带宽?(What Kind of Bandwidth does NFC Provide?)
  • 元素上的盒子阴影行为(box-shadow behaviour on elements)
  • Laravel检查是否存在记录(Laravel Checking If a Record Exists)
  • 设置base64图像的大小javascript - angularjs(set size of a base64 image javascript - angularjs)
  • 想学Linux 运维 深圳有哪个培训机构好一点
  • 为什么有时不需要在lambda中捕获一个常量变量?(Why is a const variable sometimes not required to be captured in a lambda?)
  • 在Framework 3.5中使用服务器标签<%=%>设置Visible属性(Set Visible property with server tag <%= %> in Framework 3.5)
  • AdoNetAppender中的log4net连接类型无效(log4net connection type invalid in AdoNetAppender)
  • 错误:发送后无法设置标题。(Error: Can't set headers after they are sent. authentication system)
  • 等待EC2实例重启(Wait for an EC2 instance to reboot)
  • 如何在红宝石中使用正则表达式?(How to do this in regex in ruby?)
  • 使用鼠标在OpenGL GLUT中绘制多边形(Draw a polygon in OpenGL GLUT with mouse)
  • 江民杀毒软件的KSysnon.sys模块是什么东西?
  • 处理器在传递到add_xpath()或add_value()时调用了什么顺序?(What order are processors called when passed into add_xpath() or add_value()?)
  • sp_updatestats是否导致SQL Server 2005中无法访问表?(Does sp_updatestats cause tables to be inaccessible in SQL Server 2005?)
  • 如何创建一个可以与持续运行的服务交互的CLI,类似于MySQL的shell?(How to create a CLI that can interact with a continuously running service, similar to MySQL's shell?)
  • AESGCM解密失败的MAC(AESGCM decryption failing with MAC)
  • SQL查询,其中字段不包含$ x(SQL Query Where Field DOES NOT Contain $x)
  • PerSession与PerCall(PerSession vs. PerCall)
  • C#:有两个构造函数的对象:如何限制哪些属性设置在一起?(C#: Object having two constructors: how to limit which properties are set together?)
  • 平衡一个精灵(Balancing a sprite)
  • n2cms Asp.net在“文件”菜单上给出错误(文件管理器)(n2cms Asp.net give error on Files menu (File Manager))
  • Zurb Foundation 4 - 嵌套网格对齐问题(Zurb Foundation 4 - Nested grid alignment issues)
  • 湖北京山哪里有修平板计算机的