clickpn
clickpn

Reputation: 41

how to remove rows from dataframe in r (different situation)

So I want to remove the first row in the data frame. my code is like

reddot.info<-reddot.info[-1,]

But then i find i can not view this data frame. i figure out the reason. because when i run code

reddot.info[1,]

if appears as Num Product_names URL 1 NA Product Names URL which means that if i use this code i will also remove the column names. so what should i do to remove the first row in stead of removing the column names and first row together.

Thank you so much.

Upvotes: 0

Views: 105

Answers (1)

JeremyS
JeremyS

Reputation: 3525

You probably don't have column names to begin with because removing the first row like that doesn't remove the column names.

colnames(reddot.info) <- reddot.info[1,]
reddot.info <- reddot.info[-1,]

Upvotes: 4

Related Questions