首页 \ 问答 \ 无法指定列名R.(Unable to assign column names R)

无法指定列名R.(Unable to assign column names R)

数据:

CODE                        MTH MAKE                   FAMILY                   VARIANT                        
1                    22  26 29  33                     56                       81                             
-------------------- --- -- --- ---------------------- ------------------------ ------------------------------ 
AUDA6-AL4930J7R2009C        Mar AUDI                   A6                       ALLROAD QUATTRO                
AUDA6-AL4930J7R2010A        Jan AUDI                   A6                       ALLROAD QUATTRO                
AUDA6-AL4930J7R2011A        Jan AUDI                   A6                       ALLROAD QUATTRO                
AUDA6-AL4F30GPJ2007E        May AUDI                   A6                       ALLROAD QUATTRO                
AUDA6-AL4F30GPJ2008A        Jan AUDI                   A6                       ALLROAD QUATTRO                
AUDA6-AL4F30GPJ2009A        Jan AUDI                   A6                       ALLROAD QUATTRO                

有人可以提供一些指导,因为我是编程新手。 我正在尝试使用read.fwf()按照以下代码阅读以下文件。 第一行应该是标题,但由于固定宽度,我无法做到这一点。

test <- read.fwf(file.choose(),
                 widths = c(21,4,3,4,23,25,31), fill = T)

然后我按照下面的代码将第一行保存为“标题”:

headings <- test[1,]

然后,我尝试将标题指定为根据列的名称

colnames(test) <- headings

虽然代码没有抛出错误,但我没有得到理想的结果,即colnames仍然显示为数字而不是名称。 等等


Data:

CODE                        MTH MAKE                   FAMILY                   VARIANT                        
1                    22  26 29  33                     56                       81                             
-------------------- --- -- --- ---------------------- ------------------------ ------------------------------ 
AUDA6-AL4930J7R2009C        Mar AUDI                   A6                       ALLROAD QUATTRO                
AUDA6-AL4930J7R2010A        Jan AUDI                   A6                       ALLROAD QUATTRO                
AUDA6-AL4930J7R2011A        Jan AUDI                   A6                       ALLROAD QUATTRO                
AUDA6-AL4F30GPJ2007E        May AUDI                   A6                       ALLROAD QUATTRO                
AUDA6-AL4F30GPJ2008A        Jan AUDI                   A6                       ALLROAD QUATTRO                
AUDA6-AL4F30GPJ2009A        Jan AUDI                   A6                       ALLROAD QUATTRO                

Could someone please provide some guidance as I am new to programming. I am trying to read the following file using read.fwf() as per the code below. The first row should be headers but because of the fixed width, I am unable to do that.

test <- read.fwf(file.choose(),
                 widths = c(21,4,3,4,23,25,31), fill = T)

I then take the first row and save it as "headings" as per the code below:

headings <- test[1,]

I then try to assign the headings as the colnames as per

colnames(test) <- headings

whilst the code doesn't throw an error, I dont get the desired result i.e the colnames are still showing as numbers rather than the names. etc.


原文:https://stackoverflow.com/questions/31824435
更新时间:2024-01-27 11:01

最满意答案

虽然DocumentDB允许您存储文件(它们存储为附件),但我不建议使用它。 以下是我的理由:

  • 在当前版本中,附件的最大大小为2 MB。
  • 你无法真正流式附件。 您需要先阅读应用程序中的附件内容并从此处进行流式传输。

为了将文件存储在Azure中,我强烈建议您使用Blob Storage 。 它只是为了这个目的。 您可以在BLOB存储中存储的最大文件大小为1 TB(我认为这对您来说已经足够了),每个存储帐户最多可以容纳500 TB的数据。 此外,您可以直接将文件传输到最终用户。


Though DocumentDB allows you to store files (they are stored as attachments), I would not recommend using it. Here are my reasons:

  • In the current version, the maximum size of an attachment is 2 MB.
  • You can't really stream attachments. You would need to first read the attachment contents in your application and stream it from there.

For storing files in Azure, I would highly recommend that you use Blob Storage. It is meant for that purpose only. Maximum size of a file that you can store in blob storage is 1 TB (which I would assume would be more than sufficient for you) and each storage account could hold up to 500 TB of data. Furthermore you can directly stream files to your end users.

相关问答

