subset - R accessing variable column names for subsetting -


does the following and what I want to do:

  dat & Lt; -subset (Figures,% NLI in% NLI)  

However, I might require a subset through a separate column (i.e. NLI.2 and NLI.3). I have tried

  NLI_col & lt; - "NLI.1" NLI_col & lt; -subset (data, select = NLI_col) data & lt; Data -subset (% NLI, NLI_col%)  

surprised it to achieve results does not address how I use NLI_col do?

It was requested that I give the example that looks like data . Here:

  NLI.1 & lt; -c (NA, NA, NA, NA, NA, 1,2,2,2, NA, 2,2,2,2,2,2,2, 2, NA, NA, 2,2,2,2 , NA, 2,2,2,2,2,2,2, NA, NA, NA, NA, 2,2,2,2,2,2,2,2,2,2,2,2,2 , 2,2,2,2,2,2,2,2,2,2,2, NA, 2,2,2,2,2,2,2,2,2,2, NA, 2,2 , 2,2,2,2,2,2,2,2,2,2,1,2,2,2,2,2,1,2,2,2,2,2,1,1,2,2 , 2,2,2,2,2,2,2,2,2,2,2,1,1,1,2,2,1,2,2, 2) NLI2 and LT; -C (NA, NA, NA, NA, NA, 2,2,2, NA, NA, 2,2,2,2,2,2, NA, 2,2, 2,2,2, NA, 2 , 2,2,2,2,2,2, NA, NA, NA, NA, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 , 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, NA, 2,2,2,2 , 2,2,2,2,2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2 , 2,2,2,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2) NLI.3 & lt; -C (NA, 35.40, NA 10, NA 31, NA 14, NA, NA, 15,17, NA, NA, 16,10,15,14,39,17,35,14,14 , 22, 10,15,0,34,23,13,35,32,2,14,10,14,10,10,10,40,10,13,13,10,10,10,13,13 , 25, 10, 35, NA, 13, NA, 10, 40,0,0, 20, 40,10,14,40,10,10,10,10,13,10,8, NA, NA, 14 , NA, 10,28,10,10,15,15,16,10,10,35,16, NA, NA, NA, NA, 30,19,14,30,10,10,8,10,21 , 10, 10,35,15,34,10,39, NA, 10,10,6,16,10,10,10,10,34,10) Other & lt; -C (NA, NA 511, NA, NA, NA, NA, NA, 849, NA, NA, NA, NA, 1324,1181,832,1005,166,204,1253,529,317,294, NA, 514,801,534,1319,272,315,572 , 96,666,236,842,980,290,843,904,528,27,366,540,560,659,106,63,20,1184,1052,211,651,687,434,1115,128,455,764,938,1188,105,757,719,1236,982,710, NA, NA, 632, NA, 546,747,941,1257, 99,133,61,249, NA, NA , 1080, NA, 645,19,107,486,1198,276,777,738,1073,539,1096,686,505,104,5,55,553,1023,1333, NA, NA, 969,691,1227,1059,358,991,1019, NA, 1216) data & lt ; -cbind (NLI.1, NLI.2, NLI.3, others) NLI & lt; -c (10,13)  

With this, after the sub-setting, I will see the data in $ NLI.3 in NLI_col & lt; - "NLI.3"

should be in the tens and all rows with thirteens relatively insignificant I am guessing that it is a duplicate question (drag my apologies), but hours And I still can find a solution

Looks like you unnecessarily subset < / Code>. Try it out:

  NLI_col & lt; - 'NLI.3' Head (data [, NLI_col] %% in NLI) ## [1] false false false false true false head (data [data [, NLI_col]%% of NLI,]) ## NLI.1 NLI.2 NLI.3 Other ## 5 NA NA 10 NA ## 17 2 2 10 1005 ## 26 2 2 10 801 ## 31 2 2 13 572 ## 36 2 2 10 980 ## 38 2 2 10 843 < / Code> 

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -