similar to: Sample of a subsample

Displaying 20 results from an estimated 10000 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>
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
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
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 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
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>
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
2005 Apr 29
2
Automating plot labelling in custom function in lapply() ?
Dear List, Consider the following example: dat <- data.frame(var1 = rnorm(100), var2 = rnorm(100), var3 = rnorm(100), var4 = rnorm(100)) oldpar <- par(mfrow = c(2,2), no.readonly = TRUE) invisible(lapply(dat, function(x) { plot(density(x), main = deparse(substitute(x))) } ) )
2010 Oct 03
2
Read file
Dear R-users, I would like to know how could I read a file with different lines lengths. I need read this file and create an output to feed my database. So after reading I'll need create an output like this "INSERT INTO TEMP (DATA,STATION,VAR1,VAR2) VALUES (20100910,837460, 39,390)" I mean, each line should be read. But I don`t how to do this when these lines have different
2012 Jan 10
4
Sum of a couple of variables of which a few have NA values
Dear everyone, I have looked all over the internet but I cannot find a way to solve my problem. In my data I want to sum a couple of variables. Some of these variables have NA values, and when I add them together, the result is NA dat <- data.frame( id = gl(5,1), var1 = rnorm(5, 10), var2 = rnorm(5, 7), var3 = rnorm(5, 6), var4 = rnorm(5, 3), var5 = rnorm(5, 8) ) dat[3,3] <- NA dat[4,5]
2011 May 01
2
bwplot in ascending order
Can anyone point me to examples with R code where bwplot in lattice is used to order the boxes in ascending order? I have found the following discussion and it partly works. But, I have a conditioning variable, so my example is more like bwplot(var1 ~ var2|condition, dat) Th example in the discussion below works only when there is not a conditioning variable as far as I can tell. I can tweak the
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>