Displaying 5 results from an estimated 5 matches similar to: "Why cannot get the expected values in my function"
2006 Dec 10
1
how to sort random numbers according to the sample ?
Dear R-users,
#### below is my code to randomized x three times.
> x=c(6,8,9,11)
> plan=NULL
> for(i in 1:3){
+ set.seed(i)
+ r<-runif(x)
+ plan=cbind(plan,r)
+ }
##### which gave the matrix
> plan
r r r
[1,] 0.2655087 0.1848823 0.1680415
[2,] 0.3721239 0.7023740 0.8075164
[3,] 0.5728534 0.5733263 0.3849424
[4,]
2010 Dec 23
1
Reconcile Random Samples
Is there a way to generate identical random samples using R's runif
function and SAS's ranuni function? I have assigned the same seed
values in both software packages, but the following results show
different results. Thanks!
R
===
> set.seed(6)
> random <- runif(10)
> random
[1] 0.6062683 0.9376420 0.2643521 0.3800939 0.8074834 0.9780757
0.9579337
[8] 0.7627319 0.5096485
2012 Dec 02
2
How to re-combine values based on an index?
I am able to split my df into two like so:
dataset <- trainset
index <- 1:nrow(dataset)
testindex <- sample(index, trunc(length(index)*30/100))
trainset <- dataset[-testindex,]
testset <- dataset[testindex,-1]
So I have the index information, how could I re-combine the data using that back into a single df?
I tried what I thought might work, but failed with:
2012 Nov 28
3
filter data.frame with a vector
Hello together,
i have a data.frame, which i want to filter with numbers in a vector.
I have a vector (Top10) with these numbers:
[1] 205 302 156 378 235 328 183 375 296 374
and i have a data.frame with a Column (CU_NO) with all my Customer numbers.
How can i filter this data.frame, with the Numbers in my vector.
this one doens't work:
2007 Feb 22
2
Is there better alternative to this loop?
Dear List,
Thanks to those who helped with my enquiry a few days ago.
I have a another question on loops, in this case I am trying to print out
the row of a data frame if the previous 3 values (daily values) in col5 are
in descending order. I have this loop which works, but ask whether this can
be done differently (without conventional loop) in R:
flag="T"
d= 3 # d represents