Data vs Values in Global environment in R??

rstudio
#1

Dear all

Anyone has the idea what is the difference between data file in "data" and file in "values" in the global environment R programming? i tried to import an excel data into R and use certain package for further analysis, but the file name "noges" i created couldn't be used for analysis??(i followed exactly some tech guru techniques they showed me...datapasta & reprex packages to create "noges")

Noges is located in the top right corner of the Rstudio "Global Environment" window

guess i need to do something further before i change the Noges file in "Values" and bring it into the "Data" universe?

i would be very appreciated if someone can help...

Best

Achan_k

0 Likes

#2

here is the attchaced..

Noges.PNG

0 Likes

#3

What you see on that pane are objects loaded in memory, not files, and the difference is that the objects listed under "data", are any sort of dataframe (included tibbles, data.table, etc), and the ones listed under "values" are, lists, vectors of some class, matrices, etc.

Those "techniques" are for creating a reproducible example, not for loading your data, and by the way, we are going to need a reproducible example in order to help you any further, so please read this FAQ and try to make one.

0 Likes

#4

thank you so much for your reply andresrcs

to make it simple, is there any way or function to convert objects in "values" to "objects in "data" in data frame format?

Best

0 Likes

#5

Yes, there are many ways, but which one to use depends on the specific structure of your data, that is why we are asking you for a reproducible example.

Also, if you load your data properly you shouldn't have to convert anything, it should be already on a dataframe format.

0 Likes

#6

Dear andresrcs

here is the first 10 lines or so in my reprex, please let me know if I can do anything, many thanks

Best

noges <- tibble::tribble(
~bbgid, ~name, ~sector, ~portfolio, ~benchmark, ~date, ~return, ~country,
"6869 HK", "YOFC-H", "Information Technology", 0, 6e-04, "1/31/2018", 0.0111, "CN",
"YZJSGD SP", "YANGZIJIANG SHIP", "Industrials", 0, 0.002, "1/31/2018", 0.0884, "CN",
"YLLG SP", "YANLORD LAND GRO", "Real Estate", 0, 7e-04, "1/31/2018", 0.142, "SG",
"200869 CH", "YANTAI CHANGYU-B", "Consumer Staples", 0.0071, 4e-04, "1/31/2018", 0.0467, "CN",
"1230 HK", "YASHILI INT'L", "Consumer Staples", 0.013, 2e-04, "1/31/2018", 0.0133, "CN",
"YINGLI SP", "YING LI INTERNAT", "Real Estate", 0.0629, 1e-04, "1/31/2018", 0.0331, "SG",
"123 HK", "YUEXIU PROPERTY", "Real Estate", 0.0101, 0.001, "1/31/2018", 0.1507, "HK",
"1052 HK", "YUEXIU TRANSPORT", "Industrials", 0.0399, 4e-04, "1/31/2018", 0.0017, "HK",
"1628 HK", "YUZHOU PROPERTIE", "Real Estate", 0.0013, 8e-04, "1/31/2018", 0.3861, "CN",
"ZTO US", "ZTO EXPRESS -ADR", "Industrials", 0.0084, 0.0018, "1/31/2018", -0.0025, "CN",
"576 HK", "ZHEJIANGEXPRE-H", "Industrials", 0.0287, 0.0013, "1/31/2018", 0.078, "CN",
"900915 CH", "ZHONGLU CO LTD-B", "Consumer Discretionary", 0, 1e-04, "1/31/2018", 0, "CN",
"881 HK", "ZHONGSHENG GROUP", "Consumer Discretionary", 0, 0.0012, "1/31/2018", 0.102, "CN",
"1458 HK", "ZHOU HEI YA INTE", "Consumer Staples", 0.0309, 7e-04, "1/31/2018", -0.0463, "CN",
"3898 HK", "ZHUZHOU CRRC T-H", "Industrials", 0, 0.0021, "1/31/2018", -0.1485, "CN",
"1157 HK", "ZOOMLION HEAVY-H", "Industrials", 0, 4e-04, "1/31/2018", 0.0209, "CN",
"KANG US", "IKANG HEALTH-ADR", "Health Care", 0, 3e-04, "1/31/2018", 0.0196, "CN"
)
head(noges)
#> # A tibble: 6 x 8
#> bbgid name sector portfolio benchmark date return country
#>
#> 1 6869 HK YOFC-H Information~ 0 0.000600 1/31/~ 0.0111 CN
#> 2 YZJSGD~ YANGZIJIA~ Industrials 0 0.002 1/31/~ 0.0884 CN
#> 3 YLLG SP YANLORD L~ Real Estate 0 0.0007 1/31/~ 0.142 SG
#> 4 200869~ YANTAI CH~ Consumer St~ 0.0071 0.0004 1/31/~ 0.0467 CN
#> 5 1230 HK YASHILI I~ Consumer St~ 0.013 0.0002 1/31/~ 0.0133 CN
#> 6 YINGLI~ YING LI I~ Real Estate 0.0629 0.0001 1/31/~ 0.0331 SG

