Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error reading dataset in R

Tags:

r

igraph

I have problem in reading a dataset

My code :

require(igraph)
g <- graph(c(0, 1, 1, 2, 2, 0, 1, 3, 3, 4, 
               4, 5, 5, 3, 4, 6, 6, 7, 7, 8, 
               8, 6, 9, 10, 10, 11, 11, 9))

Error :

Error in graph(c(0, 1, 1, 2, 2, 0, 1, 3, 3, 4, 4, 5, 5, 3, 4, 6, 6, 7,  : 
  At structure_generators.c:84 : Invalid (negative) vertex id, Invalid vertex id
like image 386
Jo_bast Avatar asked Dec 22 '13 14:12

Jo_bast


People also ask

How do I read a dataset in R?

The default R datasets included in the base R distribution Simply check the checkbox next to the package name to load the package and gain access to the datasets. You can also click on the package name and RStudio will open a help file describing the datasets in this package.

Why does R say Object not found?

6.2 Error: object not foundThis error usually occurs when your R Markdown document refers to an object that has not been defined in an R chunk at or before that chunk. You'll frequently see this when you've forgotten to copy code from your R Console sandbox back into a chunk in R Markdown.

How do I read a file in RStudio?

In RStudio, click on the Workspace tab, and then on “Import Dataset” -> “From text file”. A file browser will open up, locate the . csv file and click Open.

Which of the following are examples of variable names that can be used in R Select all that apply?

Examples of variable names that can be used in R are autos_5 and utility2. Variable names should start with a letter and can also contain numbers and underscores.


1 Answers

The problem seems to be vertex of name 0

yourgraph <- c(0, 1, 1, 2, 2, 0, 1, 3, 3, 4, 
               4, 5, 5, 3, 4, 6, 6, 7, 7, 8, 
               8, 6, 9, 10, 10, 11, 11, 9)

g <- graph(yourgraph + 1)
like image 127
user1317221_G Avatar answered Sep 22 '22 23:09

user1317221_G