[R] HOW TO CREATE A SUBSET FROM A LARGE DATASET based on some conditions
arun
smartpink111 at yahoo.com
Mon Jan 13 18:23:37 CET 2014
Hi,
Try:
dat1 <- read.table(text="2008 India .. .. .. .. ..
2009 India - - - - -
2010 India 5 1 6 0 -
2011 India 20 2 21 2 2
2012 India 35 4 42 3 5
2013 India 88 10 74 6 ..
2008 Brazil 3 2 .. .. 2
2009 Brazil 6 4 - - 4",sep="",header=FALSE,stringsAsFactors=FALSE)
dat2 <- dat1[dat1[,2]=="India",]
A.K.
HI all
i would like to create a small dataset from the huge dataset
based on certain conditions. A sample of the dataset is as shown below:
Time Country 3G Phone subscriber (Million) 3G Phone
subscriber per 100 Mobile subscription Smartphone subscriber
(Millions) Smartphone subscriber per 100 inhabitant Active
mobile-broadband subscriptions per 100 inhabitants
2008 India .. .. .. .. ..
2009 India - - - - -
2010 India 5 1 6 0 -
2011 India 20 2 21 2 2
2012 India 35 4 42 3 5
2013 India 88 10 74 6 ..
2008 Brazil 3 2 .. .. 2
2009 Brazil 6 4 - - 4
I would like to separate rows from the dataset only for country = India
This data is in a csv format in a file a.csv
The code i wrote it is:
tempFile<-read.csv("a.csv", header = TRUE)
df<-data.frame(tempFile)
if(df$Country == "India") { India<-df }
This shows an error. pls help, where am i doing a mistake
More information about the R-help
mailing list