0 Likes

#7

Well, that is not actually a reprex, is just sample data and is already on a dataframe format, so it seems like you have solved your own problem already.

noges <- tibble::tribble(
    ~bbgid, ~name, ~sector, ~portfolio, ~benchmark, ~date, ~return, ~country,
    "6869 HK", "YOFC-H", "Information Technology", 0, 6e-04, "1/31/2018", 0.0111, "CN",
    "YZJSGD SP", "YANGZIJIANG SHIP", "Industrials", 0, 0.002, "1/31/2018", 0.0884, "CN",
    "YLLG SP", "YANLORD LAND GRO", "Real Estate", 0, 7e-04, "1/31/2018", 0.142, "SG",
    "200869 CH", "YANTAI CHANGYU-B", "Consumer Staples", 0.0071, 4e-04, "1/31/2018", 0.0467, "CN",
    "1230 HK", "YASHILI INT'L", "Consumer Staples", 0.013, 2e-04, "1/31/2018", 0.0133, "CN",
    "YINGLI SP", "YING LI INTERNAT", "Real Estate", 0.0629, 1e-04, "1/31/2018", 0.0331, "SG",
    "123 HK", "YUEXIU PROPERTY", "Real Estate", 0.0101, 0.001, "1/31/2018", 0.1507, "HK",
    "1052 HK", "YUEXIU TRANSPORT", "Industrials", 0.0399, 4e-04, "1/31/2018", 0.0017, "HK",
    "1628 HK", "YUZHOU PROPERTIE", "Real Estate", 0.0013, 8e-04, "1/31/2018", 0.3861, "CN",
    "ZTO US", "ZTO EXPRESS -ADR", "Industrials", 0.0084, 0.0018, "1/31/2018", -0.0025, "CN",
    "576 HK", "ZHEJIANGEXPRE-H", "Industrials", 0.0287, 0.0013, "1/31/2018", 0.078, "CN",
    "900915 CH", "ZHONGLU CO LTD-B", "Consumer Discretionary", 0, 1e-04, "1/31/2018", 0, "CN",
    "881 HK", "ZHONGSHENG GROUP", "Consumer Discretionary", 0, 0.0012, "1/31/2018", 0.102, "CN",
    "1458 HK", "ZHOU HEI YA INTE", "Consumer Staples", 0.0309, 7e-04, "1/31/2018", -0.0463, "CN",
    "3898 HK", "ZHUZHOU CRRC T-H", "Industrials", 0, 0.0021, "1/31/2018", -0.1485, "CN",
    "1157 HK", "ZOOMLION HEAVY-H", "Industrials", 0, 4e-04, "1/31/2018", 0.0209, "CN",
    "KANG US", "IKANG HEALTH-ADR", "Health Care", 0, 3e-04, "1/31/2018", 0.0196, "CN"
)

class(noges)
#> [1] "tbl_df"     "tbl"        "data.frame"

Created on 2019-02-16 by the reprex package (v0.2.1)

1 Like

closed #8

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.

0 Likes