search for: mysample

Displaying 20 results from an estimated 21 matches for "mysample".

2011 Aug 12
1
Which Durbin-Watson is correct? (weights involved) - using durbinWatsonTest and dwtest (packages car and lmtest)
Hello! I have a data frame mysample (sorry for a long way of creating it below - but I need it in this form, and it works). I regress Y onto X1 through X11 - first without weights, then with weights: regtest1<-lm(Y~., data=mysample[-13])) regtest2<-lm(Y~., data=mysample[-13]),weights=mysample$weight) summary(regtest1) summary(...
2017 Aug 19
4
My very first loop!! I failed. May I have some start-up aid?
...), Latitude=c("54.753","54.753","54.752","54.751") ) myframe # Now this is where my loop is supposed to start. In this example I want to run the following functions 3 times. (In real life more often.) How do I do that? library(adehabitatHR) library(rgdal) mysample <- myframe[sample(1:nrow(myframe), 3,replace=FALSE),] mysample mysampletime <- as.POSIXct (strptime(as.character(mysample$Timestamp), "%d.%m.%Y %H:%M"), tz="GMT") mysamplexy <- project (cbind (mysample$Longitude, mysample$Latitude), "+proj=utm +zone=32 +ellps=WGS...
2012 Mar 07
5
Sampling problems
Hi, I need to sample randomly my dataset for 1000 times. The sample need to be the 80%. I know how to do that, my problem is that not only I need the 80%, but I also need the corresponding 20% each time. Is there any way to do that? Alternatively, I was thinking to something like setdiff () function to compare my 80% sample to the original dataset and obtain the corresponding 20%, unfortunately
2012 May 08
1
revolution foreach oddity
...lution to give different numbers is using 1 instead of 8 in registerDoSNOW(makeCluster(8, type = "SOCK")) but that seems to defeat the point. library(foreach) library(doSNOW) registerDoSNOW(makeCluster(8, type = "SOCK")) getDoParWorkers() getDoParName() getDoParVersion() mySamples <- foreach (jj = 1:4, .combine=cbind) %dopar% { return(sample(1:10,10,replace=TRUE)) } mySamples ########## r 2.14.1 ########## > library(foreach) > library(doSNOW) > registerDoSNOW(makeCluster(8, type = "SOCK")) > getDoParWorkers() [1] 8 > getDoParName() [1] &...
2017 Aug 19
0
My very first loop!! I failed. May I have some start-up aid?
...y loaded #> Loaded GDAL runtime: GDAL 1.11.3, released 2015/09/16 #> Path to GDAL shared files: /usr/share/gdal/1.11 #> Loaded PROJ.4 runtime: Rel. 4.9.2, 08 September 2015, [PJ_VERSION: 492] #> Path to PROJ.4 shared files: (autodetected) #> Linking to sp version: 1.2-5 myframe$mysampletime <- as.POSIXct( myframe$Timestamp , format = "%d.%m.%Y %H:%M" , tz="GMT" ) set.seed( 42 ) N <- 3 result <- matrix( NA, nrow = 16, ncol = N ) for ( i in seq.int(...
2017 Aug 19
0
My very first loop!! I failed. May I have some start-up aid?
...this example I want > to run the following functions 3 times. (In real life more often.) How do I > do that? > > library(adehabitatHR) > library(rgdal) > you should use require instead of library if this is a script, require returns boolean, whereas library raises an exception. mysample <- myframe[sample(1:nrow(myframe), 3,replace=FALSE),] > mysample > mysampletime <- as.POSIXct (strptime(as.character(mysample$Timestamp), > "%d.%m.%Y %H:%M"), tz="GMT") > mysamplexy <- project (cbind (mysample$Longitude, mysample$Latitude), > "+proj=...
2009 Dec 21
3
Question About Repeat Random Sampling from a Data Frame
...ach variable within each subset for my characteristic of interest. I am familiar with sampling and saving single columns of data to do this sort of thing, but I am not sure how to accomplish this with a multiple-variable data set. For example, I am currently iterating this using a clunky process: mysamples<-list() for (i in 1:10){ mysamples[[i]] <- dataset[ sample(1:1637,100,prob=c(rep(163.7/1637,513),rep(245.5/1637,197),rep(1227.8/1637,927)),replace = TRUE), ] } But this leaves me with the additional task of defining each mysample[i] iteration and converting it to a form on which I can apply...
2012 Jun 14
1
Question about sampling
...,1,0 sample11,Control,1,1,1,1 sample24,Control,-1,-1,1,0 sample29,Control,1,-1,1,0 sample42,Case,-1,-1,1,0 sample64,Case,-1,1,1,0 .... I'm interested to mantain in my subsample the same frequencies of those observed for the 1 value in each column I approached the problem with sample() function mysample<-df[sample(1:nrow(df),100,replace=F),] Then I tested that the frequencies of each allele in mysample are not statistically different respect to the initial dataset by mean of prop.test This seems to work but do you know if there is a package that can do the same thing allowing for example a mo...
2010 Jul 12
1
long to wide on larger data set
...ample # i have commented out the write.table statement below testData <- read.table(textConnection("rs9999853,cv0084,A,A rs999986,cv0084,C,B rs9999883,cv0084,E,F rs9999853,cv0085,G,H rs999986,cv0085,I,J rs9999883,cv0085,K,L"),header=FALSE,sep=",") closeAllConnections() mysamples <- unique(testData$V2) for (one_ind in mysamples) { one_sample <- testData[testData$V2==one_ind,] mywide <- reshape(one_sample, timevar = "V1", idvar = "V2",direction = "wide") # write.table(mywide,file ="newdata.txt",append=TRUE,row.names=...
2007 Feb 27
3
looping
Greetings: I am looking for some help (probably really basic) with looping. What I want to do is repeatedly sample observations (about 100 per sample) from a large dataset (100,000 observations). I would like the samples labelled sample.1, sample.2, and so on (or some other suitably simple naming scheme). To do this manually I would >smp.1 <- sample(100000, 100) >sample.1 <-
2011 Apr 08
3
random sampling with levels and with replacement
...has  two levels 40 bad and 360 good among other variables,how do i come up  with10 random samples that have the composition of as the main sample  but maintaining the 40 bad 360 good with replacement, i recently discovered that my random samples generated dont maintain the ratio. My code is as  : mysample <- final[sample(1:nrow(final), 400,replace=TRUE),] does not give me the ratio of 40 bad and 360 good can anyone give me some pointers please? Thanks, Taby [[alternative HTML version deleted]]
2009 Aug 20
2
boxplot with log="y" and values starting at 0
Hi, I'm working with a data.frame containing values between 0 and 22000. Most of the values are actually between 0 and 50 and the high ones are outliers. I want to generate a boxplot and since the outliers are extremely high, I need to scale the y scale logarithmically. Otherwise one wouldn't really see the boxes of the boxplot. boxplot(dat, log="y", ylim=c(0,
2009 Nov 13
2
help sample from large dataset - misleading error?
Hi All, I want to take a simple random sample from a large dataset, gly, but I'm getting an error message. Any help? dim(gly) [1] 112371 37 > s1 <- sample(gly,100) Error in `[.data.frame`(x, .Internal(sample(length(x), size, replace, : cannot take a sample larger than the population when 'replace = FALSE' Thanks, Rachel [[alternative HTML version
2010 Aug 17
1
using color palette in persp
Hello! I am using persp to get a plot of a 32x48 matrix. data <- as.matrix(read.table(file="mySample.dat")) persp(data) And I'm having trouble with trying to give a z-dependent palette to it like rainbow (or any built in one would do). How to combine that with the "col" argument? nice day Szilvi -- View this message in context: http://r.789695.n4.nabble.com/using-color-palet...
2003 Jun 18
2
Private: Problem with tapply/lapply and sample (PR#3286)
Full_Name: Peter Gedeck Version: R1.6.2 and R1.7.0 OS: Windows XP Submission from: (NULL) (194.191.169.72) Hello, I marked the bug report Private, as I don't want my email address on the web server. The problem that I found is best explained using an example. index <- 1:6 cluster <- c(1,1,1,2,2,3) tapply(index,cluster,sample) gives $"1" [1] 2 1 3 $"2" [1] 4 5
2009 May 21
3
Problems with sample variance
Dear R users, I am a beginner to R. I generated 1000 samples with 15 data in each sample I tried finding the variance for each sample I used the code: m=1000;n=15 > r<-rnorm(15000) > for(i in 1:m){ x=data[,i] v=var(x)} what I got was just the variance for the last sample i.e. the 1000th sample but what I want is 1000 variance. Does anyone know what I did wrong? Thanks Chloe Smith
2008 Dec 01
3
exclude a vector value from another vector
Dear All, I am trying to build a program which will take repeated samples (w/o replacement) from a population of values. The interesting catch is that I would like the sample values to be removed from the population, after each sample is taken. For example: pop<-c(1,5,14,7,9,12,18,19,65,54) sample(pop, 2) = lets say, (5,54) ## This is where I would like values (5, 54) to be removed from
2005 Feb 28
1
draw random samples from empirical distribution
Dear useRs, I have an empirical distribution (not normal etc) and I want to draw random samples from it. One solution I can think of is to compute let's say 100 quantiles, then use runif() to draw a random number Q between 1 and 100, and finally run runif() again to pull a random value from the quantile Q. Is there perhaps a better/more elegant way of doing this? Thank you, b.
2007 Oct 10
3
simulated data using empirical distribution
Hello all: I'm sure this is a trivial request, but I'm still a beginner at this, and haven't been able to find it. I need to create simulated data based on some empirical distributions of a single variable. I've found R functions to help me simulate data based on analytical distributions, or to make simulations based on correlation matrices, but nothing so simple as what I need.
2010 Oct 03
2
How to programme R to randomly replace some X values with Outliers
Dear experts, I am a beginner of R. I'm looking for experts to guide me how to do programming in R in order to randomly replace 5 observations in X explanatory variable with outliers drawn from U(15,20) in sample size n=100. The replacement subject to y < 15. The ultimate goal of my study is to compare the std of y with and without the presence of outliers based on average of 1000