0

So I've imported my data from excel as

Name <- read.csv("C:\\.......csv", header = TRUE, sep = ",")

and named a column of the excel file as a list in R as

Name of list <- c(unique(Name$NameofColumn)) which has worked for me numerous times before, except now, R is only reading new values, and completely ignoring repeat values. For example, if my excel column was: 3, 4, 3, 5, R reads it as 3, 4, 5

Miha
  • 2,559
  • 2
  • 19
  • 34
  • 4
    What is the purpose of the `unique()` in there? One way to describe what `unique` does would be "omit repeat values", so if you don't want to do that, maybe leave out the `unique()` part... at which point your `c()` probably isn't doing anything either, so you could just do `result = Name$NameofColumn` if all you want to do is pull out a single column. – Gregor Thomas Aug 06 '18 at 20:43
  • 1
    If you need more help than that, I'd encourage you to make a [small reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example), with a few lines of a CSV file and some R code that runs on it. – Gregor Thomas Aug 06 '18 at 20:44
  • I'd also encourage you to look deeper at your terminology so that you understand better (and can describe better) what is going on. Excel can export data and save it as a CSV, but CSV format is a very simple text file (*CSV:* comma separated values), whereas an Excel file is much more complicated. It's good to understand the difference. – Gregor Thomas Aug 06 '18 at 20:47

1 Answers1

0

As @Gregor mentioned, if you simply need to extract one of the columns as a list, then running
Name_of_list <- Name$NameofColumn
would yield the desired result. unique() will only return unique values of from the column

SmitM
  • 1,366
  • 1
  • 8
  • 14