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 just check my code and tell me why the program doesn't show the end...
Can anyone just check my code and tell me why the program doesn't show the end date & stops at the date before the end date? Tell me how i can fix it. Question: Write a program compare.cpp that asks the user to input two dates (the beginning and the end of the interval). The program should check each day in the interval and report which basin had higher elevation on that day by printing “East” or “West”, or print...
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?
I cant not seem to get this right. I have tried and tried can I please...
I cant not seem to get this right. I have tried and tried can I please get help. Thank you! Writing a Modular Program in Java Summary In this lab, you add the input and output statements to a partially completed Java program. When completed, the user should be able to enter a year, a month, and a day to determine if the date is valid. Valid years are those that are greater than 0, valid months include the values...
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT