The R Project SVN R

Rev

Rev 19004 | Rev 32809 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 19004 Rev 22811
Line 1... Line 1...
1
 
1
 
2
R : Copyright 2002, The R Development Core Team
2
R : Copyright 2003, The R Development Core Team
3
Version 1.5.0 Under development (unstable) (2002-03-29)
3
Version 1.7.0 Under development (unstable) (2003-01-24)
4
 
4
 
5
R is free software and comes with ABSOLUTELY NO WARRANTY.
5
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
You are welcome to redistribute it under certain conditions.
6
You are welcome to redistribute it under certain conditions.
7
Type `license()' or `licence()' for distribution details.
7
Type `license()' or `licence()' for distribution details.
8
 
8
 
Line 113... Line 113...
113
+     "3 1 2 3 NA TRUE def\n",
113
+     "3 1 2 3 NA TRUE def\n",
114
+     sep = "", file = "foo7")
114
+     sep = "", file = "foo7")
115
> (res <- read.table("foo7"))
115
> (res <- read.table("foo7"))
116
   A   B       C  D     E    F
116
   A   B       C  D     E    F
117
1  1 1.1  1.1+0i NA FALSE  abc
117
1  1 1.1  1.1+0i NA FALSE  abc
118
2 NA  NA      NA NA    NA   <NA>
118
2 NA  NA      NA NA    NA <NA>
119
3  1 2.0  3.0+0i NA  TRUE  def
119
3  1 2.0  3.0+0i NA  TRUE  def
120
> sapply(res, typeof)
120
> sapply(res, typeof)
121
        A         B         C         D         E         F 
121
        A         B         C         D         E         F 
122
"integer"  "double" "complex" "logical" "logical" "integer" 
122
"integer"  "double" "complex" "logical" "logical" "integer" 
123
> sapply(res, class)
123
> sapply(res, class)
124
$A
-
 
125
NULL
-
 
126
 
-
 
127
$B
-
 
128
NULL
-
 
129
 
-
 
130
$C
-
 
131
NULL
-
 
132
 
-
 
133
$D
-
 
134
NULL
-
 
135
 
-
 
-
 
124
        A         B         C         D         E         F 
136
$E
-
 
137
NULL
-
 
138
 
-
 
139
$F
-
 
140
[1] "factor"
125
"integer" "numeric" "complex" "logical" "logical"  "factor" 
141
 
-
 
142
> (res2 <- read.table("foo7",
126
> (res2 <- read.table("foo7",
143
+                     colClasses = c("character", rep("numeric", 2),
127
+                     colClasses = c("character", rep("numeric", 2),
144
+                     "complex", "integer", "logical", "character")))
128
+                     "complex", "integer", "logical", "character")))
145
   A   B       C  D     E    F
129
   A   B       C  D     E    F
146
1  1 1.1  1.1+0i NA FALSE  abc
130
1  1 1.1  1.1+0i NA FALSE  abc
147
2 NA  NA      NA NA    NA   <NA>
131
2 NA  NA      NA NA    NA <NA>
148
3  1 2.0  3.0+0i NA  TRUE  def
132
3  1 2.0  3.0+0i NA  TRUE  def
149
> sapply(res2, typeof)
133
> sapply(res2, typeof)
150
          A           B           C           D           E           F 
134
          A           B           C           D           E           F 
151
   "double"    "double"   "complex"   "integer"   "logical" "character" 
135
   "double"    "double"   "complex"   "integer"   "logical" "character" 
152
> sapply(res2, class)
136
> sapply(res2, class)
153
$A
-
 
154
NULL
-
 
155
 
-
 
156
$B
-
 
157
NULL
-
 
158
 
-
 
159
$C
-
 
160
NULL
-
 
161
 
-
 
162
$D
-
 
163
NULL
-
 
164
 
-
 
-
 
137
          A           B           C           D           E           F 
165
$E
-
 
166
NULL
-
 
167
 
-
 
168
$F
-
 
169
NULL
-
 
170
 
-
 
-
 
138
  "numeric"   "numeric"   "complex"   "integer"   "logical" "character" 
171
> unlink("foo7")
139
> unlink("foo7")
172
> 
140
> 
173
> # should be logical
141
> # should be logical
174
> type.convert(character(0))
142
> type.convert(character(0))
175
logical(0)
143
logical(0)