1

I'm trying to create association rules for some error messages. But because many of the errors have numeric measurements within the text they are reading in as 64k unique error, in reality its about 200 unique error messages. I want to put the numeric values into categories (10 to 15 bins) in order to make the data more manageable. But I do not want to edit the text part of the error only the numeric.

Example Errors:

  1. error. volt 0.025, system failure sup 22 percent

  2. error. volt 0.0015, aux system failure sup 53 percent

  3. system monitor. bal 882 units. cross is -1.8

Desired output(

  1. error. volt 1, system failure sup 50 percent

  2. error. volt 1, aux system failure sup 50 percent

  3. system monitor. bal 1000 units. cross is -1

I was trying to use gsub but ran into a problem with creating bins and also so many gsubs in one.

y<- gsub("\\d\\.\\d\\d","1",data)

Any ideas on how to create bins for only the numeric part of the error message with out effecting the text? I'm not very picky on the number of bins.

Werner Hertzog
  • 2,002
  • 3
  • 24
  • 36
Coopa
  • 213
  • 1
  • 12

1 Answers1

0

I am having a little trouble understanding this, but here is what I am thinking.

Using variables assigned to characters, it is easy to put numbers beside text in your error messages using paste.

Tip: If you library(tcltk) you can also send error pop-ups to the screen,.

Here is the basic idea...

library(tcltk)
library(tcltk2)

errornumber=4

tkmessageBox(message=(paste("Error:",errornumber, 
sep=' ')),icon="warning") 

This allows you to put any number and characters together in a warning pop up.

Applied to you....

library(tcltk)
library(tcltk2)

if(volt>0 & volt<1){

error=1

tkmessageBox(message=(paste("Error:",error, 
sep=' ')),icon="warning") 

} else if (volt>1.1 & volt<5.5){

error=5.5

tkmessageBox(message=(paste("Error:",error, 
sep=' ')),icon="warning") 
}

Hopefully this helps in some way, Again not entirely sure what you are after? You can add any numbers or strings in the paste section.

EDIT: I have recreated error message # 1 for you, all you need to due is assign the correct variables based on your program and conditions

library(tcltk)
library(tcltk2)

#"Variables"
voltread=0.025
percentread=22

tkmessageBox(message=(paste("error. volt",voltread,"system failure sup"
,percentread,"percent",sep=' ')),icon="error")
Chabo
  • 2,842
  • 3
  • 17
  • 32
  • yes I can see now how my question was not very clear. Let me summarize cause I'm not sure if the tcltk package will do what I need or not. Summary: I need to put all numeric values in my existing errors into bins, with out effecting the text within those errors. is that more clear? i'll update the question as well. – Coopa Aug 15 '17 at 21:14
  • @Coopa ah, so you already have the errors made up then.The problem is parsing the data from the error. How are the errors being created? – Chabo Aug 15 '17 at 21:23
  • @Coopa These error messages, can they be read into R? (just checking), and if so what class do they fall under? – Chabo Aug 15 '17 at 21:33
  • https://stackoverflow.com/questions/15451251/extract-numeric-part-of-strings-of-mixed-numbers-and-characters-in-r The second answer on this page may be helpful if you are to convert the errors to character strings. In this answer the user creates a function which he can then run all the data through and extract only numbers. This is using the stringr package. @Coopa – Chabo Aug 15 '17 at 21:42
  • Yes, awesome! I think I can make that work! Thank you! – Coopa Aug 15 '17 at 22:01