Displaying 2 results from an estimated 2 matches for "tp4536162p4536189".
Did you mean:
tp4536162p4536162
2012 Apr 05
1
Function - simple question
Dear all,
Suppose I have a dataset with two variables:
X = c(0, 1, 2)
Y = c(1, 1, 1)
DS = data.frame(X, Y)
Now, I want to create a new variable Z with 3 observations, but I want its
values to be the result of a function. I want to create a function that
compares X and Y, and if X = Y, then Z value = 3. If X value differs from Y
value, Z value = 4. So, I'd have the following values for Z: 4,
2012 Mar 25
2
avoiding for loops
I have data that looks like this:
> df1
group id
1 red A
2 red B
3 red C
4 blue D
5 blue E
6 blue F
I want a list of the groups containing vectors with the ids. I am
avoiding subset(), as it is
only recommended for interactive use. Here's what I have so far:
df1 <- data.frame(group=c("red", "red", "red", "blue",