Dear Team ,What should be the syntax when we apply 2 conditions at a time like >20 matches played and less than 14 matches lost ?On writing below commands-print(subData)subData<-subset(Newcaptaincy,played>20,lost<14,select=c("names","played","lost"))print(subData)Answer isprint(subData) names played won1 Dhoni 45 222 Sourav 47 203 Azhar 40 20
in the assignment my code is subdata <- subset(captaincy,played>20&&lost<14,select =c("names","played","won","lost"))print(subdata)result is names played won lost1 Mahi 45 22 122 Sourav 49 21 133 Azhar 47 14 144 Sunny 47 9 85 Pataudi 40 9 196 Dravid 25 8 6in lost column we have 19 but it should be less than 14 know.
Can create a two subset at one syntax ? will it disturb all contents of captaincy data frames?Suppose i created as>SubData<-subset(captaincy,played>25,matches<40,select("names","played","lost"))ctrl+sprint(SubData)ctrl+sctrel+enteri have did but unexpected error.
In the assignment i have worked out got the solution but with an error. Kindly help sirsubData <- subset(captaincy,played>20,lost<14, select = c("names","played","lost")) Error in `[.data.frame`(x, r, vars, drop = drop) : object 'lost' not found > print(subData) names played won 1 Mahi 45 22 2 Sourav 49 21 6 Dravid 25 8
I am trying to do the assignment but every time I got an error. Please provide me some useful solutionmy code is - subData <- subset(captaincy,played>20,lost<14, select = c("names","played","lost"))print(subData)My ans - names played lost Mahi 45 12 Sourav 49 13 Azhar 47 14 Sunny 47 8 Pataudi 40 19 Dravid 25 6
subdata1<-subset(capataincy,played>20&&lost<14,select = c("names","played","won","lost"))In above query for large dataset can we have another option other than concatenating names of all columns manually?
Why "<-" operator is more preferred to "=" operator in case of assignment?
21053 visits
Outline:Shortcut key for assignment operator (<-) How to perform numeric indexing How to extract a row or column from a data frame How to retrieve multiple rows from a data frame How to combine objects to form a vector How to perform logical indexing on a data frame How to perform name indexing on a data frame How to slice a data frame using subset function How to select required columns (by name) from a data frame How to retrieve data using double square brackets
Shortcut key for assignment operator (<-) How to perform numeric indexing How to extract a row or column from a data frame How to retrieve multiple rows from a data frame How to combine objects to form a vector How to perform logical indexing on a data frame How to perform name indexing on a data frame How to slice a data frame using subset function How to select required columns (by name) from a data frame How to retrieve data using double square brackets
Show video info
Pre-requisite