similar to: merging a list and data frame

Displaying 20 results from an estimated 40000 matches similar to: "merging a list and data frame"

2010 Jul 16
0
Mixed Conditional Logit with nested data
Hello Everyone,   This is my first attempt to do something in R. As a precursor to a Willingness to Pay analysis, I want to conduct a Mixed Conditional Logit analysis but am unsure how to proceed because of some nesting within my data.   Below is some data and code that illustrate what I’m trying to do. The data are based on responses to a conjoint survey obtained during pilot testing. In the
2008 Sep 28
2
using tapply on a data frame in a function
Hello, I'm trying to use tapply to find group means in a function. It works outside of a function, but I get the error message from the following code: "Error in tapply(index, cluster, mean) : arguments must have same length." Any suggestions? Thanks. eric d <- data.frame(cbind(cluster=1:2, value1=1:10, value2=11:20)) d FindClusterTraits <- function(framename, index){
2008 Oct 01
3
lapply where each list object has multiple parts
Hi. I have a list where each object in the list has multiple parts. I'd like to take the mean of just one part of each object. Is it possible to do this with lapply? If not, can you recommend another function? Thanks. eric > x1 <- c(0,1,2,3) > x2 <- c(7,8) > x3 <- c(2,6,6,8) > x4 <- c(4,8) > > Lst1 <- list(label1 = x1,label2 = x2) > Lst2 <-
2009 Feb 02
2
how to generate multiple random variables that are correlated
Hi. I have two variables, x and y, that are each normally distributed with mean 0 and have known standard deviations. The variables also have a known correlation, so I can represent their correlations in a matrix like so: a <- array(c(0.3,0.1,0.1,0.2),c(2,2)) a Is there an R function that generates random values for my two variables given the correlation? I'd like to do this for up to
2008 Dec 09
3
difftime
Hi. I'm trying to take the difference in days between two times. Can you point out what's wrong, or suggest a different function? When I try the following code, The following code works fine: a <- strptime(1911100807,format="%Y%m%d%H",tz="GMT") b <- strptime(1911102718,format="%Y%m%d%H",tz="GMT") x <- difftime(b, a,
2004 Aug 17
6
dialplan woes
I am making some changes to the dial plan at the request of the company president and have run into some problems. I have a couple of layers of menu's and I am not sure how to handle them. Here is how it should work (sorry for the crappy diagram) main menu --------Dial 1 for support | Dial 2 for special | Dial 3 sales
2008 Sep 29
2
adding labels to tapply results
Hi, How do I get labels onto the output from tapply? I need the labels to merge the output with another data frame. Thanks. eric d <- data.frame(cbind(x=1:3, y=1:10)) a <- with(d, tapply(y, x, sum)) [[alternative HTML version deleted]]
2008 Nov 08
2
lines, ecdf and colors
Hi. I'm trying to plot two ecdf's on the same graph using two different colors. I can plot using the same color, but it doesn't work when I change colors? Any suggestions? Thanks in advance for your help. x <- c(0.80, 0.83, 1.89, 1.04, 1.45, 1.38, 1.91, 1.64, 0.73, 1.46) y <- c(1.15, 0.88, 0.90, 0.74, 1.21) plot(ecdf(x)) # it works without col='blue', but doesn't
2011 Apr 04
4
merging data list in to single data frame
Dear R community members I did find a good way to merge my 200 text data files in to a single data file with one column added will show indicator for that file. filelist = list.files(pattern = "K*cd.txt") # the file names are K1cd.txt .................to K200cd.txt data_list <-lapply(filelist, read.table, header=T, comment=";", fill=T) This will create list,
2008 Oct 17
1
find bayesian information criterion for all variable combinations
Hi, I have data for one dependent variable and multiple independent variables y = b0 + b1*x1 + b2*x2 + ... I want to a list of all models that have some subset of the independents (just x1 x2, and not x3, etc.) and their corresponding BIC values. Is there a pre-existing function that does this? I saw that you can calculate individual BIC values using 'lm' and something like AIC(lm1, k
2009 Dec 08
6
conditionally merging adjacent rows in a data frame
Hi, I have a data frame and want to merge adjacent rows if some condition is met. There's an obvious solution using a loop but it is prohibitively slow because my data frame is large. Is there an efficient canonical solution for that? > head(d) rt dur tid mood roi x 55 5523 200 4 subj 9 5 56 5523 52 4 subj 7 31 57 5523 209 4 subj 4 9 58 5523 188 4 subj 4 7
2009 Jul 31
2
merging two data frame with colomns of different length
Dear all, I am trying to merge two data frames based on a common column but for this common column both data frame do not have the same length and associated information. I checked previous exemples in the list but was not able to apply them in my case... Is someone know how to do that? Below is my code with the expected result: # data frame 1 Id1 <- c(1,1,1,2,2,2,3,3,3) Habit1 <-
2010 May 11
1
merging data frame
Dear group, I have 3 data frames I would like to merge. Here they are: pose16 <- structure(list(DESCRIPTION = structure(c(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 12L), .Label = c("COPPER May/10", "COTTON NO.2 Jul/10", "CRUDE OIL miNY May/10", "GOLD Jun/10", "ROBUSTA COFFEE (10) Jul/10", "SOYBEANS Jul/10", "SUGAR NO.11
2003 Aug 15
1
Merging and sorting multiple data.frame
Dear R help, I'm pretty new to R and would be grateful for help. I have 11 data.frames, each with 3 columns of data. Each has the same row.names, however these are not sorted. Please tell me the best way to sort these (by row.names) and secondly the best way to extract data columns from these to form a merged table. Thanks a million Aedin
2000 Mar 07
3
Merging data.frames
On Tuesday, March 07, 2000 5:40 PM, Richard Bilonick wrote: >I need to merge several data.frames into one data.frame. In S-Plus I would >use >"merge" but I don't see a merge command in R. What is the best way to >accomplish >this? The easiest way to to this, I think, is as follows: if you have several data frames, dataframe1, dataframe2, . . . , dataframen, you
2012 Apr 13
5
Merging two data frames with different columns names
I am trying to merge two data frames, but one of the column headings are different in the two frames. How can I rjoin or rbind the tho frames? Johnny # Generate 2 blocks by confounding on abc d1 <- conf.design(c(1,1,1), p=2, block.name="blk", treatment.names = c("A","B","C")) d2 <- conf.design(c(1,1,1), p=2, block.name="blk",
2010 Oct 28
1
Merging nested lists
Hello All, I have multiple "list of lists" in the form of Mylist1[[N]][[K]]$Name_i, with N=1..6, K=1..3, and i=1..7. Each Name_i is a matrix. I have 30 of these objects Mylist1, Mylist2, ... I would like to merge these lists by each Name_i using rbind, but I couldn't figure out how to do it. What I want at the end is a single "list of lists", again in the form of
2009 Apr 22
3
Merging data frames, or one column/vector with a data frame filling out empty rows with NA's
Hello I have two data frames, SNP4 and SNP1: > head(SNP4) Animal Marker Y 3213 194073197 P1001 0.021088 1295 194073197 P1002 0.021088 915 194073197 P1004 0.021088 2833 194073197 P1005 0.021088 1487 194073197 P1006 0.021088 1885 194073197 P1007 0.021088 > head(SNP1) Animal Marker x 3213 194073197 P1001 2 1295 194073197 P1002 1 915 194073197
2006 May 30
2
merging
Dear List, Given, y <- matrix(c(0,1,1,1,0,0,0,4,4), ncol = 3, byrow = TRUE) rownames(y) <- c("a","b","c") colnames(y) <- c("1","2","3") y y2 <- y[2:3, ] rownames(y2) <- c("x","z") y2 how can I stop merge(y, y2, all = TRUE, sort = FALSE) squishing the extra rows? Ideally I want the same as: rbind(y,
2018 Feb 15
2
Duplicate column names created by base::merge() when by.x has the same name as a column in y
Hi, I was unable to find a bug report for this with a cursory search, but would like clarification if this is intended or unavoidable behaviour: ```{r} # Create example data.frames parents <- data.frame(name=c("Sarah", "Max", "Qin", "Lex"), sex=c("F", "M", "F", "M"),