Reputation: 7659
I read a data.frame from an sqlite table:
sql <- paste( "SELECT co_id, co_name, mkt_id FROM co" )
co <- dbGetQuery( db, sql )
and get a valid result (it seems):
ls( co )
[1] "co_id" "co_name" "mkt_id"
I then subset some data:
x <- co[ co$mkt_id == 5, 2 ]
x
[1] "Dongbu" "Green" "Hanwha" "Heungkuk" "Hyundai" "LIG"
[7] "Lotte" "Meritz" "Samsung" "KFCC" "NCUF" "NACF"
Having difficulties assigning this variable x
to a gcombobox
, I was trying to find the reason and (this being the reason or not) found:
ls( x )
Error in as.environment(pos) : no item called "Dongbu" on the search list
Can somebody explain what this means? Shouldn't x
be an ordinary vector, and "Dongbu" just be the first element?
sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] grid stats graphics grDevices utils datasets methods
[8] base
other attached packages:
[1] gWidgetsRGtk2_0.0-81 RSQLite_0.11.2 DBI_0.2-5
[4] stringr_0.6.1 gWidgets_0.0-52 xtable_1.7-0
[7] gridExtra_0.9.1 ggplot2_0.9.2.1
loaded via a namespace (and not attached):
[1] colorspace_1.1-1 dichromat_1.2-4 digest_0.5.2 gtable_0.1.1
[5] labeling_0.1 MASS_7.3-22 memoise_0.1 munsell_0.4
[9] plyr_1.7.1 proto_0.3-9.2 RColorBrewer_1.0-5 reshape2_1.2.1
[13] RGtk2_2.20.25 scales_0.2.2 tools_2.15.2
Upvotes: 0
Views: 636
Reputation: 81733
The first argument of the ls
function, name
, specifies the name of the environment. In General, this function is used to list the object in the specified environment.
If you run this function with x
as first argument, the function looks for the environment "Dongbu"
, which is the first string in x
, but fails to find the environment.
If you want to have a look of the structure of an object, you should use the str
function. Try str(x)
.
Upvotes: 1