[R] Index vectors get overwriten ?!

A.J. Rossini rossini at blindglobe.net
Thu May 3 15:19:31 CEST 2001


"_" is an assignment operator.  Use "." or capitalization to construct
variables.

best,
-tony

>>>>> "TB" == Thomas Bruns <Thomas.Bruns at ptb.de> writes:

    TB> Hello, For some analysis of a mesh structure I need to prepare
    TB> several vectors of indexes of different length. This is done
    TB> by the following code sequence (including diagnostic output):
    TB> #-------------------------------------------------- MT_ind <-
    TB> which(V1.frame[,2] %in% mm[,1]) print("M_ind") str(M_ind)
		
    TB> Q1_ind <- which(V1.frame[,2] %in% mq1) print("Q1_ind")
    TB> str(Q1_ind)

    TB> Q2_ind <- which(V1.frame[,2] %in% mq2) print("Q2_ind")
    TB> str(Q2_ind)

    TB> MS_ind <- which(V1.frame[,2] %in% ms) print("MS_ind")
    TB> str(MS_ind)

    TB> print ("---------------") print("M_ind") str(M_ind)
    TB> print("Q1_ind") str(Q1_ind) print("Q2_ind") str(Q2_ind)
    TB> print("MS_ind") str(MS_ind)
    TB> #-----------------------------------------------------

    TB> Although the Index vectors *_ind have different names they get
    TB> subsequently overwriten, as you see in the diagnostic output:

    TB> [1] "M_ind" int [1:12023] 6952 6953 6954 6957 6958 6959 6962
    TB> 6963 6964 6965 ...  [1] "Q1_ind" int [1:331] 1 2 3 4 5 6 7 8 9
    TB> 10 ...  [1] "Q2_ind" int [1:331] 6952 6957 6962 6963 6964 6965
    TB> 6966 6967 6968 6969 ...  [1] "MS_ind" int [1:3] 15237 15238
    TB> 15239 [1] "---------------" [1] "M_ind" int [1:3] 15237 15238
    TB> 15239 [1] "Q1_ind" int [1:3] 15237 15238 15239 [1] "Q2_ind"
    TB> int [1:3] 15237 15238 15239 [1] "MS_ind" int [1:3] 15237 15238
    TB> 15239


    TB> Everything is now equal to MS_ind which was asigned last!  So,
    TB> can anybody tell me what's happened here? Am I working on
    TB> memory pointers without knowing??

    TB> Tia!

    TB> Thomas



    TB> -- -------------------------------------------------------
    TB> Dr. Thomas Bruns <thomas.bruns at ptb.de>

    TB>          Physikalisch-Technische Bundesanstalt Braunschweig
    TB> Fachlabor: 1.13 Bundesallee 100 Tel: 0531/592 - 1132 D-38116
    TB> Braunschweig Fax: 0531/592-69-1132
    TB> -------------------------------------------------------
    TB> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
    TB> r-help mailing list -- Read
    TB> http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info",
    TB> "help", or "[un]subscribe" (in the "body", not the subject !)
    TB> To: r-help-request at stat.math.ethz.ch
    TB> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._




-- 
A.J. Rossini				Rsrch. Asst. Prof. of Biostatistics
UW Biostat/Center for AIDS Research	rossini at u.washington.edu	
FHCRC/SCHARP/HIV Vaccine Trials Net	rossini at scharp.org
-------- (friday is unknown) --------
FHCRC: M--W : 206-667-7025 (fax=4812)|Voicemail is pretty sketchy
CFAR:  ??   : 206-731-3647 (fax=3694)|Email is far better than phone
UW:    Th   : 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list