How do I get a value from a cell in R?

Asked

Viewed 79 times

5

I imported my data that was in a spreadsheet from Excel to the R, by placing them in a variable called umParticipante.

However, when I make the following code:

umParticipante.nome <- umParticipante[5,1]
print(umParticipante.nome)

Him printa:

# A tibble: 1 x 1
  ..1                          
  <chr>                        
1 Subject name: fulano

But I wish that umParticipante.nome were left with only the string corresponding to the name of the participant. In this case, I would like the code print(umParticipante.nome) return fulano.

How can I do that?

1 answer

4


Use the argument drop = TRUE.

The code should look like this:

umParticipante[5, 1, drop = TRUE]

Explanation:

When you pass the argument drop = TRUE, R turns the result into a vector and will stay the way you expect.

If you don’t pass the argument drop, or pass drop = FALSE, the result is transformed into a new tibble with only one row and column.

Browser other questions tagged

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