add_vector_to_df | R Documentation |
Given a vector, adds each value and its corresponding name to a data frame of 2 columns as new rows, where the name fills in the 1st column and the value the 2nd column.
add_vector_to_df(df, vec)
df |
|
vec |
a vector |
a data.frame
with additional rows and each element as a
character.
df = data.frame(c(0,0,1), c(0,0,2))
vec = 1:3
names(vec) = c("a","b","c")
add_vector_to_df(df, vec)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.