Ok i feel pretty stupid.. been trying to read a text file that contains heading in the first line in to R but cant. all i need to do is make a contour plot for a friend but after weeks i feel like giving up.. i included the first few lines of the file.. any help will be great Thanks Hannes http://www.nabble.com/file/p24777697/small.txt small.txt -- View this message in context: http://www.nabble.com/i%27m-so-stuck-with-text-file-and-contour-plot-tp24777697p24777697.html Sent from the R help mailing list archive at Nabble.com.
Hannes,>> been trying to read a text file that contains heading in the first line >> in to R but cant.You want the following: ## TDat <- read.csv("small.txt", sep="\t") TDat str(TDat) See ?read.csv Regards, Mark. hannesPretorius wrote:> > Ok i feel pretty stupid.. been trying to read a text file that contains > heading in the first line in to R but cant. all i need to do is make a > contour plot for a friend but after weeks i feel like giving up.. i > included the first few lines of the file.. any help will be great > > Thanks > > Hannes http://www.nabble.com/file/p24777697/small.txt small.txt >-- View this message in context: http://www.nabble.com/i%27m-so-stuck-with-text-file-and-contour-plot-tp24777697p24780416.html Sent from the R help mailing list archive at Nabble.com.
Seems to read in fine; what errors were you getting?> x <- read.table('/small.txt', sep='\t', header=TRUE) > str(x)'data.frame': 10 obs. of 7 variables: $ Placename : Factor w/ 10 levels "Aankoms","Aapieshoek",..: 1 2 3 4 5 6 7 8 9 10 $ X_coord : num 30.9 31.4 31.1 31.4 18.7 ... $ Y_coord : num -26.2 -27.4 -29 -29 -33.5 ... $ Jan.to.Dec.2006.Stroke.Density.per.sq.km : num 35.3 37.4 16.7 11.9 0 3.3 12 10.5 6.1 8.9 $ Jan.to.Dec.2007.Stroke.Density.per.sq.km : num 23.2 27.7 11.3 3.2 0.3 3 6.6 16.3 7.8 9.9 $ Jan.to.Oct.2008.Stroke.Density.per.sq.km : num 32.4 9.7 1 1.8 0.3 1 2.6 2.6 9.5 4.2 $ Total.Strokes.per.sq.km.for.Jan.2006.to.Oct.2008: num 55.5 37.4 12.4 5 0.5 4 9.3 18.9 17.2 14.1>On Sun, Aug 2, 2009 at 9:06 AM, hannesPretorius<talk2hannes at gmail.com> wrote:> > Ok i feel pretty stupid.. been trying to read a text file that contains > heading in the first line in to R but cant. all i need to do is make a > contour plot for a friend but after weeks i feel like giving up.. i included > the first few lines of the file.. any help will be great > > Thanks > > Hannes http://www.nabble.com/file/p24777697/small.txt small.txt > -- > View this message in context: http://www.nabble.com/i%27m-so-stuck-with-text-file-and-contour-plot-tp24777697p24777697.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >-- Jim Holtman Cincinnati, OH +1 513 646 9390 What is the problem that you are trying to solve?
When I read the entire text file in I get the following message> x <- read.table('c:/small.txt', sep='\t', header=TRUE)Warning message: number of items read is not a multiple of the number of columns. thanks. hannesPretorius wrote:> > Ok i feel pretty stupid.. been trying to read a text file that contains > heading in the first line in to R but cant. all i need to do is make a > contour plot for a friend but after weeks i feel like giving up.. i > included the first few lines of the file.. any help will be great > > Thanks > > Hannes http://www.nabble.com/file/p24777697/small.txt small.txt >-- View this message in context: http://www.nabble.com/i%27m-so-stuck-with-text-file-and-contour-plot-tp24777697p24823374.html Sent from the R help mailing list archive at Nabble.com.