similar to: how to apply sample function to each row of a data frame?

Displaying 20 results from an estimated 10000 matches similar to: "how to apply sample function to each row of a data frame?"

2011 Jan 18
3
error message
I was running a sampling syntax based on a data frame (ago) of 160 rows and 25 columns. Below are the column names: > names(ago) [1] "SubID" "AGR1" "AGR2" "AGR3" "AGR4" "AGR5" "AGR6" "AGR7" "AGR8" [10] "AGR9" "AGR10" "WAGR1" "WAGR2"
2010 Sep 27
1
compare two matrices
Hi everyone: I have a kinda easy question but i do not know how to solve that in a simple way. I want to compare the rows of two matrices. col1 <- c(1,2,3,4,5,6) col2 <- c(6,5,4,3,2,1) m <- cbind(col1, col2) col3 <- c(1,3,2,6) col4 <- c(6,3,5,1) n <- cbind(col3, col4) In matrix n, for example the first row is (1,6), it is also some row
2010 Nov 15
5
Sampling problem
Hey, I am hoping someone can help me with a sampling question. I have a data frame of 8 variables (the first column is the subjects' id): SubID CSE1 CSE2 CSE3 CSE4 WSE1 WSE2 WSE3 WSE4 1 6 5 6 2 6 2 2 4 2 6 4 7 2 6 6 2 3 3 5 5 5 5 5 5
2011 Oct 10
1
Linear programming problem, RGPLK - "no feasible solution".
In my post at https://stat.ethz.ch/pipermail/r-help/2011-October/292019.html I included an undefined term "ej". The problem code should be as follows. It seems like a simple linear programming problem, but for some reason my code is not finding the solution. obj <- c(rep(0,3),1) col1 <-c(1,0,0,1,0,0,1,-2.330078923,0) col2 <-c(0,1,0,0,1,0,1,-2.057855981,0) col3
2000 May 31
3
read.table and strip.white
Hi! I want to read data (using read.table(.)) from a file like: "col1", "col2", "col3" 1, 1, 1 2, 2, 2 But the white spaces are interpreted: x <- read.table("filename", header=TRUE, sep=",") ## or read.csv(...) colnames(x) [1] "col1" " col2" " col3" ^ ^ So I would like to pass
2012 Dec 08
5
How to efficiently compare each row in a matrix with each row in another matrix?
Dear expeRts, I have two matrices A and B. They have the same number of columns but possibly different number of rows. I would like to compare each row of A with each row of B and check whether all entries in a row of A are less than or equal to all entries in a row of B. Here is a minimal working example: A <- rbind(matrix(1:4, ncol=2, byrow=TRUE), c(6, 2)) # (3, 2) matrix B <-
2009 Nov 18
1
row-wise means
I have a dataframe with 3 columns. The first column stores an index. I would like to calculate the mean of the numbers stored in each of the rest of the columns. So, here is my data matrix: col1 col2 col3 1 23 34 2 45 56 3 23 56 4 34 68 For each row I would like to calculate the means of the numbers stored in col2 and col3. How can this be done in R? TIA, Anjan -- =============================
2010 Oct 11
2
Split rows depending on time frame
Hi, I have the following data frame, where col2 is a startdate and col3 an enddate COL1 COL2 COL3 A 40462 40482 B 40462 40478 The above timeframe of 3 weeks I would like to splits it in weeks like this COL1 COL2 COL3 COL4 A 40462 40468 1 A 40469 40475 1 A 40476 40482 1 B
2005 May 02
4
"apply" question
Dear R users, I??ve got a simple question but somehow I can??t find the solution: I have a data frame with columns 1-5 containing one set of integer values, and columns 6-10 containing another set of integer values. Columns 6-10 contain NA??s at some places. I now want to calculate (1) the number of values in each row of columns 6-10 that were NA??s (2) the sum of all values on columns 1-5
2011 Jan 11
1
how to sort new data frame based on the original data frame
I have a really simple question I have a data frame of 8 variables (the first column is the subjects' id): SubID G1 G2 G3 G4 W1 W2 W3 W4 1 6 5 6 2 6 2 2 4 2 6 4 7 2 6 6 2 3 3 5 5 5 5 5 5 4 5
2008 Jun 24
1
Equivalent of Mathematica's Apply
Hello, Is there some equivalent function in R of Mathematica's "Apply" i.e. Apply[ f, g[a,b]] ==> f[a,b] In concret, I have a matrix of indexes: > ind = cbind(1:5, 1:5+5) > ind [,1] [,2] [1,] 1 6 [2,] 2 7 [3,] 3 8 [4,] 4 9 [5,] 5 10 and I'd like to extract sequences 1:6, 2:7, 3:8, ..., 5:10 from a vector x. What would be the
2010 Aug 06
1
apply family functions
Hi all, I would like to flag each record in the data according to certain conditions as specified below. For example, If "Close_date" in *dat* is between ("Open" & "Close") or ("Open1" & "Close1") or ("Open2" & "Close2") in *oc, *flag the records as "Valid", otherwise "Invalid" I would like to
2010 May 14
1
Replacing double loop by apply
Dear R-users, after trying and searching a long time i have the following question. is it possible to replace to following double loop by some apply calls? ####################################################################### m1 <- data.frame(v1=factor(letters[1:5]), v2=factor(letters[2:6]), v3=factor(letters[3:7])) m2 <-
2002 May 20
1
how does one apply Western Electric / AT&T rules to R plots?
I have searched for info on how to apply the Western Electric rules for process control, to data and plots I have in R, but I have not been able to learn how. Any help would be greatly appreciated. Thank you, sjcrauhut at agere.com 05/20/02 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read
2009 Dec 20
2
Remove rows in a matrix that match rows in another matrix
Dear R Community, The following seems like a simple problem, but I''ve been stuck on it for some time, with no luck using matching or subsetting functions. I''m trying to remove the rows from a large matrix that match rows in another large matrix. A (small scale) example: col1<-c("A", "B", "C", "D") col2<-c("A",
2009 Dec 25
2
[ how can sample from f(x)~x^(a-1)
Hello all how can sample from f(x)~x^(a-1)*ind(0,min(b,-log(u)) in R? where a and b is positive constand and 0<u<1 thanks khazaei
2008 Feb 07
1
How do you refer to the row above in a data frame ?
You have a two-dimensional data frame. Columns is easy, say col4 <- col3 - col2 How do you do row3 <- row2 +1 for example. -- View this message in context: http://www.nabble.com/How-do-you-refer-to-the-row-above-in-a-data-frame---tp15336933p15336933.html Sent from the R help mailing list archive at Nabble.com.
2012 Nov 04
1
sample equal number of cases per class
Dear community I have a dataframe and want to split it into a learn and a test partition. However the learnset should be balanced, i.e. each class should have the same number of cases. I tried and searched a lot, without success so far. Maybe you can help? Some example code *# generate example data df <- data.frame(class = as.factor(sample(1:3, 20, replace = T)), var1 = rnorm(20,3), var2 =
2009 Jan 20
1
two-sample test of multinomial proportion
Hi all, This is perhaps more a statistics question than an R question, but I hope it's OK anyhow. I have some data (see below) with the number of tests positive to subtype H1 of a virus, the number of tests postive to subtype H3, and the total number of tests. This is for two different groups, and the two subtypes are mutually exclusive. What is the best way to test if the proportion of H1
2011 Sep 14
1
how to get a row with its its p value below 0.01 ??
Hi all, I'm analyzing micro array data.. it has produced a file (to be specific matrix) withdimension of 35556 2. first few lines of the matrix are as below.. probe_name control.fdr.pvals.present 10338001 0.000440001 10338002 0.000583093 10338003 0.000528449 10338004 0.000610362 10338005 0.000151825 10338006 0.0001733 10338007 0.000152924 Now, i want only rows whose