Questions tagged [read.table]

read.table is basic R function which reads a file in table format and creates a data frame from it, with cases corresponding to lines and variables to fields in the file.

read.table is basic R function which reads a file in table format and creates a data frame from it, with cases corresponding to lines and variables to fields in the file. It is the most convenient way to read in a rectangular grid of data.

Because of the many possibilities, there are several other functions that call read.table but change a group of default arguments. Convenience functions read.csv and read.delim provide arguments to read.table appropriate for CSV and tab-delimited files exported from spreadsheets in English-speaking locales. The variations read.csv2 and read.delim2 are appropriate for use in those locales where the comma is used for the decimal point and (for read.csv2) for spreadsheets which use semicolons to separate fields.

See also The R Data Import/Export manual.

567 questions
-1
votes
1 answer

Read and write data.frames in the correct way

my problem is very simple, I have a file which contains plenty of tweet one per row not surrounded by quotes. After reading the file I created "dataset", to randomize it and to eliminate duplicates: dataset <- read.table(file, header=FALSE,…
Tunarock
  • 127
  • 1
  • 1
  • 12
-1
votes
1 answer

R data frame with doubly subscripted variables x[,1]

How can I create a data.frame with some variables x,y and a doubly subscripted variables z[,1],z[,2]? Here is my code : n = 10 x = rnorm(n,0) y = rnorm(n,0) z1 = rnorm(n,0) z2 =…
Math
  • 1,274
  • 3
  • 14
  • 32
-1
votes
1 answer

Write multiple TXT files to Excel in R

I have over 100 txt files that were the output of a SQL scrape across 100 different schemas and tables. The files as tabular data, pipe delimited. All of the column names in each text file are different. Once I loaded the files into a directory I…
Zach
  • 1,316
  • 2
  • 14
  • 21
-1
votes
1 answer

R Read.table: sep when there are more than 1 occurence

I have a big list of the format Variable = Value. 99% of the list is in this format. However, very few entries need to have a = within the value part. So they look like Variable = Value = something So my read.table function throws an error: Error in…
MichiZH
  • 5,587
  • 12
  • 41
  • 81
-2
votes
1 answer

Upload data in string format in R

How is it possible to import data in R in format string? I have tried with read.csv and read.table but it is uploaded as a character, and I need it as a string
Sss
  • 427
  • 2
  • 8
-2
votes
1 answer

Extracting columns from a text file after neglecting few lines of text in starting of the text file

I need to access the data in the columns from a text file having name "Apure.asc". I cannot use the read.table or read.csv on it because it contains some extra text in it in the starting which makes it hard for R to open it as a table or a csv file.…
-3
votes
2 answers

Reading multiple .dat files as a list and saving as .RDATA files in R

I want to import multiple .DAT files from a directory and make them as a list elements and then save them as .RDATA files. I tried the following code files <- dir(pattern = "*.DAT") library(tidyverse) Data1 <- files %>% map(~ read.table(file…
MYaseen208
  • 22,666
  • 37
  • 165
  • 309
-4
votes
2 answers

Too many errors in R program

I have just started studying R in second sem of my undergrad. It is hard to figure a lot of things here. I hope if you can point me in right direction? Initially I was not sure why require lines were giving error, then i figured that they were…
Nikita
  • 11
-4
votes
1 answer

Import data in separate columns in R

I have a text file to import the data from, and I want to read it in 3 columns, but the data only imports one. The file is pretty big, and there are no . or , involved. Some of the data are made from more than one word in succession, so I can't…
-4
votes
3 answers

Average column in daily information at every n-th row

I am very new on R. I have daily observations of temperature and PP for 12-year period (6574 row, 6col, some NA ). I want to calculate, for example, the average from 1st to 10thday of January-2001, then 11-20 and finally 21 to 31 and so on for every…
Guisseppe
  • 3
  • 4
-4
votes
2 answers

capture text output as structured data frame

I have output streamed as text in the following form: [2] "TWS OrderStatus: orderId=12048 status=PreSubmitted filled=0 remaining=300 averageFillPrice=0 " [3] "TWS OrderStatus: orderId=12049 status=PreSubmitted …
kalka
  • 3
  • 4
-4
votes
1 answer

dist in R can only handle data frames, vectors, matrices, and lists

I am trying to run this code to get a hierarchical clustering on the gun point dataset from UCR Time Series database. However I encounter this error. Any help? library(dtw) set.seed(6218) n <- 10 sc <-…
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
1 2 3
37
38