[英]How can I obtain vector from data.frame
input输入
side <- c("ABC DEF", "XYZ", "GHF")
output output
[1] "ABC DEF" "XYZ" "GHF"
Now that I am importing data from excel, it is appearing as following using the given code:现在我正在从 excel 导入数据,使用给定的代码如下所示:
library("xlsx2dfs")
Mydata <- read.xlsx("Data.xlsx",sheet =1, rows=1:4)
Name
1 ABC DEF
2 XYZ
3 GHF
How do i have the same output while importing from excel file.从 excel 文件导入时,我如何拥有相同的 output。 Also I want to delete headers whereby there are no headers in the file.
另外我想删除文件中没有标题的标题。 Please help
请帮忙
First of all and most important I think is that when you write "I used to make dataframe using the following code" you have to know it's not true - this way you are not creating data.frame
object, but vector of values.首先,我认为最重要的是,当您编写“我曾经使用以下代码制作 dataframe”时,您必须知道这不是真的 - 这样您就不会创建
data.frame
object,而是值向量。 You can think - maybe you know this - of data.frame
as of table consists of rows and columns.您可以认为 - 也许您知道这一点 - 表中的
data.frame
由行和列组成。 And you can think of columns as a vectors - each column is a vector.您可以将列视为一个向量——每一列都是一个向量。 Knowing this, you can ask: "how can I obtain vector from data.frame" and this is what @user2974951 showed in the comment - syntax is
my_data_frame$my_column
or my_data_frame[["my_column"]]
.知道了这一点,您可以问:“我如何从 data.frame 获取向量”,这就是 @user2974951 在评论中显示的内容 - 语法是
my_data_frame$my_column
或my_data_frame[["my_column"]]
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.