Hey all,
I am trying to get my feet wet in R programming for statistical analysis. '
Can anyone of you, tell me what is the basic differences and similarities between a list and vector, in a simple laymanâ€™s termsâ€¦
What is a data frames?
thank you again. Now I am to totally understand the complex code that I am currently dealing with. You are a lifesaver, sent from heaven. Thank you a million
a vector is an array, i. e. all the elements are contiguous in memory and easily can be indexed by a counter from 0 to n-1 where n is the number of elements.
a list unlike to a vector is a collection of nodes. each node contains exactly 1 list element and points backwards to a predecessor node (beside of the first node) and forward to a successor node (beside of the last node of a list). a list fastly could be grow as adding a new node only requires a maximum of two nodes to be updated while in a vector you might have to move a good part of the array or even use new bigger contiguous space when the array grows. in R lists might have elements of different type what often is the main advantage of a list especially when you deal with a small number of elements.
a dataframe is a list of column vectors as explained by ststuber.
Sara
1
RayneAuthor Commented:
Awesome, thank you Sara. this is very useful to understand :)
0
Featured Post
Solve your biggest tech problems alongside global tech experts with 1:1 help.
a list an ordered collection of elements that can be of different types (a list containing a number, text, a date, and a boolean)
a data frame is a list of vectors
So a data frame might be envisioned as list (vector1, vector2, vector3)
where vector1 might be a collection of ids, vector2 a collection of dates, and vector3 is a collection of names
in other words, a data frame is rows and columns (where each column is a vector)
Open in new window