similar to: indexing data.frame columns

Displaying 20 results from an estimated 50000 matches similar to: "indexing data.frame columns"

2009 Sep 03
5
abind, but on lists?
I'm trying to massage some data from Matlab into R. The matlab file has a "struct array" which when imported into R using the R.matlab package, becomes an R list with 3+ dimensions, the first of which corresponds to the structure fields, with corresponding row names, and the second and third+ dimensions correspond to the dimensions of the original struct array (as matlab
2011 Jun 29
2
Indexing to Insert values from a dataframe into a matrix
Hello, I think this is a simple problem but I am not coming up with a simple solution. I think it just an indexing problem. I can easily replace values in a matrix from a dataframe when the dataframe has row and column numbers. In the example below I use row and column names and I can not get it to work #make a matrix where rows and columns are the lat and long for a bounding box of Australia
2010 Feb 17
3
Extending data frame with longer columns
Hi, I am a beginner in R and have only read a few chapters in the R book, I was not able to find a solution for this simple problem. I have an empty data frame: a=data.frame(name="test") which I would like to extend in a for-loop (with data extracted from a database). Ideally I would like to extend the data frame like this: a["new_1"] = 1:10 a["new_1"] = 1:12
2011 Oct 22
2
Expanding rows of a data frame into multiple rows
The setup: I have a data frame where one column is in list mode, and each entry contains a vector of varying length. I want to expand this into a data frame with one row for each member of the list-mode column (the other values being replicated) For example, an example input and the desired output would be: input <- data.frame(site = 1:6, sector =
2008 Apr 28
3
data.frame indexing
Dear R Community, A simple problem (for some of you): I wish to index a data.frame by all elements NOT in my index E.g.: > a<-as.data.frame(matrix(rnorm(100),nrow=10,ncol=10)) > b<-which(a$V1>0.8) > b [1] 1 4 6 10 > a_indexb<-a[b,] > a_notIndexB<-a[!b,] > nrow(a_notIndexB) [1] 0 Indexing a on b is not a problem (a_indexb), but how can do get only the
2011 Apr 30
3
indexing into a data.frame using another data.frame that also contains values for replacement
Hello all, I have a quandry I have been scratching my head about for a while. I've searched the manual and the web and have not been able to find an acceptable result, so I am hoping for some help. I have two data frames and I want to index into the first using the second, and replace the specific values I have indexed with more values from the second data.frame. I can do this
2005 Oct 18
2
Inconsistency with matrix indexing (PR#8214)
Full_Name: Stefan Albrecht Version: 2.2.0 OS: Windows XP Submission from: (NULL) (194.127.2.74) Dear all, in the new R 2.2.0, the matrix indexing has been changed. In my opinion, this leads to an inconsistency when indexing one-row matrices. Take > (mat <- matrix(1:9, nrow = 3, dimnames = list(paste("r", 1:3, sep = ""), paste("c", 1:3, sep = ""))))
2010 Jun 14
1
avoid row/column indexing in capture.output
Hi everyone, This might be a very petty thing but Its not working for me. I want to export an output to a txt file but without indexing. Here is what I have tried to do outfile<- function(Time, var.names, output) { var.names = c(names(para)) for(i in 1: ncol(output)){ cat(length(var.names), '\n') cat("A", "S", "C", "I", '\n')
2010 Jun 09
1
Performing a function on columns specified in another dataframe
Hello Listserve, Here is another question to keep you on your toes. Please consider the following toy dataset: a <- read.table(textConnection("fred sam joe alex measure.1 10 4 10 1 measure.2 10 4 2 8 measure.3 3 1 8 3 measure.4 5 1 3 3 measure.5 8 6 8 3 measure.6 9 5 1 0 measure.7 4 6 10 1 measure.8 3 6 8 9 measure.9 8 6 7 7 measure.10 7 8 9 8"), header = TRUE) And also please
2006 Dec 12
4
How to sum one column in a data frame keyed on other columns
I have a data frame that looks like this: url time somethingirrelevant visits www.foo.com 1:00 xxx 100 www.foo.com 1:00 yyy 50 www.foo.com 2:00 xyz 25 www.bar.com 1:00 xxx 200 www.bar.com 1:00 zzz 200 www.foo.com 2:00 xxx 500 I'd like to write some code that takes this as input and outputs
2009 Dec 22
3
vector indexing problem in multilevel data: assigning a specific value to all group members
Dear List, I work with multilevel data from psychological group experiments and have frequently encountered a situation for which I haven't found an elegant solution: I need to assign the value of a specific group member to all members of the group. For example, I have a group leader (identified by a binary vector) and some attribute for all group members. I want to create a new
2007 May 17
2
How to select specific rows from a data frame based on values
Dear Group: I am working with a data frame containing 316 rows of individuals with 79 variables. Each of these 79 variables have values that range between -4 to +4, and I want to subset this data frame so that in the resulting new dataframe, values of _all_ of these variables should range between -3 and +3. Let's say I have the following dataframe (it's a toy example with 4 individuals
2012 Feb 14
1
Filling out a data frame row by row.... slow!
I'm reading a file and using the file to populate a data frame. The way the file is laid out, I need to fill in the data frame one row at a time. When I start reading my file, I don't know how many rows I will need. It's on the order of a million. Being mindful of the time expense of reallocation, I decided on a strategy of doubling the data frame size every time I needed to expand
2008 May 28
1
indexing lists, using brobdingnagian
Dear R-Gurus, I have ended up with a calculation problem where I need to use brobs. I have to work my way through a vector with a for loop to act on each element in a calculation (refering to the previous value in the new vector of results -- so as far as I know I can't use "apply") -- this produces a list of brobs. My problem is, how do I act on, plot this list, or do vector
2011 Mar 31
1
Assign Names of columns in data.frame dinamically
Hello List. I have many files of ECG, each one with 7 column and I need only the second column and the name of each ECG. I am doing this but althought I have various days trying this i haven't gotten, so I ask help with this, if somebody cans help me I'll be so thankfully. --------------------------------------------------------------------------------------------------------
2001 Sep 20
3
indexing an array
Dear everybody, I have a following problem. I have a 3D array lambda <- array( dim=c(N,M,M-1)) where I have to extract the elements as follows: lambda[ 1, state[1], 1] lambda[ 1, state[1], 2] ... lambda[ 1, state[1], M-1] lambda[ 2, state[2], 1] ... lambda[ 2, state[2], M-1] ... lambda[ N, state[N], M-1] i.e. the result should be a 2D array, where the second index follows the first one
2012 Feb 10
2
apply pairs function to multiple columns in a data frame
I am very new to R and programming and thank you in advance for your patience and help with a complete novice! I am working with a large multivariate data set that has 10 explanatory environmental variables (e.g. temp, depth) and over 60 response variables (each is a separate species). My data frame is set up like the simplified version below: JulianDay Temperature Salinity Depth Copepod
2009 Jul 24
1
single row/column-indexing on matrices
hi all - quick question: i have a matrix m, say nrow=5, ncol=4. in a function i'd like to retrieve certain rows or columns from m, but which rows/cols are not known ahead of time. the function should return a sub-matrix (i.e. still of class 'matrix'). when selecting a single column (or row), the indexing operation converts the object of class 'matrix' into a vector of
2012 May 01
3
Data frame vs matrix quirk: Hinky error message?
AdvisoRs: Is the following a bug, feature, hinky error message, or dumb Bert? > mtest <- matrix(1:12,nr=4) > dftest <- data.frame(mtest) > ix <- cbind(1:2,2:3) > mtest[ix] <- NA > mtest [,1] [,2] [,3] [1,] 1 NA 9 [2,] 2 6 NA [3,] 3 7 11 [4,] 4 8 12 ## But ... > dftest[ix] <- NA Error in `[<-.data.frame`(`*tmp*`, ix, value
2011 Jan 19
2
MCMC object indexing
I have an mcmc object and I''m trying to plot the quantiles of the variables - and not as a function of the iterations as in cumuplot. I cannot seem to find the right combination of indexing to access the variables; after which I''m sure I can plot all the statistics I could hope for. Any hints for accessing the mcmc object would be appreciated. =Dave [[alternative HTML