0

Question: based on data table I got a column name xyz and in that column I want to drop student from “outstate” in “xyz” column, than save the column to “ppp”

PPP <- data[code here, ]
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
  • 3
    Hi! Welcome to SO. Please read [this link](https://stackoverflow.com/help/minimal-reproducible-example) on how to produce a minimal, reproducible, example. And [this one for R specific questions](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – jake2389 Oct 05 '19 at 03:13

1 Answers1

0

Since the question does not include enough accompanying data or code to make the question understandable, it's assumed that what is wanted is to add a new variable to an existing dataframe. If so, then just assign the new vector to the existing dataframe. The new vector should be the same length as the existing df.

x <- c(1:5)
y <- c(12:16)
z <- c(24:20)
df <- data.frame(x, y, z)    # existing dataframe

o <- c(99:95)               # other vector
df$new <- o                  # other vector assigned to existing df
print(df)


 x  y  z new
1 1 12 24  99
2 2 13 23  98
3 3 14 22  97
4 4 15 21  96
5 5 16 20  95
Gray
  • 1,164
  • 1
  • 9
  • 23