r - For Loop to Extract Vector Objects from Dataframe Column Headers -
i have dataframe df
50 columns, , generate vector objects each column name, length of dataframe rows.
my code throws out error:
for in ((1:ncol(df)) { colnames(df)[i] <- vector(mode = "list", length = nrow(df)) return (colnames(df)[i]) }
the error:
for in ((1:ncol(df)) { error: unexpected symbol in "for i" colnames(df)[i] <- vector(mode = "list", length = nrow(df)) error in colnames(df)[i] <- vector(mode = "list", length = nrow(df)) :
object 'i' not found return (colnames(df)[i]) error: object 'i' not found } error: unexpected '}' in "}"
p.s. of columns in dataframe nested lists, in case affects operation.
for(i in (1:ncol(df)))<----- parenthesis in wrong place
Comments
Post a Comment