Hi,

I have three lists,

``

please tell me how to make this happen?

Hi,

I have three lists,

``

please tell me how to make this happen?

You should include a simple reprex with your question that:

- Builds the input data you are using.
- The function you are trying to write, even if it doesn't work.
- Usage of the function you are trying to write, even if it doesn't work.
- Builds the output data you want the function to produce.

You can learn more about reprex's here:

Right now the is an issue with the version of reprex that is in CRAN so you should download it directly from github.

Until CRAN catches up with the latest version install reprex with

devtools::install_github("tidyverse/reprex")

Here is an example of a reprex that does this:

```
ref=c(I= 131.1736, L= 131.1736, K= 146.1882, M= 149.2124, F= 165.19, T= 119.1197, W= 204.2262, V= 117.1469, R= 174.2017, H= 155.1552, A= 89.0935, N= 132.1184, D= 133.1032, C= 121.159, E= 147.1299, Q= 146.1451, G= 75.0669, P= 115.131, S= 105.093, Y= 181.1894)
ref1=c(I=2.36, L=2.36, K=2.18, M=2.28, F=1.83, T=2.63, W=2.38, V=2.32, R=2.17, H=1.82, A=2.34, N=2.02, D=2.09, C=1.71, E=2.19, Q=2.17, G=2.34, P=1.99, S=2.21, Y=2.2)
ref2=c(I=9.68, L=9.60, K=8.95, M=9.21, F=9.13, T=9.10, W=9.39, V=9.62, R=9.04, H=9.17, A=9.69, N=8.84, D=9.82, C=10.78, E=9.67, Q=9.13, G=9.60, P=10.60, S=9.15, Y=9.11)
f1 <- function(l, r1, r2, r3) {
#??? don't know what to put here
}
# expected_output for
# f1("I", ref, ref1, ref2)
expected_output <- c(I = 131.1736, I = 2.36, I = 9.68)
expected_output
#> I I I
#> 131.1736 2.3600 9.6800
```

Created on 2018-03-09 by the reprex package (v0.2.0).

In any case here is a way of producing the output you are looking for:

```
ref=c(I= 131.1736, L= 131.1736, K= 146.1882, M= 149.2124, F= 165.19, T= 119.1197, W= 204.2262, V= 117.1469, R= 174.2017, H= 155.1552, A= 89.0935, N= 132.1184, D= 133.1032, C= 121.159, E= 147.1299, Q= 146.1451, G= 75.0669, P= 115.131, S= 105.093, Y= 181.1894)
ref1=c(I=2.36, L=2.36, K=2.18, M=2.28, F=1.83, T=2.63, W=2.38, V=2.32, R=2.17, H=1.82, A=2.34, N=2.02, D=2.09, C=1.71, E=2.19, Q=2.17, G=2.34, P=1.99, S=2.21, Y=2.2)
ref2=c(I=9.68, L=9.60, K=8.95, M=9.21, F=9.13, T=9.10, W=9.39, V=9.62, R=9.04, H=9.17, A=9.69, N=8.84, D=9.82, C=10.78, E=9.67, Q=9.13, G=9.60, P=10.60, S=9.15, Y=9.11)
f1 <- function(l, r1, r2, r3) {
v <- c(r1[[l]], r2[[l]], r3[[l]])
names(v) <- c(l, l, l)
v
}
expected_output <- c(I = 131.1736, I = 2.36, I = 9.68)
output <- f1("I", ref, ref1, ref2)
identical(output, expected_output)
#> [1] TRUE
output
#> I I I
#> 131.1736 2.3600 9.6800
```

Created on 2018-03-09 by the reprex package (v0.2.0).

Notice how easy is to check that the output of f1 is what is expected.

Please keep in mind that almost everyone here is answering questions in their spare time and appreciates the effort you take to make is as easy as possible for them to help you.

2 Likes

Thanks for explaining all that, Dan. @iMayank, just as some overall advice:

i want to make a table, where when i input value I then it should show all three values

is a bit vague in practiceâ€” when you say *"show all three values"* and do you mean as output? (as Dan has shown below) If not, do you mean using Shiny, or something of the like?

*aside: I moved this to General from RStudio IDE. If the question is about doing something in R, and not about the IDE itself (i.e. the interface, or something that's working in R but not in RStudio), then it's best to put it in a different topic area*