this maybe a very simple issue, but i cannot seem to path through it. When i try to load a file i have in my directory, by assigning "Q1", it creates a Value Q1 = data.US and a weird name in the Data tab data.US where the actual table is reflected.
这可能是一个非常简单的问题,但我似乎无法通过它。当我尝试加载我目录中的文件时,通过指定“Q1”,它会在Data选项卡data.US中创建一个值Q1 = data.US和一个奇怪的名称,其中反映了实际的表。
Q1 <- load(file = "data_all_2011Q1.RData" )
Q1 < - load(file =“data_all_2011Q1.RData”)
My expectation would be that the table will be loaded into Data Workstation with name Q1.
我的期望是该表将被加载到名为Q1的Data Workstation中。
1 个解决方案
#1
0
.RData
files store R objects, together with their names. You can see here that load
returns a list of names of variables that are loaded. Therefore your object Q1
only contains "data.US"
, because that is the name of the object in the .RData
file. The data.US
object is created in your environment because that is the object stored in the .RData
file.
.RData文件存储R对象及其名称。您可以在此处看到load返回已加载变量的名称列表。因此,对象Q1仅包含“data.US”,因为这是.RData文件中对象的名称。 data.US对象是在您的环境中创建的,因为它是存储在.RData文件中的对象。
It is better to use .RDS
files for storing single objects. See the following example:
最好使用.RDS文件来存储单个对象。请参阅以下示例:
x <- c(1,2,3)
save(x,file='x.RData')
rm('x')
y<-load('x.RData')
# object y does not contain our vector x, it just contains the name of that variable: "x".
# However, our object x is loaded into our environment.
x <- c(1,2,3)
saveRDS(x,file="x.RDS")
rm('x')
y<-readRDS('x.RDS')
# object y contains our vector x, as desired.
#1
0
.RData
files store R objects, together with their names. You can see here that load
returns a list of names of variables that are loaded. Therefore your object Q1
only contains "data.US"
, because that is the name of the object in the .RData
file. The data.US
object is created in your environment because that is the object stored in the .RData
file.
.RData文件存储R对象及其名称。您可以在此处看到load返回已加载变量的名称列表。因此,对象Q1仅包含“data.US”,因为这是.RData文件中对象的名称。 data.US对象是在您的环境中创建的,因为它是存储在.RData文件中的对象。
It is better to use .RDS
files for storing single objects. See the following example:
最好使用.RDS文件来存储单个对象。请参阅以下示例:
x <- c(1,2,3)
save(x,file='x.RData')
rm('x')
y<-load('x.RData')
# object y does not contain our vector x, it just contains the name of that variable: "x".
# However, our object x is loaded into our environment.
x <- c(1,2,3)
saveRDS(x,file="x.RDS")
rm('x')
y<-readRDS('x.RDS')
# object y contains our vector x, as desired.