Can you please help me to understand this error in scan().
I believe the error is in what=list(.) If so, can someone help clarify?
It looks like it is expecting the list to contain only real numbers, but instead the list contains real numbers (0) and strings ("").
If you would like to give an empty value for a number, instead of "" try using NA. So the line would be
what=list(NA, NA, 0, 0, 0)
Related
I have a small Problem. I want to extract a special pattern like this:
v-97bcer
or b-chyfvg or ghd6db
I tried this:
identifier_1 <- "([:alnum:]{6})" # for things like this ghd6db
identifier_2 <- "([:lower:]{1})[- ][:alnum:]{6})" # for things like this v-97bcer or b-chyfvg
The problem is that the first "identifier" works well ok, but extracts for example names as well. In GHD6D8 this example the numbers have no fixed place and can occur everywhere. I do just now that the length is 6.
And the second problem is that for example V-97bcer can occur like v97bcer but I need this format v-97bcer. Here too the numbers are randomly.
If somebody could help or give me a good source for better understanding how to do this. I have not much exp in string matching. Thank you
this should work:
x <- c("v-97bcer", "b-chyfvg", "ghd6db", "v97bcer")
grep("^([a-z].)?[a-z0-9]{6}$", x)
Note that in order to fix the length of the string I provide ^ and $ to the string.
This pattern matches v-97bcer and b-chyfvg and ghd6db but not v97bcer.
I'm trying to insert a formula IFERROR using PHPExcel. However, when I try to do that I'm getting a null value like there are no values at all.
My two values that I'm getting are 0 when I generate it will give me a #DIV/0 error. I want to change that error to a complete 0.00 only, can you help me with this?
Here's my code:
$objPHPExcel->getActiveSheet()->SetCellValue('I'.$rowCount,
'=IFERROR(G'.$rowCount.'/F'.$rowCount.',0)');
I've found a workaround regarding my problem.
I've used this formula that I found in a forum from Mark Baker.
$objPHPExcel->getActiveSheet()->SetCellValue('I'.$rowCount, '=IF(F'.$rowCount.'=0, 0, G'.$rowCount.'/F'.$rowCount.')');
I have a list in which there are more than one items. Now I want to get first element's value of tRecordCount. I am trying, but getting an error System.FormatException: Input string was not in a correct format.
Can anyone tell me what is wrong in this code?
((HiddenField)GridViewPagingControl.FindControl("TotalRows")).Value = Convert.ToString(List.First(item => item.tRecordCount == Convert.ToInt32("tRecordCount")));
I have tried FirstOrDefault and Single too, but none is working. The return type of tRecordCount is int.
Thanks in Advance
May be what you want is this.
((HiddenField)GridViewPagingControl.FindControl("TotalRows")).Value = Convert.ToString(List.First().tRecordCount);
you have problem at statement
Convert.ToInt32("tRecordCount")
correct syntax in
Convert.ToInt32("/*valid integer value*/")
if tRecordCount is variable then this statement should be
Convert.ToInt32(tRecordCount)
What's wrong is:
Convert.ToInt32("tRecordCount")
You cannot convert string to int
I am trying to extract a value which is in integer form i.e 60.
I have a code that is going through each row and each column and then using getText() method retrieve the value from column.
When applying testNG assertEqual,the value is not matched as the value found is "[60 ]" instead of "[60]".
Output of trace:
The Text is 60
Exception in thread "main" java.lang.AssertionError: expected [60] but found [60 ]
at org.testng.Assert.fail(Assert.java:94)
at org.testng.Assert.failNotEquals(Assert.java:494)
at org.testng.Assert.assertEquals(Assert.java:123)
at org.testng.Assert.assertEquals(Assert.java:165)
at rough.Test.main(Test.java:83)
Can someone help me finding how I can fix the assertion?
do you in fact have a trailing space in the table?
this is an issue that is good to find in testing
perhaps you should trim the result of getText()
Maybe because your code looks something like this<td>60 </td>
You are getting that extra space. You can try something like this.
String s = node.getText().trim();
assertEqual(s, "60");
I am a new R user and having some difficulty when trying to rename certain records in a column.
My data have columns named classcode and fish_tl, among others. Classcode is a character value, fish_tl is numeric.
When classcode='OCAL' and fish_tl<20, I need to rename that value of classcode so that it is now "OCALYOY". I don't want to change any of the other records in classcode.
I'm running the following code:
data$classcode<-ifelse(data$classcode=='OCAL'& data$fish_tl<20,
'OCALYOY',data$classcode)
My problem seems to be with the "else" aspect: the code runs fine, and returns 'OCALYOY' as expected, but the other values of classcode have now been converted to numeric (although when I look at the mode of that field, it still returns as "character").
What am I doing wrong?
Thanks very much!
You can make the else part as.character(data$classcode). ifelse has some odd semantics with regard to the classes of the arguments, and it is turning your factor into it's underlying numeric representation. as.character will keep it as a character value.
You may be getting tripped up in a factor vs character issue, though you point out that R thinks it's character. Regardless, wrapping as.character() around your code seems to fix the problem for me:
> ifelse(data$classcode=='OCAL'& data$fish_tl<20,
+ 'OCALYOY',as.character(data$classcode))
#-----
[1] "BFRE" "BFRE" "BFRE" "HARG" "OCALYOY" "OYT" "OYT" "PFUR"
[9] "SPAU" "BFRE" "OCALYOY" "OCAL"
If this isn't it, can you make your question reproducible by adding the output of dput() to your question instead of the text representation?