please help!
I'm new to R and trying to get into it. I keep getting same warning:
Warning messages:
1: In if ((AttrSum[i, 1] == AllAttr[i:length(AllAttr), 1])) { : the condition has length > 1 and only the first element will be used
I have 3 csv files. 1- AttrSum[90,2] has 90 rows,2 col....2-TC_RC [80,12]...3-AllAttr[70,20] has 20 columns and 70 rows. I want to check if first column of AttrSum[,1] is equal to 12th column of TC_RC [,12], then divide 19th column of AllAttr[,19] to the 2nd column of AttrSum[,2] w.r.t appropriate 1st columns(that are present in TC_RC [,12]=RC_ind). I'm doing this:
AttrSum <-read.csv()
AllAttr <- read.csv()
RC_sum <-AttrSum [AttrSum [,1]%in%TC_RC[,12], col_ind]# values
RC_ind <- AttrSum [(AttrSum [,1] %in%TC_RC[,12]), 1]#names
len_attrSum <- length (AttrSum)
CV <- c()
for (i in 1:len_attrSum){
if (all(RC_ind [i] == AllAttr[i:length(AllAttr),1])){
CV[i] <- (RC_sum[i]/AllAttr[,19])
}
}
Sorry for such a basic question but i'm stuck here. I understand that i have problem with my loop but cannot see what is it. I looked at Introduction to R but still cannot get it.
Thanks in advance
PS: 1-AttrSum[90,2] file.
Case x
2 1.784309
3 2.836969
4 0.791783
5 1.812687
8 0.385067
.......
90 0.771613
2-TC_RC[80,12] file. 12 columns,80 rows.
10 41.166667 1 0.364352 47 0.944911 49 26.833333 26.833333 1 0.324537 49
100 40.625 0 0.112847 55 0.953485 107 33.625 42.25 0 0.117361 109
101 29.75 0 0.082639 111 0.917909 107 12.625 29.75 0 0.082639 111
AllAttr [90,19] file
Case V16 V15 V14 V8 V9 V9.1 V10 V11 V12 V13 V1 V2 V3 V4 V5 V6 Vl7 VB 2 0.577967 0.023869 0.021571 0.481754 0.61584 0 0 0 0 0 0.024057 0.039251 0 0 0 0 0 4 3 0.327011 0.095338 0.025591 0.785795 0.511902 0.516165 0 0 0 0 0.033882 0.028056 0.513229 0 0 0 0 4