Home > database >  Loading data into RStudio and analyzing
Loading data into RStudio and analyzing

Time:12-15

I have all of my files loaded into RStudio - they are all showing as tabs at the top. I can View, tibble, etc each file. But when I type in data(filename) it says data set not found.

I'm also having trouble with analyzing. Each column name I use says "not found"

Specifically - I am trying to find the mean of TotalSteps which is a column name in the data set dailyActivity_merged.

Here is what I have-

mean(TotalSteps)

Object 'TotalSteps' not found.

CodePudding user response:

You have to call the dataframe and the column:

dailyActivity_merged$TotalSteps

or

dailyActivity_merged$["TotalSteps"]

And another way to get a good overview over a data.frame is the summary() function.

df = iris

summary(iris)

Output:

> summary(iris)
  Sepal.Length    Sepal.Width     Petal.Length    Petal.Width          Species  
 Min.   :4.300   Min.   :2.000   Min.   :1.000   Min.   :0.100   setosa    :50  
 1st Qu.:5.100   1st Qu.:2.800   1st Qu.:1.600   1st Qu.:0.300   versicolor:50  
 Median :5.800   Median :3.000   Median :4.350   Median :1.300   virginica :50  
 Mean   :5.843   Mean   :3.057   Mean   :3.758   Mean   :1.199                  
 3rd Qu.:6.400   3rd Qu.:3.300   3rd Qu.:5.100   3rd Qu.:1.800                  
 Max.   :7.900   Max.   :4.400   Max.   :6.900   Max.   :2.500         

CodePudding user response:

Like Marco_CH said, you have to specify the dataframe and the column you want the mean from. So following Marco_CH answer it should be:

mean(dailyActivity_merged$TotalSteps)

always specify the dataframe for a function so it knows exactly where it should look.

  • Related