On May 7, 2010, at 1:04 AM, Mohan L wrote:
Hi all,
I have data like this:
sample <- read.csv(file="sample.csv",sep=",",header=TRUE)
sample
stdate Domain sex age Login
1 01/11/09 xxx FeMale 25 2
2 01/11/09 xxx FeMale 35 4
3 01/11/09 xxx Male 18 30
4 01/11/09 xxx Male 31 3
5 02/11/09 xxx Male 32 11
6 02/11/09 xxx Male 31 1
7 02/11/09 xxx FeMale 29 1
8 02/11/09 xxx FeMale 23 5
9 03/11/09 xxx FeMale 25 9
10 03/11/09 xxx FeMale 35 6
11 03/11/09 xxx Male 18 3
12 03/11/09 xxx Male 31 0
13 04/11/09 xxx Male 32 25
14 04/11/09 xxx Male 31 1
15 04/11/09 xxx FeMale 29 0
16 01/11/09 yyy FeMale 25 2
17 01/11/09 yyy FeMale 35 4
18 01/11/09 yyy Male 18 30
19 01/11/09 yyy Male 31 3
20 02/11/09 yyy Male 32 11
21 02/11/09 yyy Male 31 1
22 02/11/09 yyy FeMale 29 1
23 02/11/09 yyy FeMale 23 5
24 03/11/09 yyy FeMale 25 9
25 03/11/09 yyy FeMale 35 6
I have done the graph for all the data. Now I want to get data from
particular Domain and Sex from above data, then I need to do the
calculation
, eg :
I suspect you want to be working on an object like :
subset(sample, Domain=="xxx" & sex == "Male")
# if both are true
if(Domain == xxx && sex==FeMale)
The && operator will not give you what you want. It only returns a
single value and is unusable for selecting subsets. Go back and read
the introductory material. This is explained.
I need the data in another variable, like this
1 01/11/09 xxx FeMale 25 2
2 01/11/09 xxx FeMale 35 4
3 02/11/09 xxx FeMale 29 1
I have failed to achieve it . any help would greatly appreciated.
Thanks & Rg
Mohan L
David Winsemius, MD
West Hartford, CT
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.