how to switch all column that are integers into numeric except 2 columns in read.table - read.table

I do not understand why my data, when I read.table it becomes in he form of integer instead of numeric. I need the first and last column, named taxonomy and row.names to remain in the for of "character". I thought I may specify that each column is numeric except the two mentioned above but I can not get my way around...
x <- read.table (file = dfList[8],
sep = "\t",
header = TRUE,
dec = ".",
quote = "", = TRUE,
#stringsAsFactors = TRUE,
#na.strings = 0,
colClasses=c("taxonomy"="character", "row.names"="character", "^(?!taxonomy$|row.names)"="numeric"))


strip and filter strings in ragged tensor

I would like learn if there is a decent and tensorflownic way to do follow conversion. Basically each string(row) as several words, and each word has a suffix like "%1", and goal is to strip string and only leave words with suffix value <= certain target value.
It is not hard to achieve using regular python programming. But I am thinking of adding the step to a tf computational graph, so a more tensorflownic way is preferred.
text = tf.constant(['a1%0,a2%0,a3%1,a4%2,a5%3,a6%4','a7%3,a8%4',...]) #in shape of (n,) and n is large
#if target = 1, result will be
res = tf.ragged.constant([["a1", "a2", "a3"], [],...])
#if target = 3, result will be
res = tf.ragged.constant([["a1", "a2", "a3", "a4", "a5"], ["a7"],...])
You can do the following (tested in tensorflow 2.9)
text = tf.constant(['a1%0,a2%0,a3%1,a4%2,a5%3,a6%4','a7%3,a8%4',...])
target = 1
a = tf.strings.split(tf.strings.regex_replace(text, "%\d", ""), ",")
b = tf.strings.split(tf.strings.regex_replace(text, "[^,]*%", ""), ",")
b = tf.strings.to_number(b)
c = tf.ragged.boolean_mask(a, (b<=target))

generating a binary array in

I am looking for a way to fill a binary array in by binary numbers.
I filled the array line by line but I need to fill the array by using a loop
DayArray(0) = "000"
DayArray(1) = "001"
DayArray(2) = "010"
DayArray(3) = "011"
DayArray(4) = "100"
DayArray(5) = "101"
DayArray(6) = "110"
DayArray(7) = "111"
Any idea please??
As an array of strings? Increment a counter and have a function to convert that int to binary string..I believe ToString can do it..or maybe the Convert class -- look for the one where you provide 'base' (ie. 2 for binary, 16 for hex, etc). And apparently you only want last 3 digits: use SubString() of string class.
Dim DayArr(8) As String
For b As Integer = 0 To 8
DayArr(b) = Convert.ToString(b, 2).PadLeft(3, "0"c)
The Convert.ToString(b, 2) trims the leading zeros, so we need the PadLeft to make each string exactly three characters long.

Iterate through LUA Table for string match

