Reza Reza - 2 years ago 99
R Question

Choosing specific data in R

Suppose I have a function that gives two or more data out. For example, a function that gives Lower Confidence Limit and Upper Confidence limit for a statistic.

Let's say the function is like this:
CI(a,b,c,d) and then it provides two answers:

>[1] 35.25976562 0.02499848

Now, if I want to use only ONE of these two answers to write a new function, how can I get R use ONLY, say, the first answer in my new function?

Answer Source

head might be useful for you, this function returns the first parts of a vector in this case.

head(CI, 1) 

head(CI, 2) 
35.25976562   0.02499848

Since head() is a generic function, It may also has been extended to other classes. Read more about head by typing ?head in your R console.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download