Hi all i am facing a peculiar problem for data input using read.table which i never faced previously. i have a data file by name abnew.txt with two coloumns data as depicted below. A B 420 422 314 321 the txt file is created using the excel save as option. i issued the statement as> a <- read.table("abnew.txt", header=TRUE) > aX.??S 1 NA 2 2 3 2 4 NA 5 2 6 2 7 NA 8 2 9 2 10 NA the o/p looks like as copied above. can some one help me on correct data reading. your earliest response will help me a lot. thanks and regards snvk
Hi if you still have Excel file and can open it open Excel select what you want to read, including header press ctrl-C then in R a<-read.delim("clipboard") and to write from R write.table(tab, "clipboard", sep = "\t", row.names = F) open Excel press ctrl-V Looks like Excel left in your txt file something which prevent correct reading. Does the txt file look like you presented in other viewer (Notepad,....) HTH Petr On 16 Sep 2005 at 19:46, Krishna wrote:> Hi all > > i am facing a peculiar problem for data input using read.table which i > never faced previously. > > i have a data file by name abnew.txt with two coloumns data as > depicted below. > > A B > 420 422 > 314 321 > > the txt file is created using the excel save as option. i issued the > statement as > > > a <- read.table("abnew.txt", header=TRUE) > > a > X.??S > 1 NA > 2 2 > 3 2 > 4 NA > 5 2 > 6 2 > 7 NA > 8 2 > 9 2 > 10 NA > > the o/p looks like as copied above. can some one help me on correct > data reading. your earliest response will help me a lot. > > thanks and regards > > snvk > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.htmlPetr Pikal petr.pikal at precheza.cz
Krishna <snvk4u at gmail.com> writes:> Hi all > > i am facing a peculiar problem for data input using read.table which i > never faced previously. > > i have a data file by name abnew.txt with two coloumns data as depicted below. > > A B > 420 422 > 314 321(with A left-justified and B right-ditto???)> the txt file is created using the excel save as option. i issued the > statement as > > > a <- read.table("abnew.txt", header=TRUE) > > a > X.??S > 1 NA > 2 2 > 3 2 > 4 NA > 5 2 > 6 2 > 7 NA > 8 2 > 9 2 > 10 NA > > the o/p looks like as copied above. can some one help me on correct > data reading. your earliest response will help me a lot.What do you get from readLines("abnew.txt")? You might want to try read.delim("abnew.txt"). -- O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907