similar to: multiplication by groups

Displaying 20 results from an estimated 10000 matches similar to: "multiplication by groups"

2016 Apr 24
0
Dividing rows in groups
This will handle all the columns; it assumes the ones you want to start with are in column 2 through the end: > library(dplyr) > df1 <- read.table(text = "ID A B + 1 1 2 + 1 0 3 + 2 5 NA + 2 1 3 + 3 1 4 + 4 NA NA + 4 0 1 + 4
2016 Apr 24
3
Dividing rows in groups
Hi I have two data frames as shown below (second one is obtained by aggregating rows of similar IDs in df1.). They both have similar number of columns but rows of df2 are lesser than rows of df1. df1: ID A B 1 1 2 1 0 3 2 5 NA 2 1 3 3 1 4 4 NA NA 4
2016 Apr 24
0
multiplication by groups
df1 <- data.frame(ID = c(1,1,2,2,3,3,4,4,5,5), A = c(1,0,5,1,1,NA,0,3,2,7), B = c(2,3,NA,3,4,NA,1,0,5,NA)) df2 <- data.frame(ID = c(1,2,3,4,5), A = c(1,6,1,3,9), B = c(5,3,4,1,5)) m <- match(df1$ID, df2$ID) sel <- c("A", "B") for (i in 1:nrow(df1)) { df1[i,sel] <-
2007 May 05
1
loop in function
Dear Mailing-List, I think this is a newbie question. However, i would like to integrate a loop in the function below. So that the script calculates for each variable within the dataframe df1 the connecting data in df2. Actually it takes only the first row. I hope that's clear. My goal is to apply the function for each data in df1. Many thanks in advance. An example is as follows: df1
2009 Jan 18
1
Multiplication of dataframes
If I have 2 data frames; df1: dim(df1) = (1,10) df2: dim(df2) = (2000,10) Both with column header names, how do I multiply them together please. I.e create a dateframe dim() = (2000,1) Many Thanks in advance Glenn [[alternative HTML version deleted]]
2010 Jan 02
3
Help needed on applying a function across different data sets and aggregating the results into a single data set
Hi folks, Wish y'all a Happy New Year 2010! I need some help with the following: Say I have lots of data sets, on which I have to apply a certain function on the same set of columns in each of the data set. Let's take, for ex, the typical data set is: df1 <- as.data.frame(cbind(rnorm(10),rnorm(10))) names(df1)[1] <- "A" names(df1)[2] <- "B" There are many
2011 May 31
0
filling in a dataframe with another dataframe
Hello All, I have two dataframes and I wish to insert the values of one dataframe into another (let's call them DF1 and DF2). DF1 looks like this: col1.....col2 a...........1 b...........2 c...........3 d...........4 e...........5 f............6 g...........7 where col1 (which is just the first column of the dataframe) is a list of characters and col2 is the numeric value associated with
2017 Jul 13
0
about plotting a special case
If you want colors mapped to the _values_ in DF1$C, there are a number of ways to do it: Color_unq<-color.scale(DF1$C,c(1,0),c(0,0,c(0,1)) This will produce colors from the lowest values (red) through the highest (blue). See the help page for color.scale to get different colors. With this you can use color.legend to add a mapping of the values and colors. If you just want different colors,
2011 Aug 18
2
Best way/practice to create a new data frame from two given ones with last column computed from the two data frames?
Dear expeRts, What is the best approach to create a third data frame from two given ones, when the new/third data frame has last column computed from the last columns of the two given data frames? ## Okay, sounds complicated, so here is an example. Assume we have the two data frames: df1 <- data.frame(Year=rep(2001:2010, each=2), Group=c("Group 1","Group 2"), Value=1:20)
2013 Feb 26
2
merging or joining 2 dataframes: merge, rbind.fill, etc.?
#I want to "merge" or "join" 2 dataframes (df1 & df2) into a 3rd (mydf). I want the 3rd dataframe to contain 1 row for each row in df1 & df2, and all the columns in both df1 & df2. The solution should "work" even if the 2 dataframes are identical, and even if the 2 dataframes do not have the same column names. The rbind.fill function seems to work. For
2006 Jul 01
1
noncentral F-distributed random numbers (PR#9055)
Full_Name: Long Qu Version: 2.3.1 OS: Windows XP Submission from: (NULL) (64.113.93.235) The QQ-plot of two versions of simulating noncentral F-distributed random numbers has quite different scales: > qqplot(rf(1000,2,15,3),qf(runif(1000),2,15,3)) The rf() function reads: > rf function (n, df1, df2, ncp = 0) { if (ncp == 0) .Internal(rf(n, df1, df2)) else rchisq(n, df1,
2012 Oct 11
1
as.data.frame.matrix() returns an invalid object
Hi, Two ways to create what should normally be the same data frame: > df1 <- data.frame(a=character(0), b=character(0))> df1 [1] a b <0 rows> (or 0-length row.names) > df2 <- as.data.frame(matrix(character(0), ncol=2, dimnames=list(NULL, letters[1:2]))) > df2 [1] a b <0 rows> (or 0-length row.names) unique() works as expected except that I
2011 Nov 08
2
compare linear regressions
Hi, I'm trying to compare two linear regressions. I'm using the following approach: ################## xx<-1:100 df1 <- data.frame(x = xx, y = xx * 2 + 30 + rnorm(n=length(xx),sd=10), g = 1) df2 <- data.frame(x = xx, y = xx * 4 + 9 + rnorm(n=length(xx),sd=10), g = 2) dta <- rbind(df1, df2) dta$g <- factor(dta$g)
2005 Jan 21
0
R: chi-Squared distribution
Hi, Attention chi-squared distribution, unlike F distribution, has only df1 as parameter, not df1 and df2. So correct into: outer(1:3, 1:3, function(df1, df2) qchisq(0.95, df1, df2)) outer(1:3, 1:3, function(df1, df2) qchisq(0.95, df1)) ^^^^^^^^^^^^^^^^^^^^ Regards, Vito you wrote: Dear Rs: outer(1:3, 1:3, function(df1, df2) qf(0.95, df1, df2)) I compare this F
2011 May 16
0
Fwd: Re: rbind with partially overlapping column names
I had meant to copy the list on this; must have hit 'Reply' instead of 'Reply All'. P Ehlers -------- Original Message -------- Subject: Re: [R] rbind with partially overlapping column names Date: Mon, 16 May 2011 11:14:11 -0600 From: Peter Ehlers <ehlers at ucalgary.ca> To: Jonathan Flowers <jonathanmflowers at gmail.com> On 2011-05-16 08:56, Jonathan Flowers wrote:
2004 Feb 19
1
Comparing two regression slopes
I would suggest the method of Sokal and Rholf (1995) S. 498, using the F test. Below I repeat the analysis by Spencer Graves: Spencer: > df1 <- data.frame(x=1:3, y=1:3+rnorm(3)) > df2 <- data.frame(x=1:3, y=1:3+rnorm(3)) > fit1 <- lm(y~x, df1) > s1 <- summary(fit1)$coefficients > fit2 <- lm(y~x, df2) > s2 <- summary(fit2)$coefficients > db <-
2010 Apr 23
0
A distance measure between top-k list
Hi folks, Here is the problem. I am giving an example .I want to find a measure of similarity or dissimilarity among ranking (of students of a same class of size say 50)by two judges. But instead of observing the rank of all the 50 students (Where we could have used rank correlation measures)in each case what I have is 2 list of top 20 students chosen by each judge. The following paper gives out
2005 Jun 09
1
Subassignments involving NAs in data frames
I'm seeing some inconsistent behavior when re-assigning values in a data frame. The first assignment turns all of the 0s in my data frame to 2s, the second fails to do so. > df1 <- data.frame(a = c(NA, 0, 3, 4)) > df2 <- data.frame(a = c(NA, 0, 0, 4)) > df1[df1 == 0] <- 2 ## Works > df2[df2 == 0] <- 2 Error: NAs are not allowed in subscripted assignments Checking an
2011 Mar 18
1
Problem with Slope.test function
Hi all, I need to test the significnce of difference between slopes of two regression lines and regression line with theoretical line. I try to use Slope.test function from emu package, but an error occured... library(emu) d1<-data.frame(P1=c(1,2,3,5,7,8,9,13,14,15), P2=c(1,2,5,8,11,13,15,15,18,24), R=c(2,7,8,9,16,21,27,31,33,36)) # First data set m1<-lm(R~P1+P2+P1*P2,data=d1) # Regr.
2011 Nov 30
1
Replace columns in a data.frame randomly splitted
Dear community, I'm working with the data.frame attached ( http://r.789695.n4.nabble.com/file/n4122926/df1.xls df1.xls ), let's call it df1. I typed: df1<- read.xls("C:/... dir .../df1.xls",colNames= TRUE, rowNames= TRUE) Then I splited randomly df1 using splitdf function (http://gettinggeneticsdone.blogspot.com/2011/03/splitting- dataset-revisited-keeping.html)