0

I have a csv file with 28 columns and 1000 rows.

I want to assign a specific set of columns to a vector, in order to analyze that vector in further steps.

The question is:

How can I define the columns to be stored in the vector?

What I have done is:

carbo2 <- carbo[,-4,-5,]
#or
carbo2 <- carbo[,c(-4,-5),]

In some cases, those command lines work almost well. But, when I print those vectors, I find that some columns, that I do not want, were assigned.

Cath
  • 23,906
  • 5
  • 52
  • 86
Another.Chemist
  • 2,386
  • 3
  • 29
  • 43
  • If you want them as a vector then `c(iris$Sepal.Length, iris$Petal.Length)`...? – Sotos Dec 13 '17 at 15:51
  • Or to exclude them: `iris[, -c(4,5)]` – pogibas Dec 13 '17 at 15:52
  • 2
    May worth reading about ranges and subset in R ... carbo[,-(4:5)] should do, there's nothing like 3 dimension subset for a vector, a vector has only one dimension, I assume you're talking about a dataframe here. – Tensibai Dec 13 '17 at 15:52
  • 2
    What is `carbo[,-4,-5,]` supposed to mean? What are you trying to do exactly? It's much easier to help you if you provide a [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with some sample input and desired output. – MrFlick Dec 13 '17 at 15:53

0 Answers0