LogFAQs > #908642908

LurkerFAQs, Active DB, DB1, DB2, DB3, Database 4 ( 07.23.2018-12.31.2018 ), DB5, DB6, DB7, DB8, DB9, DB10, DB11, DB12, Clear
Topic List
Page List: 1
TopicHas anyone here ever worked with R?
jramirez23
09/13/18 12:35:11 AM
#14:


Quick way:

j = rep(NA, 1000)
for (i in 1:1000) {
j[i] = 10
}


j is a vector with 1000 entries, and it starts with all of them being garbage (NA). Then inside the for loop it populates all entries of j with the number 10.

You would want to change the line inside the loop to something like j[i] = mean(sample(1:50, 20))

Then, if you wanted to output the mean of the 135th sample you took, you just type j[135] to see what number that entry has.
---
I consider it completely unimportant who in the party will vote, or how; but what is extraordinarily important is this who will count the votes, and how.
... Copied to Clipboard!
Topic List
Page List: 1