similar to: Sample rows in data frame by subsets

Displaying 20 results from an estimated 7000 matches similar to: "Sample rows in data frame by subsets"

2005 Dec 06
2
Constructing a transition matrix
Hi, I would like to construct a transition matrix from a data frame with annual transitions of marked plants. plant<-c(1:6) class<-c("seed","seed", "seed", "veg", "rep", "rep") fate<-c("dead", "veg","veg","rep", "rep", "veg") trans<-data.frame(plant, class, fate)
2007 Sep 25
2
3d barplot in rgl
Is there anyway to plot a matrix using a 3d bar plot. Something like bar3 in matlab? The example in demo hist3d does a 3d barplot for binned data, but has anyone tried something for a simple matrix with spaces betwen bars and axis labels using matrix dimnames or 1,2,3? stages<-letters[1:3] A<-matrix(c( 0.21, 0.21,0.03, 0.55, 0.58, 0.09, 1.30, 1.35, 0.22), nrow=3, byrow=TRUE,
2007 Feb 06
2
abbreviate dataframe for Sweave output
I wanted to print the first and last rows of some dataframes in Sweave using dots in columns to separate the two parts. Head and tail almost work, but I have problems with factors and row names. z<-data.frame(id=letters[1:26], x=sample(1:26,26)) rbind(head(z,3), ".", tail(z,1)) id x 1 a 18 2 b 8 3 c 14 4 <NA> . 26 z 10 Warning message: invalid
2007 Nov 14
1
reading tables from url
I'm trying to read some web tables directly into R. These are both genome sequencing projects (eukaryotes and metagenomes) from NCBI and look very similar; however, only the first one works. http://www.ncbi.nlm.nih.gov/genomes/leuks.cgi http://www.ncbi.nlm.nih.gov/genomes/lenvs.cgi I added ?dump=selected to the end of the url string to get a tab- delimited file (which is what happens
2006 Jun 18
2
analyze amino acid sequence (composition)of proteins
Dear R-helpers: thank your for your attention. i am a newer to R and i am doing some protein category classification based on the amino acid sequence.while i have some questions urgently. 1. any packages for analysis amino acid sequence 2. given two sequences "AAA" and "BBB",how can i combine them into "AAABBB" 3. based on "AAABBB",how can i get some
2013 May 07
4
create unique ID for each group
Hey All, I have a dataset(dat1) like this: ObsNumber ID Weight 1 0001 12 2 0001 13 3 0001 14 4 0002 16 5 0002 17 And another dataset(dat2) like this: ID Height 0001 3.2 0001 2.6 0001
2006 Jan 23
8
In which application areas is R used?
If anyone has a list of application areas where there is extensive use of R, I'd like to hear of it. My current short list is: Bioinformatics Epidemiology Geophysics Agriculture and crop science John Maindonald Mathematical Sciences Institute, Australian National University. john.maindonald at anu.edu.au
2000 Jun 28
1
F-secure -> Openssh Compatibility (fwd)
Date: Tue, 27 Jun 2000 16:09:43 -0600 (MDT) From: "W. Scott Wilburn" <wilburn at lanl.gov> To: ssh at clinet.fi Subject: F-secure -> Openssh Compatibility We have Macintoshes running Fsecure SSH client 1.0.1 which are unable to connect to a server running Openssh 2.1.1 on Red Hat 6.2. I believe that the problem is a bug with Fsecure, since a 30-day trial version of 1.0.2 works
2003 Sep 03
2
lme in R and Splus
Good Day, Included below is some code to generate data and to fit a mixed effects model to this fake data. The code works as expected when I call the function "lme" in Splus but not in R. The error message from calling lme in R is: "Error in getGroups.data.frame(dataMix, groups) : Invalid formula for groups" I installed the nlme package for R around 20 August
2006 Sep 27
1
Impossible to merge with a zero rows data frame?
I'm trying to merge two data frames. One of them is a zero rows data frame. I'm using the merge parameter 'all.x = TRUE' so I'd expect to obtain all the rows of x. In fact the merge help says: all.x: logical; if 'TRUE', then extra rows will be added to the output, one for each row in 'x' that has no matching row in 'y'. These rows
2013 Dec 14
2
Change factor levels
Suppose I have a dataframe 'd' defined as L3 <- LETTERS[1:3] d0 <- data.frame(cbind(x = 1, y = 1:10), fac = sample(L3, 10, replace = TRUE)) (d <- d0[d0$fac %in% c('A', 'B'),]) x y fac 2 1 2 B 3 1 3 A 4 1 4 A 5 1 5 A 6 1 6 B 8 1 8 A Even though factor 'fac' in 'd' only has 2 levels, but it seems to bear the birthmark
1999 Nov 29
2
Food for thought regarding PAM
I'm new to this list, so please forgive me if this has been discussed before. It appears that one of the (commendable) design goals of OpenSSH is to re-use existing open-source libraries wherever possible in order to simplify the OpenSSH code and hopefully improve security in the process. As exhibited by the current, non-open SSH, supporting all of the nuances of authentication and logins
2011 Mar 27
1
run function on subsets of matrix
I was wondering if it is possible to do the following in a smarter way. I want get the mean value across the columns of a matrix, but I want to do this on subrows of the matrix, given by some vector(same length as the the number of rows). Something like nObs<- 6 nDim <- 4 m <- matrix(rnorm(nObs*nDim),ncol=nDim) fac<-sample(1:(nObs/2),nObs,rep=T) ##loop trough different
2005 Jun 10
4
data.frame to character
Hi, Excuse me for this simple question. How to convert as.data.frame to as.character? ?data.frame > L3 <- LETTERS[1:3] > L10 <- LETTERS[1:10] > d <- data.frame(cbind(x=c("XYZ"), y=L10), fac=sample(L3, 10, repl=TRUE)) > d x y fac 1 XYZ A A 2 XYZ B A 3 XYZ C A 4 XYZ D A 5 XYZ E B 6 XYZ F C 7 XYZ G A 8 XYZ H C 9 XYZ I B 10 XYZ
2002 Feb 13
3
xtabs
Hi, In Splus if I call the function crosstabs() the output is a contigency table; in each cell of the table is printed: N, N/RowTotal, N/ColTotal, N/Total. N is the number of observations in each cell. The same call to xtabs() in R will produce the contigency table but the only entry in each cell is N. How can I get the same relative frequencies that crosstabs() gives? Thanks, mike --
2009 Jan 06
2
Converting data frame to symmetric matrix
Dear Sir or Madam, I have the following data frame (which is just a toy example of my larger dataset) L3 <- LETTERS[1:3] x=c(1,1,2,2,3,3,4,4,5,5) y=1:10 d <- data.frame(cbind(x,y), fac=sample(L3, 10, replace=TRUE)) This data frame produces the following output x y fac 1 1 1 C 2 1 2 C 3 2 3 B 4 2 4 B 5 3 5 C 6 3 6 B 7 4 7 B 8 4 8 C 9 5 9 B 10 5
2006 Apr 06
3
convert a data frame to matrix - changed column name
I have a question, which very easy to solve, but I can't find a solution. I want to convert a data frame to matrix. Here my toy example: > L3 <- c(1:3) > L10 <- c(1:6) > d <- data.frame(cbind(x=c(10,20), y=L10), fac=sample(L3, + 6, repl=TRUE)) > d x y fac 1 10 1 1 2 20 2 1 3 10 3 1 4 20 4 3 5 10 5 2 6 20 6 2 > is.data.frame(d) [1] TRUE > sapply(d,
2012 Jun 07
3
conditional statement to replace values in dataframe with NA
Hello and thanks for helping. #some data L3 <- LETTERS[1:3] dat1 <- data.frame(cbind(x=1, y=rep(1:3,2), fac=sample(L3, 6, replace=TRUE))) #When x==1 and y==1 I want to replace the 1 values with NA #I can select the rows I want: dat2<-subset(dat1,x==1 & y==1) #replace the 1 with NA dat2$x<-rep(NA,nrow(dat2) dat2$y<-rep(NA,nrow(dat2) #select the other rows and rbind
2009 Jul 31
2
how use the subset?
hi ,everyone I want subtract some dataset by subset. >From the help running help(subset), ths information is "*subset(airquality, Day == 1, select = -Temp)* " while I running my script written as "*g1data<-subset(errdata, fac>12) *" ,it is wrong with the error information "*subset.default(newerrdata, fac>12),can not find fac*" and g1 in read
2008 Apr 22
3
how to read in multiple files with unequal number of columns
Dear all, I want to read in 1000 files which contain varying number of columns. For example: file[1] contains 8 columns (mixture of characters and numbers) file[2] contains 16 columns etc I'm reading everything into one big data frame and when I try rbind, R returns an error of "Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match" Below is my