similar to: yet another vectorization question

Displaying 20 results from an estimated 8000 matches similar to: "yet another vectorization question"

2005 Dec 15
1
millions of comparisons, speed wanted
Dear all, I have a 10 columns matrix which has 2^10=1024 unique rows, with values 0 and 1. What I would like to do is a little complicated; in a simple statement, for a subset (say 1000 rows) I want to perform pairwise comparisons between all rows, find out which rows differ by only one value, replace that value by "x", get rid of the comparisons that differ by more than one value
2004 May 27
4
extract columns using their names
Hello, Is there a way to extract multiple columns from a dataframe using their names instead of their numbers? Currently I use: data2 <- data1[, c(1,3,9)] And I am looking for something like data2 <- data1[, c("XX","YY","ZZ")] I use the same dataframe for many purposes, and I run codes that change the order of the columns every time. Many thanks, Adrian
2004 Jan 07
2
segments in 3d space
Hi all, Is it possible to draw line segments in a 3d space plot? I'm interested to draw the errors from an observed value to the regression plane, for a textbook example in an Intro Stats handbook for multiple regression. I used the scatterplot3d package to draw the regression plane. Many thanks, Adrian ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Adrian Dusa (adi@roda.ro) Romanian Social
2003 Dec 17
5
beginner programming question
Hi all, The last e-mails about beginners gave me the courage to post a question; from a beginner's perspective, there are a lot of questions that I'm tempted to ask. But I'm trying to find the answers either in the documentation, either in the about 15 free books I have, either in the help archives (I often found many similar questions posted in the past). Being an (still actual)
2003 May 28
2
missing values
Dear list members, I'm relatively new to this list; can anyone tell me how to declare missing values once a dataset has been attached? For example here: VAR1 1 1 2 2 3 1 4 3 5 2 6 1 7 3 8 3 9 1 10 2 11 98 12 2 13 97 14 99 15 NA 16 3 I would like values 97, 98 and 99 to be treated as missing values. I read
2005 Nov 19
5
help with apply, please
Dear list, I have a problem with a toy example: mtrx <- matrix(c(1,1,0,1,1,1,0,1,1,0,0,1), nrow=3) rownames(ma) <- letters[1:3] I would like to determine which is the minimum combination of rows that "covers" all columns with at least a 1. None of the rows covers all columns; all three rows clearly covers all columns, but there are simpler combinations (1st and the 3rd, or 2nd
2007 Nov 15
3
generate combination set
I have a set data={A,B,C,D,E,F,G} I want to choose 2 letter from 8 letters, i.e. generate the combination set for choose 2 letters from 8 letters. I want to get the liking: combination set={AB,AC,AD,....} Does anyone konw how to do in R. thanks, Aimin
2006 Jul 04
1
[Fwd: formatting using the write statement]
>I have a series of write statements because >i am writing to a file >where the characters strings are the column names of a dataframe >and the numbers are the elements in a particular row. >So, a file might look like > >AAA 2.1 >BB 3.1 >AHLZ 0.2 > >and it would be named "rowname".mls. > >so, each time i get to a new row, i create a new file and
2009 Nov 24
1
write to file append by column
Readers, Scenario: data x consists of one column; 1 2 3 data y; 4 5 6 Is it possible to write to file such that the file is: 1,4 2,5 3,6 using the write.file function? I have tried the command: write(x,file="file.csv",ncolumns=1,append=TRUE,sep=",") write(y,file="file.csv",ncolumns=1,append=TRUE,sep=",") but the result is: 1 2 3 4 5 6 yours,
2002 Apr 17
1
concat
i have a function that returns a list containing a variety of variable types i am trying to run the function multiple times and return the output into a variable with a semi-consistent naming pattern i.e., for ten trials i want to return the list into variables trial1,trial2,...trial10 is there a generic way to get this to happen i have a similar process that does the same thing to an external
2004 May 19
2
indexing question
Hi, I have a problem and a rather poor solution that I would like to improve. There a 2 datasets with different number of cases like this: Dataset 'poploc? Dataset 'siruta? Case no. SIRUTA TYPE Case no. SIRUTA TYPE 1 1017 0 1 1017 3 2 1026 0
2009 Apr 25
2
Extracting an object name?
Dear Sir or Madam: This is an extension to a earlier post, about looping through several thousand files, and testing student's models against a different data-set, called rclnow, for "recall now". The problem is, that the instructor never specified to the students, what they should name their "lm" object. So what they created was: "arbitrary variable name"
2007 Apr 10
1
R CMD Rdconv drops sections: arguments, seealso, examples (PR#9606)
I've created a .Rd file (below), then converted that to .sgml using R CMD Rdconv --type=Ssgm combn.Rd > combn.sgml The output (shown below) is missing some of the sections: arguments seealso examples If instead I convert to .d (below), the same sections are missing, and the "note" section is included but without the necessary newline.
2010 Mar 26
2
More efficient alternative to combn()?
Hi, i am working on a problem where i need to compute the products of all possible combinations of size m of the elements of a vector. I know that this can be achieved using the function combn(), e.g.: > vector <- 1:6 > combn(x = vector, m = 3, FUN = function(y) prod(y)) In my case the vector has 2000 elements and i need to compute the values specified above for m = 32. Using combn() i
2007 Apr 20
1
simply this loop?
Hi, anyone interested in this: I tried to simply this loop with lapply or something but haven't figured it out: mapt = c("203929_s_at", "203930_s_at", "203928_x_at", "206401_s_at") mapt.combn <- lapply(1:4, function(i) combn(mapt, i)) out = list() k = 1 for (i in 1:length(mapt.combn)){ for (j in 1:ncol(mapt.combn[[i]])){ out[[k]] =
2006 Jul 24
5
change the name of file
Dear R Users, Is it possible to make file names dependent on a changing variable? For instance. I generate random numbers in a loop and at each iteration I want data to write to file (I do not want to write everything in one file using 'append'): for (i in 1:50){ x<-matrix(runif(100, min=0,max=1),nrow=5,ncol=20) Write(t(x),file="Data_i.txt",ncolumns=5,sep="\t") }
2012 Nov 16
1
pairing data using combn with criteria
Dear All, I have a dataframe made up of individual beetles consisting of individual number, family number, mother's family number, father's family number, and sex of the beetle. I would like to pair up the individuals for breeding. I would, however, like to avoid breeding beetles of the same sex (obviously), the same family, and with the same mother's family or father's family,
2013 Sep 06
1
Importing function that is previously imported by other package
Dear developeRs, I encounter the following problem: in the current version of my package FrF2, certain calls to a functioni do not work when package combinat is loaded, because function combn from combinat masks the function from utils that my package uses. I tried to solve this issue by importing function combn into the namespace of FrF2; I don't need to export it, I just want to use it
2010 Nov 17
1
efficient conversion of matrix column rows to list elements
Hi List, I'm hoping to get opinions for enhancing the efficiency of the following code designed to take a vector of probabilities (outcomes) and calculate a union of the probability space. As part of the union calculation, combn() must be used, which returns a matrix, and the parallelized version of lapply() provided in the multicore package requires a list. I've found that
2006 Dec 18
2
write() gotcha
Hi I used write() the other day to save some results. It seems that write() does not record the full precision of the objects being written: > write(pi,file="~/f",ncolumns=1) > pi.saved <- scan("~/f") Read 1 item > dput(pi) 3.14159265358979 > dput(pi.saved) 3.141593 > pi-pi.saved [1] -3.464102e-07 > This difficulty was particularly difficult to