Using read.csv, I have a dataframe read from .csv file which has data arranged as following:
team1 team2 team3
Andy Alice Karen
Bob Belle Kyle
Chad Carol
Diana
team <- read.csv("team.csv")
The data frame is of factor class and have dimension or 4x3. For team1 and team3 columns, the extra empty rows are show with "".
I want to extract the column as a vector using as.character conversion. But how do I shorten this vector exclude the "" elements? For eg.:
team1_list <- as.character(team$team1) includes the trailing "" element. I just want to have the vector of ("Andy", "Bob", "Chad") and not ("Andy", "Bob", "Chad", "")
team1_list <- as.character(team$team1[team$team1!=""])orteam1_list <- as.character(team$team1[levels(team$team1)!=""])