我试图读取重复行名称的csv文件,但不能.我得到的错误信息是Error in read.table(file = file, header = header, sep = sep, quote = quote, : duplicate 'row.names' are not allowed.
我使用的代码是:
S1N657 <- read.csv("S1N657.csv",header=T,fill=T,col.names=c("dam","anim","temp"))
Run Code Online (Sandbox Code Playgroud)
我的数据示例如下:
did <- c("1N657","1N657","1N657","1N657","1N657","1N657","1N657","1N657","1N657","1N657")
aid <- c(101,102,103,104,105,106,107,108,109,110)
temp <- c(36,38,37,39,35,37,36,34,39,38)
data <- cbind(did,aid,temp)
Run Code Online (Sandbox Code Playgroud)
任何帮助将不胜感激.
这类似于read.csv row.names和/sf/ask/869791961/,但我看不到有帮助的答案.
问题:尝试读取包含第一列中重复数字的文件,但在row.names = NULL时移动列标题.
我正在尝试将以下文件读入R中
TripId VID TspVID VWT VCLS Week
201110041426 2226 33889 1 0 41
201110041501 2226 33889 1 0 41
201110041510 2226 33889 1 0 41
201110041557 2226 33889 1 0 41
Run Code Online (Sandbox Code Playgroud)
(这是一个包含数千行和~200列的CSV文件的Excel摘录.第一行中的条目数和所有其他条目的条目数相同.第一行中有重复项. t与此视图中的标签对齐,但它们在CSV空间中.)
命令
> lm.table <- read.table(file= file.in, sep=",", header=TRUE)
Error in read.table(file = file.in, sep = ",", header = TRUE) :
duplicate 'row.names' are not allowed
Run Code Online (Sandbox Code Playgroud)
不起作用.对row.names使用第一列意味着第一行的值小于其他行,但实际情况并非如此.我当然不希望第一列作为row.names.
我尝试设置row.names = NULL
> lm.table <- read.table(file= file.in, sep=",", header=TRUE, row.names=NULL)
Run Code Online (Sandbox Code Playgroud)
哪个运行,但列已被移动 …
使用下面的代码,我设法绘制了它们
library(shiny)
library(leaflet)
stations <- read.csv("~path/stations.csv")
ui <- bootstrapPage(
tags$style(type = "text/css", "html, body {width:100%;height:100%}"),
leafletOutput("map", width = "100%", height = "100%"))
server <- function(input, output) {
output$map <- renderLeaflet({
leaflet(stations) %>%
addProviderTiles("Esri.WorldTopoMap") %>%
addCircleMarkers(~x,~y)
})
}
shinyApp(ui, server)
Run Code Online (Sandbox Code Playgroud)
这是结果
现在,在最终shiny应用程序中,我想.csv从保管箱读取文件。
library(repmis)
myfilename <- "stations.csv"
mykey <- "i9pw95ltjown2uc"
stations <- source_DropboxData(myfilename, key=mykey, sep=",", header=TRUE)
Run Code Online (Sandbox Code Playgroud)
我得到这个错误
source_DropboxData(myfilename,key = mykey,sep =“,”,header = TRUE)中的错误:未使用的参数(myfilename,key = mykey,sep =“,”,header = TRUE)
使用 …
这里我在R的问题:
mtable <- read.table(paste(".folder_1362704682.4574","/groups.txt",sep=""),sep="\t",comment.char='',skip=0, header=TRUE, fill=TRUE,check.names=FALSE)
Run Code Online (Sandbox Code Playgroud)
第一个文件夹部分或paste()通常由var包装,用于调试目的 - > static.
我总是得到这样的信息:
Error in read.table(paste(".frunc_1362704682.4574", "/groups.txt", sep = ""), :
duplicate 'row.names' are not allowed
Run Code Online (Sandbox Code Playgroud)
但是,如果我查看带有此标题的文件:
root_node_name node_name node_id #genes_in_root_node #genes_in_node #genes_with_variable=1_in_root_node #genes_with_variable=1_in_node raw_p_underrepresentation_of_variable=1 raw_p_overrepresentation_ of_variable=1 FWER_underrepresentation FWER_overrepresentation FDR_underrepresentation FDR_overrepresentation
Run Code Online (Sandbox Code Playgroud)
我看不到任何重复.. :(我在另一个关于我应该尝试的讨论中读到:
mtable <- read.table(paste(".frunc_1362704682.4574","/groups.txt",sep=""),sep="\t",comment.char='',skip=0, header=TRUE, fill=TRUE,check.names=FALSE,**row.names=NULL**)
Run Code Online (Sandbox Code Playgroud)
这很好用,但之后所有标题都向右移了一列:
> head(mtable, n=1)
row.names root_node_name node_name
1 molecular_function trans-hexaprenyltranstransferase activity GO:0000010
node_id #genes_in_root_node #genes_in_node
1 17668 2 2419
#genes_with_variable=1_in_root_node #genes_with_variable=1_in_node
1 0 0.74491
raw_p_underrepresentation_of_variable=1
1 1
raw_p_overrepresentation_of_variable=1 FWER_underrepresentation
1 1 1
FWER_overrepresentation FDR_underrepresentation …Run Code Online (Sandbox Code Playgroud)