[BioC] Simple question about Vector

Thiago Maia maia at adylnet.com.br
Tue Feb 26 14:17:06 CET 2013


Hello Mark

     Thanks a lot for the help, you was right it worked now with this  
command
bed[12] <- ifelse(bed[11] < 0, abs(bed[11]*-1),bed[11])

thanks

Thiago


> Hi Thiago,
> have a look at ?ifelse or ?abs
> cheers,
> Mark
>
> On 26/02/2013, at 10:46 PM, "Thiago [guest]" <guest at bioconductor.org>  
> wrote:
>
>>
>> Hello
>>
>>   I'm new at bioconductor and I have a very simple and stupid question,  
>> but I couldn undertand how to do that.
>>
>> I have a vector with a column with negative numbers(double). I want to  
>> change all negative to positive.
>> I then made a function:
>> -----------------------------
>> function(number){
>>    if(number < 0){
>>        number <- number * -1
>>    }
>>    return(number)
>> }
>> -----------------------------
>> then I run
>>> bed[12] <- arruma(bed[,11])
>>
>> I got this error
>>
>> Warning message:
>> In if (number < 0) { :
>>  the condition has length > 1 and only the first element will be used
>>
>> What happen is that all negative became positive and all positive  
>> became negative.
>>
>> Does enybody know what I'm doing wrong?
>>
>> thanks and best regards
>>
>> -- output of sessionInfo():
>>
>>> sessionInfo()
>> R version 2.15.2 (2012-10-26)
>> Platform: x86_64-w64-mingw32/x64 (64-bit)
>>
>> locale:
>> [1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United  
>> States.1252
>> [3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
>> [5] LC_TIME=English_United States.1252
>>
>> attached base packages:
>> [1] stats     graphics  grDevices utils     datasets  methods   base
>>
>> loaded via a namespace (and not attached):
>> [1] tools_2.15.2
>>
>> --
>> Sent via the guest posting facility at bioconductor.org.
>>
>> _______________________________________________
>> Bioconductor mailing list
>> Bioconductor at r-project.org
>> https://stat.ethz.ch/mailman/listinfo/bioconductor
>> Search the archives:  
>> http://news.gmane.org/gmane.science.biology.informatics.conductor
>


--



More information about the Bioconductor mailing list