Hi,

Sorry for the newbie question! My code:

x <- 'a'
ifelse(x == 'a',y <- 1, y <- 2)
print(y)

Shouldn't this assign a value of 1? When I execute this I get:

> x <- 'a'
> ifelse(x == 'a',y <- 1, y <- 2)
[1] 1
> print(y)
[1] 2


Am I doing something really daft???

thanks!



> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] splines   parallel  stats     graphics  grDevices utils     datasets  
methods   base     

other attached packages:
 [1] Biostrings_2.30.1     XVector_0.2.0         IRanges_1.20.6        
ggplot2_0.9.3.1       sda_1.3.2             fdrtool_1.2.11        corpcor_1.6.6 
       
 [8] entropy_1.2.0         scatterplot3d_0.3-34  pdist_1.2             
hash_2.2.6            DAAG_1.18             multicore_0.1-7       
multtest_2.18.0      
[15] XML_3.95-0.2          hgu133a.db_2.10.1     affy_1.40.0           
genefilter_1.44.0     GOstats_2.28.0        graph_1.40.1          
Category_2.28.0      
[22] GO.db_2.10.1          venneuler_1.1-0       rJava_0.9-6           
colorRamps_2.3        RColorBrewer_1.0-5    sparcl_1.0.3          gap_1.1-10    
       
[29] plotrix_3.5-2         som_0.3-5             pvclust_1.2-2         
lsr_0.3.1             compute.es_0.2-2      sm_2.2-5.3            
imputation_2.0.1     
[36] locfit_1.5-9.1        TimeProjection_0.2.0  Matrix_1.1-1.1        
timeDate_3010.98      lubridate_1.3.3       gbm_2.1               
lattice_0.20-24      
[43] survival_2.37-4       RobustRankAggreg_1.1  impute_1.36.0         
reshape_0.8.4         plyr_1.8              zoo_1.7-10            
data.table_1.8.10    
[50] foreach_1.4.1         foreign_0.8-57        languageR_1.4.1       
preprocessCore_1.24.0 gtools_3.1.1          BiocInstaller_1.12.0  
org.Hs.eg.db_2.10.1  
[57] RSQLite_0.11.4        DBI_0.2-7             AnnotationDbi_1.24.0  
Biobase_2.22.0        BiocGenerics_0.8.0    biomaRt_2.18.0       

loaded via a namespace (and not attached):
 [1] affyio_1.30.0         annotate_1.40.0       AnnotationForge_1.4.4 
codetools_0.2-8       colorspace_1.2-4      dichromat_2.0-0       digest_0.6.4  
       
 [8] grid_3.0.2            GSEABase_1.24.0       gtable_0.1.2          
iterators_1.0.6       labeling_0.2          latticeExtra_0.6-26   MASS_7.3-29   
       
[15] munsell_0.4.2         proto_0.3-10          RBGL_1.38.0           
RCurl_1.95-4.1        reshape2_1.2.2        scales_0.2.3          stats4_3.0.2  
       
[22] stringr_0.6.2         tools_3.0.2           xtable_1.7-1          
zlibbioc_1.8.0

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to