Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我从因子列中提取一些行时,我的数据框正在中断:
data.df = data.frame(x = factor(letters[1:10])) data.temp = data.df[1:3, ] print(data.temp)
我怎样才能避免这种情况?我还需要保留列名。谢谢!
您可以添加参数drop=FALSE以将数据保留为数据框。
drop=FALSE
data.df = data.frame(x = factor(letters[1:10])) data.temp = data.df[1:3, ,drop=FALSE] print(data.temp) x 1 a 2 b 3 c