similar to: Extract rows from data frame based on row names from another data frame

Displaying 20 results from an estimated 20000 matches similar to: "Extract rows from data frame based on row names from another data frame"

2007 Oct 29
3
using survfit
hie when i use plot.survfit to plot more than one graph why I only see the last graph how do i see the other graphs.for example n=20 n1=n/2 n2=n/4 a11=4;a12=4 ;a21=4 ;a22=4 t1<-array(1,c(n1)) t2<-array(2,c(n1)) treatgrp=matrix(c(t1,t2))
2009 Aug 20
2
How to extract row values?
Dear All! I'm trying to extract one specific row from a data frame without columnnames being included. I only want a 1-dimensional vector that consists of the specific data on this row. Here's an example: existing data: column names: v1v2v3 Row 1 ab cd ef Row 2 gh ij kl Row 3 mn op qr This is what I want to extract: ab cd ef I do not want: v1v2v3
2009 Jul 09
9
Population pyramids
Hi, I hope somebody can help me with this issue: I am doing population pyramids using the barplot command, so in the left side I have male age structure and in the right side the female age structure. To plot the male age structure I put the data in negative numbers. Now, I want to change the sign in the bar plot in such way that I have no-sign numbers, both in left and right side of the graph. I
2008 Nov 10
2
how to convert indvidual pairwise distances to matrix
Hello, I am trying to convert list of pairwise distances to a distance matrix for spatial analysis (kriging). For instance, I have something like this for each pair pf points, and I want to convert it to a matrix: point1 point2 distance 1 1 0 1 2 4 2 2 0 2 1 4 Please let me know if there is a
2009 Jul 24
4
CI wiskers
I have a matrix containing means and CIs (lower and upper in two columns, so three columns for every data point) for several points. I have to build a graph of these means accompained by the CIs (as wiskers). No problems with making the graph of means, but I don't know how to introduce CIs. Can anybody advise? -- View this message in context:
2008 Jun 17
4
PCA analysis
Hi, I have a problem with making PCA plots that are readable. I would like to set different sympols instead of the numbers of my samples or their names, that I get plotted (xlabs). How is this possible? With points, i don´t seem to get the right data plotted onto the PCA plot, as I do not quite understand from where it is taken. I dont know how to plot the correct columns of the prcomp
2008 Feb 27
4
Error in cor.default(x1, x2) : missing observations in cov/cor
Hello, I'm trying to do cor(x1,x2) and I get the following error: Error in cor.default(x1, x2) : missing observations in cov/cor A few things: 1. I've used cor() many times and have never encountered this error. 2. length(x1) = length(x2) 3. is.numeric(x1) = is.numeric(x2) = TRUE 4. which(is.na(x1)) = which(is.na(x2)) = integer(0) {the same goes for is.nan()} 5. I also try
2008 Nov 20
1
sub / gsub - extracting between identical symbols
Hi, I am trying to extract some numbers from a text string. The problem is that the delimiting symbols are identical so that I do not know how to tell "sub" between which of them to extract. The string looks like this 12/01/03/08 The extracted variables should look like: x1=12 x2=01 x3=03 x4=08 If anybody could help or point me to useful help, I would be greatful. Cheers, Daniel
2009 Aug 12
1
to extract a section of the matrix
HI, i have this matrix and i want to extract  a section of the matrix which present the first and second value of optim position:    OptimYear            LRPhase                                  PriorLRPosition                 OptimPosition            LRPosition   5      2009                      1                                         1.15641679414676       0.33037984561357            1 6     
2009 Jul 22
1
How do I delete a row from a data frame when varA == "TRUE"
I want to delete a row from a data frame XYZ where A == "TRUE". Let's assume there are five variables in this data frame XYZ. My deletion is based on the TRUE vs. FALSE value under variable A. How do I do this? Thanks! My current code: for (i in 1:length(XYZ$A)) if (XYZ$A == "FALSE") XYZ<-XYZ else XYZ<- XYZ[-i,] Error message is: Error in if (XYZ$A ==
2009 Sep 20
3
statistics
The myoglobin sequence, with reference number NM_005368 in Gen bank, has the following frequencies of DNA nucleotides: A C G T 237 278 309 242 Do these data provide sufficient evidence, at the 1% level of significance, that the DNA nucleotides have an unequal distribution, that is the DNA nucleotides are not evenly utilised? Clearly state your hypothesis, test statistic and conclusion.
2008 Feb 26
3
OLS standard errors
Hi, the standard errors of the coefficients in two regressions that I computed by hand and using lm() differ by about 1%. Can somebody help me to identify the source of this difference? The coefficient estimates are the same, but the standard errors differ. ####Simulate data happiness=0 income=0 gender=(rep(c(0,1,1,0),25)) for(i in 1:100){ happiness[i]=1000+i+rnorm(1,0,40)
2010 Apr 08
2
Problem using elements in a vector
Hi So my particular problem is this: I have a row vector of length 5200 elements - specifically created by x<-rbinom(5200,1,0.5) y<-matrix(x,nrow=1,ncol=5200) y now, each element is either a 0 or a 1 - e.g. it could be (0,1,1,1,1,0,0,0,1,1,1) e.t.c. when the element is a 1, i need to multiply a number (say 1000) by 1.005, and if it is 1 again, multiply it _again_ by 1.005. so for
2009 Nov 11
3
how to use # in a rd doc in url address
I am writing a rd doc, and need to use "#" in a url adress. This would make: \url{http://www.xxxx.org/myfolder/#myanchor} Of course, I suppose this will not work because # is a special character starting a comment line in the rd dialect. I did not found a similar example in "Writing R exentions". I am not sure bout using \dQuote{a quotation}), and use \sQuote and \dQuote
2017 Jun 23
0
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
Hello, The obvious way would be to preallocate the resulting data.frame, to expand an empty one on each iteration being a time expensive operation. n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2))) D4 <- data.frame(distance=integer(n),difference=integer(n)) k <- 0 for (i in 1:nrow(D1)){ for (j in 1:nrow(D2)) { k <- k + 1 D4[k, ] <-
2017 Jun 23
4
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
For certain reason, the content was not visible in the last mail, so posting it again. Dear Members, I have two different dataframes with a different number of rows. I need to apply a set of functions to each possible combination of rows with one row coming from 1st dataframe and other from 2nd dataframe. Though I am able to perform this task using for loops, I feel that there must be a more
2008 Mar 31
2
Finding a mean value of a variable holding a dummy variable fixed
I have time-series data on approval ratings of British Prime Ministers. The prime ministers dating from MacMillan onward till today are coded as dummy variables and the approval ratings are entered for each month. I want to know the mean value of the approval rating of each Prime Minister in the dataset and the approval rating during his/her first month and last month as PM. What R code should
2017 Jun 23
1
R version 3.3.2, Windows 10: Applying a function to each possible pair of rows from two different data-frames
Hello, Another way would be n <- nrow(expand.grid(1:nrow(D1), 1:nrow(D2))) D5 <- data.frame(distance=integer(n),difference=integer(n)) D5[] <- do.call(rbind, lapply(seq_len(nrow(D1)), function(i) t(sapply(seq_len(nrow(D2)), function(j){ c(distance=sqrt(sum((D1[i,1:2]-D2[j,1:2])^2)),difference=(D1[i,3]-D2[j,3])^2) } )))) identical(D3, D5) In my first answer I forgot to say that
2009 Feb 27
5
Filtering a dataset's columns by another dataset's column names
Hello all, I hope some of you can come to my rescue, yet again. I have two genetic datasets, and I want one of the datasets to have only the columns that are in common with the other dataset. Here is a toy example (my real datasets have hundreds of columns): Dataset 1: Individual SNP1 SNP2 SNP3 SNP4 SNP5 1 A G T C A 2 T C A G T 3 A C T
2011 Apr 21
1
Help with matching rows
Dear Sir, Please excuse my akwardness as I a new to R and computers, but would kindly appreciate help. { a <- sample (1:10,100,replace=T ) b <-sample(10:20,100,replace=T) c <- sample(20:30,100,replace=T) d <- sample(30:40,100,replace=T) e <- sample(40:50,100,replace=T) } d1 <- a d2 <- b d3 <-c d4 <- d d5 <- e data.frame(d1,d2,d3,d4,d5) dd <-