Question

In: Computer Science

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?

Solutions

Expert Solution

Solution: R is very good language for Statistical Applications and Graphical Presentation of data. It has capability to handle Vectors,Matrices,Lists,Dataframes as simple objects.

Here question contains a data set includes 5 candy's brands:a b c d e

Now creation of new group in R , it is easy as shown below:

# Creation of a dataset with five candy's brands as a data frame

brands<-c('a','b','c','d','e')

a<-c(1:10)

b<-seq(1,20, by=2)

c<-c(11:20)

d<-seq(1,30, by=3)

e<-c(21:30)

# Sample vectors created for a,b,c,d,e

candydataset<- data.farme(a,b,c,d,e)

candydataset<- data.frame(a,b,c,d,e)
> candydataset
a b c d e
1 1 1 11 1 21
2 2 3 12 4 22
3 3 5 13 7 23
4 4 7 14 10 24
5 5 9 15 13 25
6 6 11 16 16 26
7 7 13 17 19 27
8 8 15 18 22 28
9 9 17 19 25 29
10 10 19 20 28 30

if you want only 3 brands a,b,c we can create data frame with only that vectors only as shown below:

Newcandy<-data.frame(a,b,c)

Newcandy
a b c
1 1 1 11
2 2 3 12
3 3 5 13
4 4 7 14
5 5 9 15
6 6 11 16
7 7 13 17
8 8 15 18
9 9 17 19
10 10 19 20

Note: I got the given question upto this extent. If i did not got your exact needs extreamly sorry.


Related Solutions

How would I code the following in assembly language? Use the Keil programming environment to code...
How would I code the following in assembly language? Use the Keil programming environment to code the C8051F330 SiLabs 8051 micro controller. All the documentation is available on efundi. The program shall be done in assembler and you shall use the DJNZ instruction to generate a delay time to flash the LED. The LED shall flash in the following sequence: 1. On for 50mS, 2. Off for 400mS, 3. On for 50mS, 4. Off for 1.5S, 5. Repeat the sequence...
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...
This is my C language code. I have some problems with the linked list. I can't...
This is my C language code. I have some problems with the linked list. I can't store the current. After current = temp, I don't know how to move to the next node. current = current-> next keeps making current into NULL. #include #include #include #include struct node{int data; struct node *next;}; int main() {     struct node *head, *current, *temp, *trash;     srand(time(0));     int randNumber = rand()%51;     if(randNumber != 49)     {         temp = (struct node*)malloc(sizeof(struct node));         current = (struct node*)malloc(sizeof(struct node));...
Use R programming language to answer and please so show the code as well. A paper...
Use R programming language to answer and please so show the code as well. A paper manufacturer studied the effect of three vat pressures on the strength of one of its products. Three batches of cellulose were selected at random from the inventory. The company made two production runs for each pressure setting from each batch. As a result, each batch produced a total of six production runs. The data follow. Perform the appropriate analysis. Table is below Batch Pressure...
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.
R code Need assistance in getting this R code to run variables (Process) char ( Age)...
R code Need assistance in getting this R code to run variables (Process) char ( Age) char tmp <- expand.grid(Process = unique(words$Process),Age =unique(words$Age)) X <- model.matrix(~ factor(Process):factor(Age), data = tmp) glht(mod, linfct = X)
COMPUTER CALCULATIONS: I need to know how to code in R for the solutions, not by...
COMPUTER CALCULATIONS: I need to know how to code in R for the solutions, not by hand. 2. Look at the data in Table 7.18 on page 368 of the textbook. These data are also given in the SAS code labeled “SAS_basketball_goal_data” and R code labeled basketball goal data . The dependent variable is goals and the independent variable is height of basketball players. Complete a SAS /R program and answer the following questions about the data set: (a) Does...
Use the Python programming language to complete below (I need the New Answer for this, and...
Use the Python programming language to complete below (I need the New Answer for this, and please provide the screenshot of the source code. Thank you!): A website requests an user to input his account password. Write a program to examize the validity of the password. The valid password must consists of: At least 1 letter in [a-z] At least 1 number in [0-9] At least a letter in [A-Z] (capital) At least one special letter in [$#@] At least...
Use the Python programming language to complete below (I need the New Answer for this, and...
Use the Python programming language to complete below (I need the New Answer for this, and please provide the screenshot of the source code. Thank you!): Write a function to seek for all even numbers and odd numbers in the middle of two number A and B. Print even and odd numbers in 1 and 2020 (including both these two numbers)
I need this in R code please: Use the dataset ’juul’ in package ’ISwR’ to answer...
I need this in R code please: Use the dataset ’juul’ in package ’ISwR’ to answer the question. (1) Conduct one-way ANOVA test to test if the mean of igf1 of each level of tanner are the same? (2) What is the mean of igf1 in each level of tanner? (3) If there is any difference, which ones appear to be different? (Use pairwise t test for each pair of level with bonferroni method)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT