Assignment 4 slicing by date

Assignment 4 slicing by date

by Jinyuru Yang -
Number of replies: 7

Hi,


I am trying to perform conditional slicing on the data frame to isolate the September calls but I can’t seem to figure out how to make it so R will only isolate based on the 09 in the date code. I am unsure which command would be helpful in this situation?

In reply to Jinyuru Yang

Re: Assignment 4 slicing by date

by Erik Spence -
I used the "substr" command.
In reply to Erik Spence

Re: Assignment 4 slicing by date

by Danielle Sacdalan -
Hi,

Just like Jinruyu I am attempting to slice the data frame using the date of creation by limiting it to 09. I'm trying out the substr () command, wherein I define the text to be extracted and assign it to a variable that I then use as a condition for slicing the data frame. Unfortunately, R keeps returning an empty df:

[1] calls.Creation.Date calls.Division calls.Ward <0 rows> (or 0-length row.names)

Can I ask for advice on how to proceed with this approach?
In reply to Danielle Sacdalan

Re: Assignment 4 slicing by date

by Erik Spence -
How are you using substr? What command, exactly, are you using? Did you read the documentation on how to use the function ("help(substr)")?
In reply to Erik Spence

Re: Assignment 4 slicing by date

by Danielle Sacdalan -
Im using:
a <- substr ("text to be extracted", position of first character of text, position of last character of text)
sept <- df [df$date.creation == a,]
head (sept)

[1] calls.Creation.Date calls.Division calls.Ward 
 <0 rows> (or 0-length row.names)

#output is empty
In reply to Danielle Sacdalan

Re: Assignment 4 slicing by date

by Erik Spence -
That's not quite right. It's not "text to be extracted", it's "text which is being extracted from". Be sure to test how the function works at the R prompt to make sure you understand what it's doing.

I'm also not sure that date.creation is the correct column name.
In reply to Erik Spence

Re: Assignment 4 slicing by date

by Danielle Sacdalan -
Thank you Erik. I have already been able to use substr to get "09". But I'm not able to use this to slice the data frame by month of Creation.Date in the same way that I can by Division. I get either NA, or empty data frames. I think that my syntax is wrong, but it could also be that this is not the approach I should be taking. Would really appreciate your or anyone's help.
In reply to Danielle Sacdalan

Re: Assignment 4 slicing by date

by Erik Spence -
I would need to see your code to determine the problem. It's probably better if you email.