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
0
votes
1 answer

Massive text file to be read into R

so the story is i have a 30 gig txt file that need to be read into R, it contains two cols and about 2 billion rows of integers! I dont want to load the whole thing in one go, sizeable chunks will suffice. I've tried using read.table with arguments…
David
  • 326
  • 1
  • 11
0
votes
1 answer

How to make R read data separated by "|**|"

I have a large data set, which variables are separated by the symbol of |**|. I've tried to use sep="|", but this did not work when the one of the string variables containing |. How can I make R to read data with compound separator?
Nhuhe
  • 13
  • 1
0
votes
0 answers

How to read and structure txt files from rows, then assign them as variables to columns?

I have a problem in structuring a txt dataset, which is about the news from different fields and time, looking like this: court agrees to expedite n.f.l.'s appeal the decision means a ruling could be made nearly two months before the regular…
0
votes
1 answer

SAS' MISSOVER for data input in R

I've got a data file A with 7 columns, no missing values, to which I've unix-joined a data file B that has 28 fields. The result file is C. If no match is found in B, then the output row in C only has 7 columns. If there is a match in B, then the…
user2105469
  • 1,413
  • 3
  • 20
  • 37
0
votes
0 answers

read.csv counts from first column, read.table and read.delim count from second column?

I'm totally new to R. I have a few scripts that read data from .cvs files to plot them. They read the complete table and plot the data in a particular column (e.g. column 6): tablecsv <- read.csv("myfile.csv", header=TRUE) plot.values_csv <-…
ThisIsMe
  • 3
  • 3
0
votes
1 answer

r - need help converting table to matrix

I'm new to R and I'm having trouble understanding what all the parameters in read.table() do. I have a text file with a header, and roughly 50 rows. Columns are separated by tabs. I did the following. data <-…
Yuen Hsi
  • 143
  • 1
  • 4
  • 11
0
votes
0 answers

R : read.table() not fetching the results when i run with large data set

I am running the below command where there are like 5572457 rows. The tempField$Lat column has data separated by comma and I want this data in different columns in a data frame. The logic is running fine for 50000 rows which is the sample load i am…
Ankit Solanki
  • 670
  • 2
  • 9
  • 23
0
votes
3 answers

How to display a dataframe with separators in R?

I have a dataframe where some columns contain levels with spaces. When I call the dataframe and copy paste the result into read.table(text="") it doesn't work because there is an unequal number of spaces in different rows. So how to do a clean…
Wicelo
  • 2,358
  • 2
  • 28
  • 44
0
votes
2 answers

R, Read in characters as numeric in one step using read.csv?

I am reading a .csv into R with several different variable types two of which are read in as characters although they are numeric (latitude and longitude in decimal degrees). To work around this, I define them "as.numeric" after reading them in. Is…
seapen
  • 345
  • 1
  • 4
  • 13
0
votes
1 answer

Read only select columns with read.table when number of columns is unknown

I want to read in the first 3 columns from many files where I don't necessarily know the number of columns each file contains. Additionally, I don't exactly know the number of lines to skip in each file, though it won't be more than 19 before the…
Jota
  • 17,281
  • 7
  • 63
  • 93
0
votes
1 answer

When using read.table in r, r gives some blank cells NA values and leaves others blank. Is something wrong?

I am reading a csv file into r (with the blank.lines.skip=T option). It has some character,numeric, and factor variables. When r reads the file in, some cells are given NA's while others are left blank. It appears that only columns with all…
user27008
  • 600
  • 3
  • 15
  • 24
0
votes
2 answers

R read.table columns shifted to the left

I created a file called test2.txt with the following information: col1 col2 col3 col4 1 A B 2 A B 3 A B 4 A B 5 A B 6 A B 7 A C 8 A C When reading with the following…
egor.ananyev
  • 347
  • 4
  • 9
0
votes
1 answer

read.table error: Same data file but column numbers do not match

I want to assign column names for a data table that I read from a file, but I get an error message that doesn't quite make sense to me. This is an excerpt from the data file: HEADER SPOT GRID TOP LEFT BOT RIGHT ROW COL CH1I CH1B …
user2015601
0
votes
2 answers

R - rbind transposing single column matrix

I'm pretty new to R, but it seems that this is a specific problem to which I have not been able to find an answer. My program reads in some data, then rbinds certain columns of that data to one of several data frames based on a vector of column…
0
votes
2 answers

extract row numbers of interesecting elements

I do have two table. I want to extract a single colum from the second table and past it into the first table. The problem is that not all rows of the colum of the second table should be copied but that only those are copied whose first colum matches…
Tim Heinert
  • 179
  • 3
  • 6
  • 11