similar to: how to randomly eliminate half the entries in a vector?

Displaying 20 results from an estimated 700 matches similar to: "how to randomly eliminate half the entries in a vector?"

2010 Mar 11
2
Comparing matrices
Hello all, I have two matrices, pop and pop2, each the same number of rows and columns that I want to compare for equality. I am concerned about efficiency in this operation. I've tried a few things without success so far. Doing something simple like: if (pop==pop2) { cat('equal') } else { cat('NOT equal') } results in the warning: 1: In if (pop == pop2) { : the
2009 Apr 26
3
3 questions regarding matrix copy/shuffle/compares
Hello all, I have the following function call to create a matrix of POP_SIZE rows and fill it with bit strings of size LEN: pop=create_pop_2(POP_SIZE, LEN) I have 3 questions: (1) If I did keep_pop[1:POP_SIZE] == pop[1:POP_SIZE] to keep a copy of the original data structure before manipulating 'pop' potentially, would this make a deep copy or just shallow? Ie
2019 Dec 04
3
How do I set all my mailboxes to "subscribed"
Hi all, I've had a great deal of trouble accessing my Dovecot IMAP from most supposedly IMAP aware email clients, and have been advised that it might be because some of my email folders are not subscribed. Is there s way I can subscribe all my folders? I see no reason to have a folder not subscribed. Thanks, SteveT Steve Litt December 2019 featured book: Rapid Learning for the 21st
2009 Aug 28
6
Google's R Style Guide
Perhaps most of you have already seen this? http://google-styleguide.googlecode.com/svn/trunk/google-r-style.html Comments/Critiques? Thanks, Esmail ps: Reminds me of PEP 8 for Python http://www.python.org/dev/peps/pep-0008/ Maybe not that surprising since Python is also one of the main languages used by Google.
2009 Apr 19
3
flip certain bits in vector
I have a string of binary values, and I would like to flip certain bits in a set of positions. Let's say the vector p contains position [1, 3, 5, 7] vector b contains bits [1, 0, 1, 0, 1, 0, 1, 0, 1, 0] result r should be [0, 1, 0, 0, 0, 0, 0, 0, 1, 0] in pseudo code this would be something like --- r = c() for (i in 1:10) if (i in p) r = c(r, flip[i]) r ----
2008 Jun 12
3
Adding new columns to (output) data - e.g., read 5 cols write 8
Hello, I have the following task I'd like to accomplish: A file contains 5 columns of data (several hundred rows), let's call them a, b, c, d and e (ie these are their column headers) I also have a set of definitions, e.g., f = a + b g = a * 3 h = c + d etc. I would like to write out a new .rda file that contains columns a b c d e f g h etc. I.e. , the original data plus new columns
2008 May 09
2
which.max2()
Hello, which.max() only returns one index value, the one for the maximum value. If I want the two index values for the two largest values, is this a decent solution, or is there a nicer/better R'ish way? max2 <-function(v) { m=which.max(v) v[m] = -v[m] m2=which.max(v) result=c(m, m2) result } Seems to work ok. Thanks, Esmail
2009 Apr 26
4
comparing matrices
I'm trying to compare two matrices made up of bits. doing a simple comparison of matA == matB yields this sort of output. [,1] [,2] [,3] [,4] [,5] [,6] [1,] FALSE TRUE FALSE TRUE TRUE FALSE [2,] TRUE TRUE TRUE TRUE TRUE TRUE [3,] FALSE TRUE FALSE FALSE FALSE TRUE [4,] FALSE TRUE TRUE FALSE FALSE FALSE [5,] TRUE TRUE TRUE TRUE FALSE FALSE [6,] TRUE TRUE
2008 May 07
1
Automatically generating new column names (and columns)
Once again I need to tap into the collective knowledge here. Let's say I have the following columns and data below Y X1 X2 X3 X4 I would like to generate additional new columns and column names (ie the data would be squared - and I'd like the column names to reflect this) like: Y X1 X2 X3 X4 X1^2 X2^2 X3^2 X4^2 I believe I can compute the values correctly with the code below, but I
2010 Feb 24
2
sprintf + integer(0) problem
Hello all, I am stuck with R v2.8.0 under Linux for the time being and I am running into a small problem that doesn't exist under 2.9.x and 2.10.x with sprintf. If I have the following code segment to help me determine the column number for a specific column header/label: nn = names(Dataset) s = "Group" c = which(nn==s) cat(sprintf('found %s in col %d\n', s, c))
2001 Jan 14
2
Help
Dear sir, I am using R in windows. I want to extend R Memory size. I use the following command, but unfortunately it doesn't work. -- vsize=15M --nsize=1000K Your help is appreciated. Thanks, Esmail Amiri. __________________________________________________ Do You Yahoo!? Get email at your own domain with Yahoo! Mail. http://personal.mail.yahoo.com/
2008 May 06
2
building a formula string bit by bit ..
Hello, Still a newbie with R, though I have learned a lot from reading this list. I'm hoping someone can help with this question: I have two vectors, one for variables, and one for bits. I want to build a string (really a formula) based on the values in my vector of 1s and 0s in bits. If I have a one, I want to include the corresponding entry in the vars vector, otherwise ignore it. Of
2010 Feb 15
1
argh .. if/else .. why?
Hello, would someone please help explain the following inconsistency in the if/else statement to me? The format of the if/else #3 below is ok, but if/else #1 is not? (I get an "unexpected else" type error.) In order for it to work I have to use if/else #2 Thanks .. maybe there is some reason for this, but this looks very inconsistent to me. R version 2.10.1 (2009-12-14) Ubuntu 9.04
2008 Jun 11
3
searching for specific row in matrix
Hi, I have matrix of bits and a target vector. Is there an efficient way to search the rows of the matrix for the target? I am interested in the first row index where target is found. Example: > source("lookup.R") [,1] [,2] [,3] [,4] [,5] [1,] 1 0 1 1 0 [2,] 1 1 0 1 0 [3,] 0 0 1 0 0 [4,] 1 0 0 1 1 [5,]
2009 May 23
1
optimizing function over x,y
Hello all, I would like to maximize or minimize a given math function over a specific set of values. I was checking out Wolfram Alpha (http://www70.wolframalpha.com/) and it can do simple optimization problems in math, such as maximize 15*x - x**2 over 0 to 15 (http://www70.wolframalpha.com/input/?i=maximize+15*x+-+x**2+over+0+to+15) which finds the maximum value and input for x in
2009 Apr 27
3
Formatting numbers
I've been trough the R documentation for about half an hour and it's not clear to me how to do this: I need to format to character a series of integers from 1 to 1000, and I like them to look like "0001" "0002", "0059", "0123" and so on. Padded with zeroes to have four digits. Cheers! Mario. r-help-request at r-project.org wrote: > Send
2010 Apr 08
1
formatting a result table (number of digits)
Hello, Is there an easy way to format the output of a result table that R generates from a regression? I like the table, but would like to limit the number of decimal points in the entries if possible. For instance I would like only 3 digits of precision for the Value, Std.Error. (And if it would be easy to get rid of scientific notation, that would be good to know too). So ideally keep the
2008 Apr 20
1
representing binary data for Genetic Algorithm in R
Hello all, I am trying to implement a simple Genetic Algorithm. I am doing this in R since I want access to the statistical functions (eg lm) it provides. I'm not new to programming, or GAs, but I am totally new to R (the package and the language), and I am hoping someone could help with these questions: 1. I am going to use a binary representation, it seems that vectors of Factors would
2006 Sep 05
2
User Group SID behavior has changed from 21b to 23c
I am using LDAP as my backend. I have 6 PDC's running Samba 3.0.21b, each domain has a different SID. I store all user,groups,and machine accounts in one LDAP database. So that when I create a user once, all domains can see the user. This keeps me from having to create a user account on each domain for cross domain file sharing. The behavior for Domains running Samba 3.0.21b is a follows.
2008 May 27
1
hash or other quick lookup function?
Hello all, I have a matrix of bit values. I compute certain values based on the bits in each row. There may be *duplicate* entries in the matrix, ie several rows may be identical. These rows change over time, and identical entries may not be next to each other. Computing these values is time consuming, so I would like a way to store a value once it's computed. That way I would be able to