I'm trying to match two tables by string case in sensitive.
[6] =
["itemName"] = [Ore],
["cleanName"] = [[Iron Ingot]],
["secs"] = 25004,
["gN"] = [[Luminary]],
["buyer"] = [[#Naptha42]],
["eventType"] = 15,
["timestampz"] = 1399514069,
["quantity"] = 100,
["soldAmount"] = 500,
["seller"] = [[#FataI]],
I'm trying to move items from the above table format into a new table, or filter them into a list.
g = e.cleanName
for k, v in pairs(savedTable.ALL_ITEMS) do searchTable[k] = v
if g == savedTable.ALL_ITEMS.cleanName then
table.insert(searchTable, savedTable.ALL_ITEMS)
The problem above is g never = that savedTable.
The table has a few thousand entries and I'm trying to display by search, I believe the best way is to create a new table with the values im looking for?
Or is there a way to use the string.match to iterate through the table and display (print) only these values.
I have an active search, each time the user enters a letter it will search the table.
Val1 = "Hello"
Val2 = "Goodbye"
Val3 = "Hi"
While searching and the user enters "H" or "h" I want the results for "hello, hi" to show up but not "goodbye"
so with the if g == string.match(savedTable.ALL_ITEMS.cleanName)
not sure if that is correct.
//UPDATE for solution of what worked (thanks ESOUI)
local searchForItem = string.lower(g)
for k, v in ipairs(myTable.ALL_SALES) do
-- if string.lower(g) == string.lower(v.cleanName) then
if string.lower(v.cleanName):find(searchForItem) then
if v.cleanName ~= nil then
table.insert(searchTable, v)
If ALL_ITEMS is a table that contains tables then it isn't ever going to have a cleanName field directly.
Is that == in the loop intended to be against v?
Also, if ALL_ITEMS is integer indexed you probably want ipairs instead of pairs to walk the table in order.
Why are you inserting every element into searchTable (via searchTable[k] = v) and then also attempting to insert the matching entries again (via table.insert)?
You can use string.match to match g against the cleanName in your loop if you need to but that isn't going to solve the problem if you aren't comparing what you think you are comparing.

Linq Dynamic Error with Dynamic Where clause

I have a four dropdownlists that are used to filter/order a gridview.
If any of the first 3 dropdowns have a selected value other than 0 the the WhereFlag is set to True. The fourth dropdown is used to dictate which column the grid is ordered by.
My code for databinding the gridview uses System.Linq.Dynamic and is shown below...
Dim dc As New DiaryDataContext
If WhereFlag = False Then
'This section works...
Dim AList = dc.D_AreaSubAreas _
Dim dl As List(Of D_AreaSubArea)
dl = AList.ToList
dl.Insert(0, New D_AreaSubArea With {.Ref = 0,
.Area = "",
.SubArea = "",
.Allocation = "Allocation...",
.Redundant = False})
gv_AreaSubArea.DataSource = dl
'Gridview successfully binds
'If ddl_SortBy value is changed... Gridview binds OK.
'This section gives error...
Dim WhereBuild As New StringBuilder
If ddl_AreaFilter.SelectedIndex <> 0 Then
WhereBuild.Append("Area = '" & ddl_AreaFilter.SelectedValue & "'")
AndFlag = True
End If
If ddl_SubAreaFilter.SelectedIndex <> 0 Then
If AndFlag = True Then
WhereBuild.Append(" AND ")
End If
WhereBuild.Append("SubArea = '" & ddl_SubAreaFilter.SelectedValue & "'")
AndFlag = True
End If
If ddl_AllocFilter.SelectedIndex <> 0 Then
If AndFlag = True Then
WhereBuild.Append(" AND ")
End If
WhereBuild.Append("Allocation = '" & ddl_AllocFilter.SelectedValue & "'")
End If
Dim AList = dc.D_AreaSubAreas _
.Where(WhereBuild.ToString) _
Dim dl As List(Of D_AreaSubArea)
dl = AList.ToList
dl.Insert(0, New D_AreaSubArea With {.Ref = 0,
.Area = "",
.SubArea = "",
.Allocation = "Allocation...",
.Redundant = False})
gv_AreaSubArea.DataSource = dl
End If
The error I get is with the dynamic where clause. The error I get is
ParseException is unhandled by user code. Character Literal must contain exactly one character
It points to the query AList in the Else fork. The only difference between it and the query in the If fork is the addition of the Where clause... but I have been unable to deduce what is wrong with my code. AHA.
The error points to the place where the LINQ query is evaluated and, as the message says, the problem is that a character is expected but several characters were provided.
Check whenever ddl_AreaFilter.SelectedValue, ddl_SubAreaFilter.SelectedValue or ddl_AllocFilter.SelectedValue actually contain a character or a string. If they contain more than one character, you should replace ' with \" when building the where condition, for instance:
WhereBuild.Append("Area = """ & ddl_AreaFilter.SelectedValue & """")
You must make sure that the type of the value contained in each SelectedValue string match the corresponding database type. For instance, if the database column is a numeric type, the string content will be casted to a numeric type.
When you specify the value in the comparison using quotes, you are indicating that the type on the right side of the comparison is either character or string (depending on whenever you use single or double quotes, respectively).
So, what are the Area, SubArea and Allocation types in the database?
Single character: the value in your query should be around single quotes: Area = 'value'
Strings (for instance, varchar):you must use double quotes: Area = "value"
Other: then you should use no quotes: Area = value

How to apply a style to a substring of text in Indesign?

How can I select a substring of text from my Cell, so that I can apply a character style?
This works fine when I'm only selecting a single character:
If IsNumeric(para.Contents.ToString.Substring(0, 1))
doc.Selection = para.Characters.ItemByRange(1, 1)
doc.Selection.Item(1).appliedCharacterStyle = mycharstyle
End If
but it fails if I try to select a range of characters
doc.Selection = myCell.Characters.ItemByRange(72, 76)
The error is
Invalid valid for set property 'Selection. Expected Array of Objects, Object or idNothingEnum enumerator, but received (Character, Character, Character, Character, Character)
I think there must be some entirely different technique to apply my CharacterStyle to a substring of text in my Cell, but after searching high-and-low I've yet to discover it.
got it working with GREP instead.
app.FindGrepPreferences = idNothingEnum.idNothing
app.ChangeGrepPreferences = idNothingEnum.idNothing
app.FindChangeGrepOptions.IncludeFootnotes = False
app.FindChangeGrepOptions.IncludeHiddenLayers = False
app.FindChangeGrepOptions.IncludeLockedLayersForFind = False
app.FindChangeGrepOptions.IncludeLockedStoriesForFind = False
app.FindChangeGrepOptions.IncludeMasterPages = False
mycharstyle = doc.CharacterStyles("SK-number1")
app.ChangeGrepPreferences.AppliedCharacterStyle = mycharstyle
app.FindGrepPreferences.FindWhat = "(?<=\t)(\d{4}.*~b)"