Displaying 20 results from an estimated 30000 matches similar to: "How sample without replacement on more than one variables?"
2010 Sep 27
2
Sample size estimation for non-inferiority log-rank and Wilcoxon rank-sum tests
Hello Everyone,
I'm trying to conduct a couple of power analyses and was hoping someone might be able to help. I want to estimate the sample size that would be necessary to adequately power a couple of non-inferiority tests. The first would be a log-rank test and the second would be a Wilcoxon rank-sum test. I want to be able to determine the sample size that would be necessary to test for a
2010 Jul 07
2
How not to print '\\' as '\\'
Hello All,
'\\' is printed as '\\', but it is actually only one character.
Sometimes, I'd rather print it as a single '\'. Is there a function to
do so in R?
> nchar('\\')
[1] 1
> print('\\')
[1] "\\"
--
Tom
2011 Apr 13
2
How to get the names of all the packages that depend on a give package?
Dear All,
I want to check what packages depends on a given package. For example,
glmnet depends on Matrix. I want get the names of all the packages
that depend on Matrix on CRAN. Is there a way to do so? Thanks!
> library(glmnet)
Loading required package: Matrix
Loading required package: lattice
--
Tom
2011 Aug 08
2
enclosing with() in a function
Hi All,
I want to enclose with() in a function mean_on_element. Obviously, it
is not working. The problem is how to specify the element name with a
function body. Does anybody have any suggestion? Thanks!
> data=list(x=1:10)
> with(data, mean(x))
[1] 5.5
>
> mean_on_element=function(data, elem_name) {
+ with(data, mean(elem_name))
+ }
> mean_on_element(data, 'x')
[1] NA
2010 Jul 07
3
Weired problem when passing arguments using ...?
Hello All,
I'm trying to pass the argument col.names to write.csv using '...'.
But I got the following warnings. Maybe it is very simple. But I'm not
sure what I am wrong. Could you please help point to me what the
problem is?
#####################
fun=function(x, ...) {
fr=parent.frame()
tmp=get(x, envir=fr)
write.csv(
tmp
, file=paste(x, '.csv',
2010 Aug 05
2
a question about 'read.table' with or without 'read.table'.(urgent)
Hi, I've got a quite tricky question.
I have a txt file, named 'temp.txt', as the following:
snp1 snp2 snp3
AA 00 00
GG GG 00
00 AA 00
I want to read the file into R.
1) when I use 'read.table' without 'header=T' option,
> temp <- read.table('temp.txt')
# I got
> temp
V1
2010 Jul 14
2
How to define a function (with '<-') that has two arguments?
Hi All,
The last line if the following code returns the error right below this
paragraph. Essentially, I use the operator %:% to retrieve a variable
in a nested frame. Then I want to use the same operator (with '<-') to
change its value. I'm not sure if this is possible in R with %:%
operator. Would you please help and let me how to correct the code if
it is possible?
Error in
2007 Dec 17
2
more structure than 'str'?
How can I see more of the structure than displayed by 'str'?
Consider the following:
tstDF <- data.frame(a=1, row.names='b')
> str(tstDF)
'data.frame': 1 obs. of 1 variable:
$ a: num 1
The object 'tstDF' has row.names, but I have to suspect they are
there -- AND know a function like 'row.names' or 'dimnames' -- to see
2004 Sep 22
1
Sample without replacement
Hello, I have a simple problem (checked the archives and the appropriate
help pages, to no avail). I want to creat a vector that is length(2000).
The vector is to consist of two strings( "std" and "dev") with 1760 "std"s
and 240 "dev"s. Furthermore, for each element of the vector, i want the
selection of one of the strings to be approx. random. The
2017 Oct 18
0
uniform sampling without replacement algorithm
Splus used a similar method for sampling from "bigdata" objects. One
problem was that sample() is used both for creating a sample and for
scrambling the order of a vector. Scrambling the order of a big vector
wastes time. It would be nice to be able to tell sample() that we don't
care about the order.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Tue, Oct 17, 2017 at 10:55
2017 Oct 17
4
uniform sampling without replacement algorithm
Let us consider the current uniform sampling without replacement
algorithm. It resides in function do_sample in
https://svn.r-project.org/R/trunk/src/main/random.c
Its complexity is obviously O(n), where the sample is selected from
1...n, since the algorithm has to create a vector of length n. So when
the sample size is much lesser than n, the algorithm is not effective.
Algorithms with
2018 Mar 15
1
[GSoC 2018] Integrate with Z3 SMT solver to reduce false positives.
Hi all,
I am a fourth year EE bachelors student who is very interested in
compilers. I have taken the only compilers course offered in my school and
did an independent study with my CS professor. Although I'll begin to work
in a couple of months, I definitely want to pursue my interest in compiler
design and optimization as a PhD in the future. I am very interested in the
z3 SMT solver
2012 Jul 30
3
replace values in vector from a replacement table
Dear all
I've got stuck when trying to replace values in a vector by selecting
replacements from a replacement table. I'm trying to use only base
functions. Here's a dummy example:
> (x <- rep(letters,2))
[1] "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l"
2010 Jul 07
2
What does `_data` mean in transform()?
Hi All,
I meant to take the min row by row. But the result is apparently not
what I want. Changing min to pmin solve the problem.
> df=data.frame(X=1:10, Y=1:10)
> transform(df, Z=min(X,10-Y))
X Y Z
1 1 1 0
2 2 2 0
3 3 3 0
4 4 4 0
5 5 5 0
6 6 6 0
7 7 7 0
8 8 8 0
9 9 9 0
10 10 10 0
I try to look at the source code to understand what transform() does.
I know
2017 Oct 18
1
uniform sampling without replacement algorithm
> From: "Pavel S. Ruzankin" <ruzankin at math.nsc.ru>
> Let us consider the current uniform sampling without replacement
> algorithm. It resides in function do_sample in
> https://svn.r-project.org/R/trunk/src/main/random.c
> Its complexity is obviously O(n), where the sample is selected from
> 1...n, since the algorithm has to create a vector of length n. So
2010 Aug 02
2
Why do the results of paste() depend on how the argument (data.frame) is constructed?
Hi,
The following two 'df's should be the same, although their
constructions are different. But the results of paste() are different.
I don't see this is explained in ?paste. Could you help me understand
why it is like this?
> df=data.frame(X=c(1, 2, 3), Y=c(4, 5, 6))
> df
X Y
1 1 4
2 2 5
3 3 6
> paste(df)
[1] "c(1, 2, 3)" "c(4, 5, 6)"
>
2010 May 28
2
How to get the definition of a function if it is masked by a variable?
Hello,
Normally, if I type a function name, it shows the function definition.
When the function is masked by a variable with the same name, it
doesn't show the function definition any more. Can anyone please tell
me a way how to retrieve the function definition even if it is masked
by a variable?
> x=1:3
> length(x)
[1] 3
> length
function (x) .Primitive("length")
>
2010 May 13
2
What functions are called internally in R to resolve what variable is referred?
Hello All,
If I refer to a variable 'x', 'x' will be searched in the current
frame or the parent frame, or the parent of the parent frame, etc.,
until it is found (or not found at all)? Could you please show me what
code in R source that handles this? Is it in the C code or the R code?
Thanks,
Tom
2005 Oct 26
1
replacement in a dataframe
Hi,I want to replace some elements of a dataframe "a", using 2 index vectors ("x" and "y") and a vector of replacement ("z") of the same length of "x" and "y".
I've tried a[cbind(x,y)]<-z, but it doesn't work.How can I do it in a simply way?Thanks,
2019 Feb 26
2
bias issue in sample() (PR 17494)
Gabe
As mentioned on Twitter, I think the following behavior should be fixed
as part of the upcoming changes:
R.version.string
## [1] "R Under development (unstable) (2019-02-25 r76160)"
.Machine$double.digits
## [1] 53
set.seed(123)
RNGkind()
## [1] "Mersenne-Twister" "Inversion"??????? "Rejection"
length(table(runif(1e6)))
## [1] 999863
I don't