Seems to work for me: > x <- read.table(textConnection("a b c d e f + SPX LSZ 100 C 0 34.4 + SPX LSZ 100 P 0 1.3 + SPX LSZ 105 C 0 30.3 + SPX LSZ 105 P 0 1.85 + SPX LSZ 110 C 0 26.4"), + header=T, colClasses=c("character","character","numeric","character", + "numeric","numeric")) > x a b c d e f 1 SPX LSZ 100 C 0 34.40 2 SPX LSZ 100 P 0 1.30 3 SPX LSZ 105 C 0 30.30 4 SPX LSZ 105 P 0 1.85 5 SPX LSZ 110 C 0 26.40 > str(x) 'data.frame': 5 obs. of 6 variables: $ a: chr "SPX" "SPX" "SPX" "SPX" ... $ b: chr "LSZ" "LSZ" "LSZ" "LSZ" ... $ c: num 100 100 105 105 110 $ d: chr "C" "P" "C" "P" ... $ e: num 0 0 0 0 0 $ f: num 34.4 1.3 30.3 1.85 26.4
> sessionInfo() R version 2.8.0 (2008-10-20) i386-pc-mingw32 locale: LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252 attached base packages: [1] stats grDevices utils datasets graphics methods base other attached packages: [1] MASS_7.2-44 On Fri, Dec 19, 2008 at 7:35 AM, threshold <r.kozar...@gmail.com> wrote: > > Hi , I want to use the read.table to the following example 'data.txt' format: > a b c d e f > SPX LSZ 100 C 0 34.4 > SPX LSZ 100 P 0 1.3 > SPX LSZ 105 C 0 30.3 > SPX LSZ 105 P 0 1.85 > SPX LSZ 110 C 0 26.4 > > and I want to have the columns a,b,d read as the 'character' data, a the > remaining columns as 'numeric'. What I did was: > read.table("data.txt",header=T, > colClasses=c("character","character","numeric","character", > "numeric","numeric"), but I could not get what I want, since all values were > in the 'character' format. I will apprecaite any suggestions. > best, robert > -- > View this message in context: > http://www.nabble.com/read.table-tp21090550p21090550.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help@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? ______________________________________________ R-help@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.