similar to: using "sample()" for a vector of length 1

Displaying 20 results from an estimated 20000 matches similar to: "using "sample()" for a vector of length 1"

2010 Mar 23
1
[patch] add is.set parameter to sample()
Hi all, sample() has some well-documented undesirable behaviour. sample(1:6, 1) sample(2:6, 1) ... sample(5:6, 1) do what you expect, but sample(6:6, 1) sample(1:6, 1) do the same thing. This behaviour is documented: If 'x' has length 1, is numeric (in the sense of 'is.numeric') and 'x >= 1', sampling _via_ 'sample' takes place from
2009 May 28
2
Bug in base function sample ( ) (PR#13727)
Full_Name: Michael Chajewski Version: 2.9.0 OS: Windows XP Submission from: (NULL) (150.108.71.185) I was programming a routine which kept reducing the array from which a random sample was taken, resulting in a single number. I discovered that when R attempts to sample from an object with only one number it does not reproduce/report the number but instead chooses a random number between 1 and
2007 Jun 05
5
sampling problem - new to R
I have a data set of individual trees and the plots that they are in: Tree Plot 56749 1 63494 1 87375 1 37494 2 92753 3 34847 3 38747 4 etc... So each plot is represented once for every individual that occurrs in it. Plots get different numbers of rows because there can be a different number of individuals in each plot. I want to make a data frame that consists of one
2012 Jul 30
1
problem plotting in a grid
Hi all, I'm trying to generate a grid of four plots. The first 2 appear just fine, but the final 2 will not appear in the grid, instead overwriting the first two. Any ideas on how to get them all in the same window would be greatly appreciated. Cheers, Jonathan library(fields) par(mfrow=c(2,2)) #2x2 plot windows plot(c(2,4),c(2,2)) # works fine plot(c(2,4),c(2,2)) # works fine
2008 Aug 28
2
sample consecutive integers efficiently
Hi all, I have some rough code to sample consecutive integers with length according to a vector of lengths #sample space (representing positions) pos<-c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) #sample lengths lengths<-c(2,3,2) From these two vectors I need a vector of sampled positions. the sampling is without replacement, making things tough as the sampled integers need
2007 Mar 21
2
Encoding audio sampled at 44.1 khz?
Hi everyone, I recently began using libspeex 1.2 Beta 1 on Windows using MS Visual C++. I have gotten a decoder and an encoder to work fine from the excellent sample code posted at the website. But I face a problem. I am working on using Speex in a program to play and create audio books encoded using Speex (currently testing it only; for these tests, I do not use Ogg to save the encoded
2008 Dec 30
5
Randomly remove condition-selected rows from a matrix
Hello all, I create the following matrix: m <- matrix(1:20, nrow = 10, ncol = 2) which looks like: [,1] [,2] [1,] 1 11 [2,] 2 12 [3,] 3 13 [4,] 4 14 [5,] 5 15 [6,] 6 16 [7,] 7 17 [8,] 8 18 [9,] 9 19 [10,] 10 20 Then, I want to remove randomly 2 rows among the ones where m[,1]<8 and m[,2]>12 I suppose the
2006 Oct 19
4
Question about random sampling in R
Hi, I looked up the help file on sample(), but didn't find the info I was looking for. When sample() is used to resample from a distribution, e.g., bootstrap, how does it do it? Does it use an uniform distribution, e.g., runif(), or something else? And, when the help file says:"sample(x) generates a random permutation of the elements of x (or 1:x)", would I be correct if I
2015 Jun 15
3
Add-on argument in sample()
Hi. I have a problem with the default behavior of sample(), which performs sample(1:x) when x is a single value. This behavior is well explained in ?sample. However, this behavior is annoying when the number of value is not predictable. Would it be possible to add an argument that desactivates this and perform the sampling on a single value ? Examples: > sample(10, size = 1, replace = FALSE)
2007 Mar 22
1
[SPAM] RE: Encoding audio sampled at 44.1 khz?
________________________________ Hi David, Thank you very much for your reply. Since I need to resample the audio in the program itself, I decided to try out the resampling API in speex. But now, I have another problem. The resampled sound is very much distorted and clicks appear quite often. (I have attached the source code I used for testing it below). The test data I had was a file sampled
2009 Feb 25
2
[R] length 1 offset in glm (& lm)
This post about length 1 offsets on R help seems to have been ignored (sorry deleted original email - is there a way to continue thread in this case?) https://stat.ethz.ch/pipermail/r-help/2009-February/189352.html It does seem to be a bug, in that glm does not behave as documented. In fact the same bug applies to lm as well. I don't think the suggested fix works though - Y isn't
2006 Jan 23
1
Sample rows in data frame by subsets
Hi, I need to resample rows in a data frame by subsets L3 <- LETTERS[1:3] d <- data.frame(cbind(x=1, y=1:10), fac=sample(L3, 10, repl=TRUE)) x y fac 1 1 1 A 2 1 2 A 3 1 3 A 4 1 4 A 5 1 5 C 6 1 6 C 7 1 7 B 8 1 8 A 9 1 9 C 10 1 10 A I have seen this used to sample rows with replacement d[sample(nrow(d), replace=T), ] x y fac 7 1 7 B 2
2009 Jan 02
1
[Fwd: Re: [R] Randomly remove condition-selected rows from a matrix]
Following Duncan's suggestion, I forward the below to R-devel. vQ -------- Original Message -------- Subject: Re: [R] Randomly remove condition-selected rows from a matrix Date: Fri, 02 Jan 2009 10:34:52 -0500 From: Duncan Murdoch <murdoch at stats.uwo.ca> To: Wacek Kusnierczyk <Waclaw.Marcin.Kusnierczyk at idi.ntnu.no> CC: R help <R-help at stat.math.ethz.ch>
2008 Dec 11
3
Resampling physiological data using R?
Dear all R users, I am going to use R to process some of my physiological data about eye. The problem is the recording machine does not sample in a reliably constant rate: the time intervals between data sampled can vary from 9msec to ~120msec, while most around in the 15-30msec range. The below is a fraction of a single data file of a trial: Time CursorX CursorY Pupilsize 1811543 -1 -1 -1
2007 May 02
2
how to reproduce the same sampled units?
Hi all, Is it possible to generate the same sample number of times in R? In SAS, using the option "seed" it is possible to reproduce exactly the same sample. Is there any such feature in R which I can use? For further clarity, for (i in 1:2) { samp = sample(1:1000,100,replace = FALSE) print(samp) } For the above simulation, is it possible to generate the same sampled units
2009 Dec 20
2
read.table: mysterious line omissions
Hello again, I am simply trying to import a rectangular table of strings. The table's dimensions are 1990 x 2, yet my read.table() command can only find 362 of the rows (and they're not the first 362). I would've taken the time to figure out how to use scan, readLines, or some other tool that can read in character strings, and then parse and input to a table, but that seems like
2004 Oct 07
1
sample suggestion
I have been bitten by what is clearly described on the help page for 'sample', namely sampling from a population of size one. I agree that it is convenient to have an exception if 'length(x) == 1', but my suggestion is to enforce the exception only if 'x' is numeric. In any case, if x is not numeric and of length 1, all you get is an error message. I would like
2002 Dec 22
1
oggdropXPd.exe crashes when resampling is activated
I need to encode a WAV to OGG but must resample to 22050 samples per second, but can't do that with oggdropXPd.exe. The application always crashes. What I do is: Start oggdropXPd.exe. Right-click on fish, choosing 'Encoding Options'. Under Advanced Options, I set Re-sample to 22050 samples per second. Click 'Accept'. Drag WAV on fish. In the directory where the WAV originates,
2018 Jan 19
1
Re: [PATCH nbdkit filters-v2 2/5] Introduce filters.
On 01/19/2018 11:12 AM, Richard W.M. Jones wrote: >>> + >>> +=head2 C<.pread> >>> + >>> + int (*pread) (struct nbdkit_next_ops *next_ops, void *nxdata, >>> + void *handle, void *buf, uint32_t count, uint64_t offset); >> >> Wrong signature, missing the uint32_t flags that the backend interface >> has, and that
2013 Aug 30
3
Type annotations for R function parameters.
Hello. One of my clients asked if it would be possible to have an IDE which could use type discovery for R functions to make flow-like construction of an R program. Something like a LabView graphical composition of processing elements. They called this type of program composition a "workflow". I looked at some of this programs, like: * Orange http://orange.biolab.si/ * RedR