更多
  • 加密/解密过程对最终用户是透明的。 因此,当平台处理加密/解密时,您永远不会看到加密数据。 它在静止时仍然是加密的(因此@jaxidian提到了)。 The encryption/decryption process is transparent to the end user. Thus, you never see the encrypted data as the platform handles the encryption/decryption. It is still encrypted at ...
  • 有一个容量规划器计算器,您可以在其中上传样本文件,指定收集的文档数量并获得总收集大小的估计值。 集合大小基于原始JSON文档计算,不应用任何压缩。 因此,它或多或少等同于硬盘驱动器上文档的磁盘大小。 Cosmos DB还会为每个文档+辅助索引添加一些字段,如_ts ,因此总大小可能会高一些。 如果需要任何压缩,则需要在应用程序中执行此操作(例如,创建一个包含10,000个数字的压缩数组的JSON编码二进制字段)。 There is a capacity planner calculator where yo ...
  • SQL Data Sync仅在SQL Azure数据库和SQL Server实例之间同步数据。 不支持SQL Azure数据仓库。 https://docs.microsoft.com/en-us/azure/sql-database/sql-database-sync-data 希望这可以帮助。 问候, Alberto Morillo SQL Data Sync synchronizes data between SQL Azure Databases and SQL Server instances o ...
  • 文档数据库提供了Azure搜索没有的一致性保证。 一般来说,我们不建议使用Azure Search作为主要商店。 有关具体警告,请参阅我对此其他SO问题的回答: 可以将Azure Search用作某些数据的主数据库吗? Document DB provides consistency guarantees that Azure Search does not. In general we don't recommend using Azure Search as a primary store. See m ...
  • 此请求背后的业务要求是什么? 1 - 您是否在数据库1中有一些参考数据并希望将该数据复制到数据库2? 如果是这样,那么如果您在同一个逻辑服务器中,则使用跨数据库查询。 有关详细信息,请参阅我的文章 。 2 - 您是否可以在不同的区域拥有数据库的副本? 如果是这样,请使用活动地理复制来保持数据库同步。 有关详细信息,请参阅我的文章 。 3 - 如果您只需要复制几个表并且数据量很低,那么只需编写一个简单的PowerShell程序(工作流)来从源代码加载目标。 在您选择的时间安排Azure Automation中 ...
  • 您可以配置redis缓存诊断以获取此信息。 有关更多详细信息,请参阅How to monitor Azure Redis Cache - Available metrics and reporting intervals 。 通过此链接,我相信您正在寻找的其中一个可用指标是“ Used Memory ”。 已用内存在指定的报告间隔期间用于缓存中的键/值对的缓存内存量(以MB为单位)。 此值映射到Redis INFO命令中的used_memory。 这不包括元数据或碎片。 我没有亲自使用REDIS Cache ...
  • Service Fabric可以创建无状态和有状态的微服务。 顾名思义,如果一个无状态服务实例维护的任何状态将在节点停止运行时丢失。 一个新的,新鲜的实例将简单地在集群中的其他地方转移。 有状态服务提供了在不依赖外部存储的情况下坚持状态的能力。 存储在Reliable Collection中的任何数据都将自动复制到集群中的多个节点上,确保该状态对故障具有恢复能力。 一种常见的模式是使用无状态服务作为应用程序的面向客户端的网关,然后让该服务将流量引导至应用程序的分区有状态服务。 这隐藏了从客户端解析分区的工作 ...
  • 虽然DocumentDB允许您存储文件(它们存储为附件),但我不建议使用它。 以下是我的理由: 在当前版本中,附件的最大大小为2 MB。 你无法真正流式附件。 您需要先阅读应用程序中的附件内容并从此处进行流式传输。 为了将文件存储在Azure中,我强烈建议您使用Blob Storage 。 它只是为了这个目的。 您可以在BLOB存储中存储的最大文件大小为1 TB(我认为这对您来说已经足够了),每个存储帐户最多可以容纳500 TB的数据。 此外,您可以直接将文件传输到最终用户。 Though Document ...
  • Azure Diagnostics是一个很好的起点。 您可以添加任何您喜欢的性能计数器:内存消耗,CPU使用率等。 在Azure项目中右键单击您的角色,然后转到“属性”。 在配置下,您将看到“诊断” 勾选“启用诊断”并选择“自定义计划” - >“编辑” 在Performance Counters下选择你想要的(请注意,如果你的机器上有不同的语言,它必须是计数器的英文名称) 这些计数器将保存在表格名称“WADPerformanceCounters”下的表存储中 本文也许有帮助: http : //msdn.m ...
  • 关于第一个问题,答案是:这取决于。 你如何以及在哪里举办web api。 在IIS? 在Azure上? 使用自托管? 根据此处的文档https://docs.microsoft.com/en-us/azure/application-insights/app-insights-monitor-performance-live-website-now这些是您的选择: 您可以使用Azure Application Insights检测实时Web应用程序,而无需修改或重新部署代码。 在您的应用程序由本地IIS服务 ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)