Displaying 20 results from an estimated 11000 matches similar to: "Sample of a subsample"
2017 Sep 25
0
Sample of a subsample
For personal aesthetic reasons, I changed the name "data" to "dat".
Your code, with a slight modification:
set.seed (1357) ## for reproducibility
dat <- data.frame(var1=seq(1:40), var2=seq(40,1))
dat$sampleNo <- 0
idx <- sample(seq(1,nrow(dat)), size=10, replace=F)
dat[idx,"sampleNo"] <-1
## yielding
> dat
var1 var2 sampleNo
1 1 40
2017 Sep 25
1
Sample of a subsample
Hi David,
I was about to post a reply when Bert responded. His answer is good
and his comment to use the name 'dat' rather than 'data' is instructive.
I am providing my suggestion as well because I think it may address
what was causing you some confusion (mainly to use "which", but also
the missing !)
idx2 <- sample( which( (!data$var1%%2) & data$sampleNo==0 ),
2012 Apr 12
4
Recode Variable
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120412/74331e9a/attachment.pl>
2012 Feb 13
3
Change dataframe-structure
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120213/d2a5afa6/attachment.pl>
2012 May 07
2
y-axis-problem (barplots)
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120507/f2dfaa17/attachment.pl>
2012 Apr 22
1
Transform dataframe
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120422/bb638d28/attachment.pl>
2013 May 13
2
reduce three columns to one with the colnames
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130513/fe848ce7/attachment.pl>
2013 Jan 21
4
missing values are not allowed in subscripted assignments of data frames
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130121/317d3f7b/attachment.pl>
2009 Jan 13
3
Comparing elements for equality
Suppose I have a dataframe as follows:
dat <- data.frame(id = c(1,1,2,2,2), var1 = c(10,10,20,20,25), var2 =
c('foo', 'foo', 'foo', 'foobar', 'foo'))
Now, if I were to subset by id, such as:
> subset(dat, id==1)
id var1 var2
1 1 10 foo
2 1 10 foo
I can see that the elements in var1 are exactly the same and the
elements in var2 are exactly
2002 Jul 09
3
Assignment converts variable to factor
Hello,
I would like to know if this behaviour in R is as expected.
I have a data frame 'dat' with column var1 being character (and not
factor). Then I create a new column 'var2' by:
> dat[,"var2"] <- dat$var1;
Column var2 is now a factor.
But if I do:
> dat$var2 <- dat$var1;
Then column var2 is character (and not factor).
I don't want to have
2013 Mar 04
3
urgent: question concerning data manipulation
Ein eingebundener Text mit undefiniertem Zeichensatz wurde abgetrennt.
Name: nicht verf?gbar
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130304/62581e97/attachment.pl>
2012 Jan 16
3
Select rows based on multiple comparisons
Dear all,
I have a data set in which the same unit appears 2 or 3 or 4 times. I need
to aggregate this data to maintain only one unit by row. But I need to do
that based on a comparison between the values of such units. I can't find a
function to help me on that. I appreciate any help. Below I provide an
example of what I want:
This is my data:
Units Var1 Var2 Var3
1 B 2
2009 May 20
1
Comparing spatial distributions - permutation test implementation
Hello everyone,
I am looking at the joint spatial distribution of 2 kinds of organisms
(estimated on a grid of points) and want to test for significant
association or dissociation.
My first question is: do you know a nice technique to do that,
considering that I have a limited number of points (36) but that they
are repeated (4 times)? I did GLMs to test for correlations between
the
2013 Apr 05
4
[LLVMdev] A strange testing case of SROA
Hi,
Following is excerpted from dynamic-vector-gep.ll.
The resulting "extractelement" seems to always return 0.0f regardless
the value idx1 and idx2 is holding.
Am I missing something here or there is something fishy take place?
Thanks
Shuxin
101 ; CHECK: test6
102 ; CHECK: insertelement <4 x float> zeroinitializer, float
1.000000e+00, i32 %idx1
103 ; CHECK:
2012 Oct 17
2
loop of quartile groups
Greetings R users,
My goal is to generate quartile groups of each variable in my data set. I
would like each experiment to have its designated group added as a
subsequent column. I can accomplish this individually with the following
code:
brks <- with(data_variables,
cut2(var2, g=4))
#I don't want the actual numbers, I need a numbered group
data$test1=factor(brks,
2007 Apr 02
3
Create a new var reflecting the order of subjects in existing var
Dear R helpers
I have a data set sth like this:
set.seed(123);dat <- data.frame(ID= c(rep(1,2),rep(2,3), rep(3,3), rep(4,4),
rep(5,5)),
var1 =rnorm(17, 35,2),
var2=runif(17,0,1))
dat
ID var1 var2
1 1 33.87905 0.02461368
2 1 34.53965 0.47779597
3 2 38.11742 0.75845954
4 2 35.14102 0.21640794
5 2 35.25858 0.31818101
6 3 38.43013
2012 Apr 26
2
How to plot graph with different scale (y axis) on same graph?
Hi,
I have my data in below format.
position var1 var2
2 .1 10
3 .29 89
12 .56 100
425 .34 1234
6546 .12 21
.... ..... .....
.... ..... ......
2013 Apr 05
0
[LLVMdev] A strange testing case of SROA
Hi Shuxin
I think i might have written that test. And yeah, no matter what values you get you’ll get a 0.0. Its probably a bad test case, but i can’t remember if it exposed a bug in this form or not. Since writing it Chandler rewrote SROA anyway so the original bug is long gone.
Thanks,
Pete
On Apr 5, 2013, at 11:57 AM, Shuxin Yang <shuxin.llvm at gmail.com> wrote:
> Hi,
>
>
2010 Jul 30
2
Summing by index
# build a sample data frame illustrating the problem
ids<-c(rep(1234,5),rep(5436,3),rep(7864,4))
years<-c(seq(1990,1994,by=1),seq(1991,1993,by=1),seq(1990,1993,by=1))
data<-seq(14,25,by=1)
data[6]<-NA
DF<-data.frame(Id=ids,Year=years,Data=data)
DF
Id Year Data
1 1234 1990 14
2 1234 1991 15
3 1234 1992 16
4 1234 1993 17
5 1234 1994 18
6 5436 1991 NA
7
2003 Aug 26
2
Simple simulation in R
Hello all
I have a feeling this is very simple......but I am not sure how to do
it
My boss has two variables, one is an average of 4 numbers, the other is
an average of 3 of those numbers i.e
var1 = (X1 + X2 + X3 + X4)/4
var2 = (X1 + X2 + X3)/3
all of the X variables are supposed to be measuring similar constructs
not surprisingly, these are highly correlated (r = .98), the question
is how