Reading textfile in R -


i have text file tab delimited, sample data of file like

id<\t> address<\t> city <br> 1<\t>  abc<\t>   brookyln<br> 2<\t> dhf<\t>    philadelphia<br> 

i used

data <- read.table(file.choose(), sep="\t",quote = "",header=true) 

function read text file.

but when trying access first column, giving null

data$id null 

but when tried accessing other columns worked

data$city brooklyn philadelphia 

i tried reading data frame

data <- as.data.frame(read.table(file.choose(), sep="\t",quote = "",header=true)) 

but still got same error

"null" output r returns when try read non-existing column. seems id column not exists.

to see names of columns exist in data run colnames(data) make sure id column exists.


Comments