I am quite new in R and I know it is very simple but i got stuck.
Could you please tell me how I can write an Excel formula ="X" & i
(for i for instance from 1 to 10) used in loop in r.
For example, assume I have two dataframes with a single column "SUBSET1" and "SUBSET2". What I want is to save the result of the sum of each column in two different dataframes.
For an reproducible example please refer below to the EDIT part:
Illustration:
for (i in 1:2)
{
assign(paste0("sum_results", i),"")
}
for (i in 1:2)
{
sum_results & i<-sum(subset & i) ----something which works in this way
}
I would be very grateful for any hint.
EDIT: Proper example:
Let's assume I have the following data frames
a<-c(2,3,4)
b<-c(2,3,5)
subset1<-data.frame(a,b)
a<-c(2,7,5)
b<-c(4,8,15)
subset2<-data.frame(a,b)
So desired output is that I have two data frames: sum_results1 & sum_results2, where sum_results1 is the sum of the column "a" of the subset1, and sum_results2 is the sum of the column "a" of the subset2.
for (i in 1:2)
{
assign(paste0("sum_results", i),"")
}
for (i in 1:2)
{
sum_results & i<-sum(subset & i)$a --that is where the problem is
}