0

So I use SGA tools for processing my images. It gives back results in .dat files. Now in order to work on this data in R, I tried to import the .dat file using the haven package. I installed haven and then its library, but I am not able to import data still and it gives this error message.

Error: Failed to parse C:/Users/QuRana/Desktop/SGA Tools/Plate_Image_Example (1).dat: This version of the file format is not supported.

When I use this command install.packages("haven"), haven is loaded, but then when I load library using library(haven) nothing appears on my console except for this

> library(haven)

Then when I use this code:

datatrial1 <- read_dta("C:/Users/QuRana/Desktop/SGA Tools/Plate_Image_Example (1).dat") 

It gives me the error mentioned above. When I try converting my .dat file to a .csv file and load my data, the imported data adds additional "t" values before the values in columns except for the first one like this:

Flags: S - Colony spill or edge interference                                          C - Low colony circularity
# row\tcol\tsize\tcircularity\tflags                                                                              
1\t1\t4355\t0.9053\t                                                                                              
1\t2\t4456\t0.8401\t                                                                                              
1\t3\t3439\t0.8219\t                                                                                              
1\t4\t3215\t0.8707\t

All the t's before the numeric values are not what I want. Another issue that I am facing is I cannot install the gitter package on my R version which is R 4.2.2.

Shawn Hemelstrand
  • 2,676
  • 4
  • 17
  • 30
  • 2
    The `read_dta` function from haven is for reading Stata DTA files. Not sure why you think this the right function to read you `dat` file. With the `\t` used as separator this looks more like a `tsv` file. Maybe you should try with `read.tsv` or `readr::read_tsv` – stefan Feb 01 '23 at 22:27
  • Dear Stefan I was able to produce a csv function which worked to import data but the problem oh having "/t" still persists. I am new to R so i apologize if my questions look stupid to you. do you have any idea how to import data using read.csv function without the /t. i tried read.delim as Mike told mw but it omits rows after 200th row saying [ reached 'max' / getOption("max.print") -- omitted 184 rows ] – Qurrat ul ain Rana Feb 02 '23 at 04:55
  • From the message I would get guess that you just hit the `max.print` limit when printing your data. Use `datatrial1 <- read_delim(...)` to assign the read data to a variable. When your are using Rstudio you could then do `View(datatrial1)` to have a look at the data or use `str(datatrial1)` to get a compact description of the data which will include the number of rows. – stefan Feb 02 '23 at 06:49

1 Answers1

0

You can read your tab separated file like so `read.delim("file_path", header = TRUE, sep = "\t")

mike
  • 11
  • 3
  • Dear Mike I tried getting it in csv file so read.csv imports data but it still has /t in the 2nd 3rd and 4th row. read.delim worked excellently but the problem is it only imports first 200 rows and the remaining 184 are omitted and thats the message which i get "[ reached 'max' / getOption("max.print") -- omitted 184 rows ]" any idea how to work around it – Qurrat ul ain Rana Feb 02 '23 at 04:58
  • That's just for printing. If you do dim(your_object_name), it will show number of rows and columns. Should be the entire file. – mike Feb 02 '23 at 16:34