Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 208732

Calculating several regression analysis with specific columns in lapply

$
0
0

This is my data:

df1<-read.table(text=" Time1    Time2   Time3   MNR1    MNR2    MNR3

36  36  43  5   4   5
40  41  51  4   6   4
38  36  50  7   8   3
35  51  43  8   3   2
52  55  57  3   2   4
",header=TRUE)

I want to have a loop using lapply ( preferably) to analyse Time1 with MNR1, Time2 with MNR2 and Time 3 with MRN3 using regression model and ....

I have tried the following function, but I failed to get the results:

R <- lapply(1:ncol(df1), function(x) lm(Time[,x] ~ MNR[,x]))

But it does not give me the results for each group. Can we do it using lapply?


Viewing all articles
Browse latest Browse all 208732

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>