Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Rstudio, I need help with creating a data frame from another data frame -

ID: 3195531 • Letter: U

Question

Using Rstudio, I need help with creating a data frame from another data frame - I've been trying a code in this manner;
new.df<-old.df[old.df$variable=="X","Y","Z"] but it won't work. Further for this question I need to compare the economy and answer which country has the strongest economy, so I also need a code for that. This question uses a data set.

2. Secondly, I need to find the mistake as to what led to the yield being num 2.3 and not the 1st and 3rd variables of the data frame - this is an example of the data frame: a.df<-a.df[1,3] and the output is num 2.3

3. Thirdly how can I check what a variable is measuring in R studio, from a data set?

Explanation / Answer

(a)

use the following code to choose the observations where column variables has either X, Y or Z value.

new.df<-old.df[old.df$variable=="X"|old.df$variable=="Y"|old.df$variable=="Z"]

To find out the strongest economy, you will have to first define the basis for comparison.

for example, you choose the currency value is the indicator of the strong economy, so you take out the currency values of all the countries.

Post it as a separate question with full details for the code

(b)

a.df<-a.df[1,3]

This code block will fetch the cell value of 1st row and 3rd column.

That is why it provides you an ouput of single value.

If you want to fetch 1st and 3rd variable, use following code

a.df<-a.df[,c(1,3)]

(c)

This question is also very ambiguous. What do you mean by measuring?

Do you want to check the name of the column - names(a.df$variable)

Do you want to check whether it has numerical value in the column - is.numeric(a.df$variable)

Do you want to check what all values are present in the column - levels(a.df$variable)

Do you want to check frequencies of all values are present in the column - table(a.df$variable)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote