separate columns and remove the letter t

Asked

Viewed 144 times

-2

data<-read.table("identified species.txt",header=T,Sep=",") dice Species........................ ... .com..... without

1 C. maculata t 1 T3

2 C. sanguinea t 26 t39

3 E. connexa t 20 T14

4 H. axyridis t 2 T7

5 H. convergens t 12 T37

6 T. bisquinquepustulata 74 T87

7 H. festiva t 65 t39

8 S. rubicundus t 50 T3

9 S. demerarensis t 10 T7

10 S. loewii t 4 T11

11 D. agapitus t 2 T3

12 D. seminulus t 15 t0 13 Sticholotidini\t 1\t0

  • I suggest even decrease the example table and leave a demonstration of what you expect to get

2 answers

2

Try to modify the separator. In your case, by output, the comma is not the column separator.

dados<-read.table("especies identificadas.txt",header=T,sep="\t")
  • By the way, colClasses = c("character", "numeric", "numeric") maybe it’s a good idea.

1

The problem is that by setting the " t" as a function parameter R recognizes it as a tab symbol (the popular "Tab" on the keyboard) and therefore does not recognize its tab. However, when typing " t" (so that it recognizes the metacharacter as text) o read.table does not accept, because the separator can only be one character. I made a modification in your file (if possible) replace the " t" with "|" and used the code:

dados <- read.table("especies_identificadas.txt", header = F, sep = "|")

Browser other questions tagged

You are not signed in. Login or sign up in order to post.