similar to: Subsetting a data frame

Displaying 20 results from an estimated 200 matches similar to: "Subsetting a data frame"

2011 Oct 05
2
Subsetting a data frame with multiple values and exclusions.
Hi all, I realise that the convention is to provide a working example of my problem but the data are of a sensitive nature so I'm not able to do that in this case. I need to query a database for multiple search terms: db <- structure(list(ind = c("ind1", "ind2", "ind3", "ind4"), test1 = c(1, 2, 1.3, 3), test2 = c(56L, 27L, 58L, 2L), test3 =
2011 Mar 10
2
within group sequential subtraction
Hi Everyone, I would like to do sequential subtractions within a group so that I know the time between separate observations for a group of individuals. My data: data <- structure(list(group = c("IND1", "IND1", "IND2", "IND2", "IND2", "IND3", "IND4", "IND5", "IND6", "IND6"), date_obs =
2009 Sep 11
2
Accumulating results from "for" loop in a list/array
Dear R users, I would like to accumulate objects generated from 'for' loop to a list or array. To illustrate the problem, arbitrary data set and script is shown below, x <- data.frame(a = c(rep("n",3),rep("y",2),rep("n",3),rep("y",2)), b = c(rep("y",2),rep("n",4),rep("y",3),"n"), c =
2011 Aug 10
2
choosing selective data with permutations
Hello, I am a R beginner and hoping to obtain some hints or suggestions about using permutations to sort a data set I have. Here is an example dataset: Ind1 11 00 12 15 28 Ind2 21 33 22 67 52 Ind3 22 45 21 22 56 Ind4 11 25 74 77 42 Ind5 41 32 67 45 22 This will be read into a variable using read.table. What I want to do is permute these individuals and every
2009 Aug 09
1
problem adding columns to matrix
Hi all, i purchased a copy of the book Morphometrics with R by Springer. at the end of each chapter there are exercises to train what you just read and (hope) learned... so i have this problem: Define a hypothetical data frame containing five measurments normally distributed(size,head,pectoral,area,weight) for four individuals (named ind1, ind2, etc). ADD A COLUMN corresponding to the
2011 Mar 09
2
Cleaning date columns
Hi Everyone, I have the following problem: data <- structure(list(prochi = c("IND1", "IND1", "IND1", "IND2", "IND2", "IND2", "IND2", "IND3", "IND4", "IND5"), date_admission = structure(c(6468, 6470, 7063, 9981, 9983, 14186, 14372, 5129, 9767, 11168), class = "Date")), .Names =
2008 Oct 29
1
Subsetting data in a loop
I need some help with sub-setting my data.  I am trying to divide a data frame into multiple data frames based on the year collected, and stored in a list with each new data frame labeled with "year X" where X is the year the data was collected.  When I run my current code I get nine error messages stating "In one_year[name] <- myear :  number of items to replace is not a
2011 Dec 04
2
frequency table?
Hello R-users, I've got a file with individuals as colums and the clusters where they occur in as rows. And I wanted a table which tells me how many times each individual occurs with another. I don't really know how such a table is called...it is not a frequency table....My eventual goal is to make Venn-diagrams from the occurence of my individuals. So I've this: cluster ind1 ind2
2011 Dec 04
1
similarity matrix
Hello R-users, I've got a file with individuals as colums and the clusters where they occur in as rows. And I wanted a similarity matrix which tells me how many times each individual occurs with another. My eventual goal is to make Venn-diagrams from the occurence of my individuals. So I've this: cluster ind1 ind2 ind3 etc. 1 0 1 2 2 3 0 1 3
2011 Dec 03
1
pivot table help
Hello R-users, I've got a huge table with about 20.00 rows and 50 columns. The table now has headers as Members1, Members2 etc. My data are 8 different individuals. And I've got a column with clusters. So each individual belongs to different clusters and can occurs multiple times within a cluster (that's the reason that there can be more than 8 members). I want a presence/ absence
2010 Jan 20
7
Data Manipulation
Dear All, I would like to to group the Ticker by Industry and create file names from the Industry Factor and export to a txt file. I have tried the folowing ind=finvizAllexETF$Industry ind is then "Aluminum" "Business Services" "Regional Airlines" ind2=gsub(" " ,"",ind) ind3 [1] "Aluminum"
2003 Jun 05
1
Logical vectors
Hi everybody, just a quick question that drives me crazy: Is it possible to "join" 2 logical vectors ? i.e. x<-4 ind <- 1:19200 pin <- c(0, rep(400, 48) * (1:48)) ind1<-((pin[j] + 1) <= ind) & (ind <= pin[j + 2]) ind2<-((pin[j+x] + 1) <= ind) & (ind <= pin[j+x + 2]) ind2 and ind1 give the right TRUE index #but I would like something like that
2011 Jan 20
2
Using a list as multidimensional indexer
Hello list. Another 'puzzle' for which I don't have a clean solution. Say I have a multidimensional object, e.g.: Mm<-matrix(1:6, nrow=2, dimnames=list(c("a","b"), c("g","h","i"))) And on the other hand I have a list Ind<-list("b","g") This holds, for each dimension, an indexer for that dimension. Now I would
2010 Oct 22
1
Reference classes
Dear all, First, many thanks to John Chambers, and anyone else who was involved, for the new support for "reference classes" in R 2.12.0. It's nice to see this kind of functionality appear in a relatively R-like form, and with the blessing of the core team. In some contexts it is undoubtedly appealing to associate a set of methods with a class directly, rather than defining a load
2010 Jan 17
3
enty-wise closest element
Dear R-users, i have a simple problem maybe, but i don't see the solution. i want to find the entry-wise closest element of an vector compared with another. ind1<-c(1,4,10) ind2<-c(3,5,11) for (i in length(ind2):1) { print(which.min(abs(ind1-ind2[i]))) } for ind2[3] it should be ind1[3] 10, for ind2[2] it should be ind1[2] 4 and for ind2[1] it should be ind1[1] 1. but with the
2009 Jul 09
1
Converting indices of a matrix subset
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I have two matrices: > m1 <- matrix(1,4,4) > m1 [,1] [,2] [,3] [,4] [1,] 1 1 1 1 [2,] 1 1 1 1 [3,] 1 1 1 1 [4,] 1 1 1 1 > m2 <- matrix(0,3,3) > diag(m2) <- 1 > m2 [,1] [,2] [,3] [1,] 1 0 0 [2,] 0 1 0 [3,] 0 0 1 I want to get indicies from m2
2010 May 03
3
how to rewrite this for loops in matrix form without loop
x0=rnorm(100) y0=rpois(100,3)+1 ind=as.data.frame(table(y0)) ind1=ind[,1] ind2=ind[,2] phi=NULL for (i in 1:length(ind2)){ phi[i]=sum(x0[y0==ind1[i]])/ind2[i] } [[alternative HTML version deleted]]
2009 Feb 13
0
lists on a script
Dear R experts, I have a problem with a function I wrote. The fuction looks like this: series<-function(x,s){ foo<-list(); ind3<-integer(); for (j in diff){ for (i in 1:(n-12)){ if (!(x[i,j]==0)&!(x[i+1,j]==0)&!(x[i+2,j]==0)&!(x[i+3,j]==0)&!(x[i+4,j]==0)&!(x[i+5,j]==0)&!(x[i+6,j]==0)
2017 Nov 18
0
Using cforest on a hierarchically structured dataset
Hi, I am facing a hierarchically structured dataset, and I am not sure of the right way to analyses it with cforest, if their is one. - - BACKGROUND & PROBLEM We are analyzing the behavior of some social birds facing different temperature conditions. The behaviors of the birds were recorder during many sessions of 2 hours. Conditional RF (cforest) are quite useful for this analysis
2005 Jul 25
0
lda: scaling to 'disctiminant function'
Friends Briefly... In the documentation for lda in MASS it describes the value 'scaling' as 'a matrix which transforms observations into discriminint functions...'. How? Verbosely... I have a matrix of data. 9 independent variables and describing 3-classes. About 100 observations in total. A 10x100 matrix of data. I am trying to generate two discriminant functions and i