Question

In: Computer Science

anyone can explain why this code in R doesn't work? i also tried to use filter...

anyone can explain why this code in R doesn't work? i also tried to use filter function, no hope either!

b <- subset(sub,NEIGHBORHOOD == "HARLEM-CENTRAL")

the name of the variable is correct, the condition. is correct too.

Solutions

Expert Solution

b <- subset(sub,NEIGHBORHOOD == "HARLEM-CENTRAL",select=c(columnname1,columnname2,columnname3))

You have to add a select attribute also which contains the columns from sub. Since you have not provided the dataframe sub, I have simply given columnname1, columnname2, columnname3. There give the actual column names in sub which is your original data frame.

Example

x<-data.frame("roll"=1:11,

"name"=c("Jack","Jill","Jeeva","Smith","Bob","Smith","John","Mathew","Charles","Zen","Yug"),

"age"=c(20,22,30,28,30,21,19,18,25,25,29))

Here x is my dataframe.

newdata <- subset(x, age >= 25 & age < 30,select=c(roll,name,age)) will produce the following results.

# subset(x, age >= 25 & age < 30,select=c(roll,name,age))

   roll    name age

4     4   Smith 28

9     9 Charles 25

10   10     Zen 25

11   11     Yug 29


Related Solutions

can anyone explain the code from R below? spam is a dataset sample <- sample( c(TRUE,...
can anyone explain the code from R below? spam is a dataset sample <- sample( c(TRUE, FALSE), nrow(spam), replace=TRUE) train <- spam[sample,] test <- spam[!sample,] when i run train and test, we got two different datasets that are split from the original spam dataset. But i don't understand the first line of code. not sure why this line of code can split data into two sets.
Does anyone know the code to use in R programming to create a scatter plot?
Does anyone know the code to use in R programming to create a scatter plot?
Does anyone know the code to use in R programming to create a box plot?
Does anyone know the code to use in R programming to create a box plot?
Please show work and explain. Also, can I use TVM in the TI-83+ to solve? 5-8:...
Please show work and explain. Also, can I use TVM in the TI-83+ to solve? 5-8: Thatcher Corporation’s bonds will mature in 10 years. The bonds have a face value of $1,000 and an 8% coupon rate, paid semiannually. The price of the bonds is $1,100. The bonds are callable in 5 years at a call price of $1,050. What is their yield to maturity? What is their yield to call?
Can anyone explain to me why I am getting an access violation when I try to...
Can anyone explain to me why I am getting an access violation when I try to add notes? It occurs when I try to set the "pLast" pointer to the previous node (for a doubly linked list). The code worked as singly linked list. When I added a "pLast" pointer and the needed code to make it a doubly linked list everything broke. #include <iostream> #include <stdlib.h> using namespace std; //build class that has a private function to inc count....
Why Newtonian mechanics doesn't work at velocities close to that of the speed of light? I...
Why Newtonian mechanics doesn't work at velocities close to that of the speed of light? I know that mass tends to become infinite at v=c but why does it fail if v is close to c but not exactly c?
How can I use the R language to code a new group to screen some variables?...
How can I use the R language to code a new group to screen some variables? for example, there is a data set include 5 candy's brand: a b c d e I just want to create a new group include a, b, c variable. How can I code it?
USE R CODING! Pleaseee I need the code With R coding Obs: it supposed to use...
USE R CODING! Pleaseee I need the code With R coding Obs: it supposed to use probability density function like X ~ Binomial( n ,p ) dbinom(X=?, n, prob) pbinom(X=?, n, prob) rbinmo(幾個符合二項分配的X, n, prob) X~Poisson (lamda) dpois(X=?, lamda) ppois (X=?, lamda) rpois (X, lamda) **Suppose the random variable X obeys the binomial allocation B (n=100, p=0.1) (a) Use X as the binomial allocation to calculate P(12≤X≤14) (b) In practice, when np ≥ 5 and n(1-p) ≥ 5, X will...
please I don't understand this code. Can you put comments to explain the statements. Also, if...
please I don't understand this code. Can you put comments to explain the statements. Also, if there any way to rewrite this code to make it easier, that gonna help me a lot. import java.io.*; import java.util.*; public class State {    private int citi1x,citi1y; private int pop1; private int citi2x,citi2y; private int pop2; private int citi3x,citi3y; private int pop3; private int citi4x,citi4y; private int pop4; private int plantx,planty; public int getCity1X(){ return citi1x; } public int getCity1Y(){ return citi1y;...
Why doesn't the Uniform Commercial Code cover patents? Please explain with a couple sentences.
Why doesn't the Uniform Commercial Code cover patents? Please explain with a couple sentences.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT