[R] Environment change?

David Winsemius
Sat, 24 Jan 2009 04:09:44 -0000

Those are not screen output from objects of the same type. The first
one is being displayed as a character type and the second series of
values appears to be a numeric vector. You called it a "lsit". In R a
list is a specific data structure and neither of these appear to be
displayed in a manner that would suggest a list.

 > one <- c("1", "2", "3")
 > one
[1] "1" "2" "3"

 > num_one <- c( 1,2,3)
 > num_one
[1] 1 2 3

 > list_one <- list(1,2,3)
 > list_one
[[1]]
[1] 1

[[2]]
[1] 2

[[3]]
[1] 3

 > list_two <-list(c(1,2,3))
 > list_two
[[1]]
[1] 1 2 3

You should be using str(), typeof(), and class() functions to answer
these questions. The screen display may not always be sufficient to
determine important features.

--
David Winsemius

On Jan 23, 2009, at 8:50 PM, PDXRugger wrote:

>
> So i have a simple question that doesnt require sample code, not
> sure if that
> violates posting rules or not.
>
> Is this:
> [1] "111" "112" "113" "114"
"115" "116" "118" "119" "120"
"123"
> "125" "126"
> [13] "127" "128" "132" "137"
"138" "139" "140" "143" "149"
"154" "156"
> "157"
> [25] "158" "164" "165" "166"
"173" "177" "188" "189" "190"
"191" "192"
> "193"
> [37] "194" "195" "196" "197"
"198" "199" "211" "213" "215"
"222" "223"
> "225"
> [49] "227" "228" "229" "230"
"231" "232" "236" "241" "242"
"243" "246"
> "247"
> [61] "249" "250" "252" "253"
"254" "255" "256" "257" "258"
"259" "260"
> "261"
> [73] "264" "286" "295" "296"
"298" "299" "300" "301" "303"
"304" "306"
> "307"
> [85] "308" "309" "311" "312"
"316" "348" "349" "352" "354"
"355" "356"
> "357"
> [97] "358" "359" "363" "367"
"370" "373" "374" "375" "376"
"377" "386"
> "387"
> [109] "391" "392" "393" "396"
"397" "398" "399" "400" "401"
"402"
> "403"
> "404"
> [121] "405" "406" "407" "408"
"409" "410" "411" "412" "413"
"414"
> "415"
> "416"
> [133] "417" "418" "419" "420"
"421" "422" "423" "424" "425"
"426"
> "427"
> "428"
> [145] "430" "431" "432" "433"
"434" "435" "439" "440" "441"
"442"
> "443"
> "445"
> [157] "446" "447" "453" "454"
"455" "460" "466" "475" "489"
"493"
> "494"
> "495"
> [169] "497" "498" "499" "501"
"502" "503" "504" "505" "506"
"507"
> "509"
> "510"
> [181] "511" "512" "513" "514"
"515" "516" "517" "518" "519"
"520"
> "521"
> "522"
> [193] "523" "524" "525" "526"
"527" "528" "529" "530" "531"
"533"
> "535"
> "536"
> [205] "537" "538" "539" "540"
"541" "543" "544" "545" "546"
"547"
> "548"
> "549"
> [217] "563" "567" "568" "569"
"570" "571" "572" "574" "575"
"577"
> "579"
> "580"
> [229] "581" "584" "587" "588"
"589" "590" "591" "592" "593"
"603"
> "604"
> "607"
> [241] "608" "609" "620" "622"
"623" "631" "632" "634" "637"
"640"
> "642"
> "647"
> [253] "649" "651" "652" "653"
"658" "659" "673" "674" "677"
"681"
> "682"
> "683"
> [265] "684" "685" "686" "697"
"698" "699" "702" "703" "704"
"705"
> "706"
> "708"
> [277] "710" "714" "715" "717"
"719" "720" "721" "722" "723"
"725"
> "727"
> "728"
> [289] "733" "735" "737" "738"
"744" "745" "746" "747" "750"
"751"
> "754"
> "763"
> [301] "766" "769" "770" "771"
"784" "785" "786" "787" "788"
"789"
> "790"
> "791"
> [313] "792" "802" "803" "804"
"805" "813" "818" "822" "826"
"827"
> "828"
> "829"
> [325] "830" "831" "832" "834"
"835" "837" "840" "841" "842"
"843"
>
> The same as this:
>
> [1] 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
> 116 117
> 118 119 120
> [22] 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
> 137
> 138 139 140 141
> [43] 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
> 158
> 159 160 161 162
> [64] 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
> 179
> 180 181 182 183
> [85] 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
> 200
> 201 202 203 204
> [106] 205
>
> Now besides the fact that the values and length is different, does
> that fact
> that there are quotes around each value change the way R deals with
> the
> values.  I am getting an error when i try and use the object that
> contains
> the first list's values.  The error is:
>
> Error in `[.data.frame`(TAZ_VAC_FEET, TAZ_VAC_FEET$TAZ ==
> Loc_Mod_TAZ,  :
>  (list) object cannot be coerced to type 'integer'
>
> Now the object Loc_Mod_TAZ would be equal to one of the first list
> values in
> a loop like:
> Candidates[i]=Loc_Mod_TAZ.  So again the question is does R treat
> these two
> lists the same.  Thanks and sorry i cant supply my code, it would
> require
> megs of data in order fo rit to work anyhow.  Thanks in advance.
>
> Cheers,
> JR
> --
> View this message in context:
http://www.nabble.com/Environment-change--tp21636186p21636186.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.