Assume i have a
mylist<-list( c(12,3,12,5),"Hello R",sin )
function (x) .Primitive("sin")
Error: attempt to apply non-function
You are very very close. Notice that when you type
mylist, next to your desired output, you also get
[]. This means that this is a list with element 1. You can see this if you do
> str(mylist) List of 1 $ :function (x)
To subset the very element of the list (and not just the third list element), you should use double bracket.
> mylist[](90)  0.8939967
Here is a nice representation of how to work with lists in R.
Alternatively, you could name your elements and access them that way.
> mylist <- list(a = c(12,3,12,5), b = "Hello R", allmysins = sin) > mylist$allmysins(90)  0.8939967