Skip to content

Arguments become nonnumeric

5 messages · Ferri Leberl, jim holtman

#
Dear Everybody,
Enclosed are the tiny beginning of a program and its output.
As a pity, if I load the image <load("kanal.RData")> the elements of
<de.dd> are non numerical; <de.dd[2]+de.dd[3]> returns <Fehler in
de.dd[2] + de.dd[3] : nicht-numerisches Argument f??r bin??ren Operator>.
How can I keep the numbers numerical?
Thank you in advance.
hopefully,
Mag. Ferri Leberl
-------------- n?chster Teil --------------
#Programm zur Erstellung eines Wasserwegenetzplanes

#St??dte
#TLD.Stadtk??rzel<-c("Stadtname",??Breite,'Breite,??L??nge,'L??nge)
de.dd<-c("Dresden",51,2,13,44)
save.image("~/gmx/allalei/kanal/kanal.RData")
#
You program contains:

de.dd<-c("Dresden",51,2,13,44)

and since you are mixing characters with numerics and putting them
into a single vector, the data is coerced to a common data type, which
in this case is numeric.  What are you trying to do?  Do you want to
use a list?
[1] "Dresden" "51"      "2"       "13"      "44"
[[1]]
[1] "Dresden"

[[2]]
[1] 51

[[3]]
[1] 2

[[4]]
[1] 13

[[5]]
[1] 44

A list will maintain the mode of each element.
On Dec 9, 2007 6:14 AM, Mag. Ferri Leberl <ferri.leberl at gmx.at> wrote:

  
    
#
Meant to say coerced to "character".

See "?c"
On Dec 9, 2007 6:14 AM, Mag. Ferri Leberl <ferri.leberl at gmx.at> wrote:

  
    
#
Thank you, this seems promissing. How can I address then a certain
element e.g. to add the second and the third component?
Faithfully,
Mag. Ferri Leberl



Am Sonntag, den 09.12.2007, 07:11 -0800 schrieb jim holtman:
#
Several different ways.  You can look in the Intro to R to learn more:
$a
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9

$b
[1] 1 2 3 4

$c
[1] "this is  a string"

$d
$d[[1]]
[1] 1

$d[[2]]
[1] 2

$d[[3]]
[1] 3
[,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
[[1]]
[1] 1

[[2]]
[1] 2

[[3]]
[1] 3
[1] 2
[1] 2
[,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9

        
On Dec 9, 2007 1:36 PM, Mag. Ferri Leberl <ferri.leberl at gmx.at> wrote: