ge -
From: Lib Gray
To: Rui Barradas
Cc: r-help
Sent: Thursday, July 19, 2012 8:17 PM
Subject: Re: [R] Subsetting problem data, 2
I'm still getting the message (if this is what you were suggesting I try).
The data set I'm using has many more columns other than these variab
s
Chris Campbell
Mango Solutions
Data Analysis that Delivers
http://www.mango-solutions.com
+44 (0) 1249 705 450
-Original Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of Lib Gray
Sent: 20 July 2012 01:17
To: Rui Barradas
Cc: r-help
Subject:
I'm still getting the message (if this is what you were suggesting I try).
The data set I'm using has many more columns other than these variables;
could that be a problem? I didn't think it would affect it.
>pattern <- "L[1-8][12]"
> nms<-names(data)[grep(vars,names(data))]
Warning message:
In gr
I'm getting this error message:
nms<-names(data)[grep(vars,names(data))]
Warning message:
In grep(vars, names(data)) :
argument 'pattern' has length > 1 and only the first element will be used
Is there a way around this?
On Thu, Jul 19, 2012 at 6:17 PM, Rui Barradas wrote:
> Hello,
>
> I gu
Hello,
Sorry, forgot about that. It's trickier to write code without a dataset
to test it.
Try
pattern <- "L[1-8][12]"
and after the grep print nms to see if it's right.
Rui Barradas
Em 20-07-2012 00:33, Lib Gray escreveu:
I'm getting this error message:
nms<-names(data)[grep(vars,names(
Hello,
I guess so, and I can save you some typing.
vars <- sort(apply(expand.grid("L", 1:8, 1:2), 1, paste, collapse=""))
Then use it and see the result.
Rui Barradas
Em 20-07-2012 00:00, Lib Gray escreveu:
The variables are actually L11, L12, L21, L22, ... , L81, L82. Would just
creating a
Hello,
Try the following. The data is your example of Patient A through E, but
from the output of dput().
dat <- structure(list(Patient = structure(c(1L, 1L, 1L, 1L, 1L, 2L,
2L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 5L, 5L, 5L), .Label = c("A",
"B", "C", "D", "E"), class = "factor"), Cycle = c(1L, 2
Hello,
Try the following.
d <- read.csv(text="
Patient, Cycle, Variable1, Variable2
A, 1, 4, 5
A, 2, 3, 3
A, 3, 4, NA
B, 1, 6, 6
B, 2, NA, 6
C, 1, 6, 5
C, 3, 2, 2
", header=TRUE)
d
compl <- lapply(split(d, d$Patient), function(x) if(all(diff(x$Cycle) ==
1)) x)
holes <- lapply(split(d, d$Patie
Hello,
Not sure whether I understand it well.
If you want your output to include only Patient A &B,
this should work:
dat1<-read.table(text="
Patient Cycle Variable1 Variable2
A 1 4 5
A 2 3 3
A 3 4 NA
B 1 6 6
B 2 NA 6
C 1 6 5
C 3 2 2
",sep="",header=TRUE)
subset(dat1,!dat1$Patient=="C")
Pa
Tena koe Lib
In case you have receive a reply to this (I didn't notice one), here is one
option:
> lib
A X1 X4 X5
1 A 2 3 3
2 A 3 4 NA
3 B 1 6 6
4 B 2 NA 6
5 C 1 6 5
6 C 3 2 2
> str(lib)
'data.frame': 6 obs. of 4 variables:
$ A : chr "A" "A" "B" "B" ...
$ X1: num 2 3 1 2
10 matches
Mail list logo