Error/Warning using the replicate function in R -


i trying replicate station number 24 times each using code follows:

stnid <- null  (i in 1:24) {   stnid[i] <- rep(paste0("station",i),times=24) }  > stnid  [1] "station1"  "station2"  "station3"  "station4"  "station5"  "station6"  "station7"  "station8"  "station9"  [10] "station10" "station11" "station12" "station13" "station14" "station15" "station16" "station17" "station18" [19] "station19" "station20" "station21" "station22" "station23" "station24" 

however, warnings saying :

> warnings() warning messages: 1: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 2: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 3: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 4: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 5: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 6: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 7: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 8: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 9: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 10: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 11: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 12: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 13: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 14: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 15: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 16: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 17: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 18: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 19: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 20: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 21: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 22: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 23: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 24: in stnid[i] <- rep(paste0("station", i), times = 24) :   number of items replace not multiple of replacement length 

could explain did wrong here ? thanks.

expected:

each station station 1 station24 24 times each.

is want?

rep(x = paste0("station", 1:24), times = 24) 

or if rather want stations same number occur together:

rep(x = paste0("station", 1:24), each = 24) 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -