0 votes
1 view
in R Programming by (5.3k points)

I want to make the equivalent of a python dict in R. Basically, in python I have:

visited = {}

if atom_count not in visited:

  Do stuff

  visited[atom_count] = 1

The idea is, if I saw that specific, atom_count, I have visited[atom_count] = 1. Thus, if I see that atom_count again, i don't "Do Stuff". Atom_Count is an integer.

Thanks!

1 Answer

0 votes
by (25.3k points)

For a dictionary in R, you can use the list data structure. You can set the names of the elements of a list using the names() function set equal to a vector of names.

For example:

l <- list(A = 5,B = "hello",C = 1:10)

> l

$A

[1] 5

$B

[1] "hello"

$C

 [1]  1  2  3  4  5  6  7  8  9 10

Related questions

0 votes
1 answer
asked Jul 10 in Python by Sammy (47.7k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...