On 30/12/2015 5:56 AM, SHIVI BHATIA wrote:
Dear Team,
I am facing an error while performing a manipulation using a dplyr package.
In the code below, I am using mutate to build a new calculated column:
kp<-read.csv("collection_last.csv",header=TRUE)
mutate(kp,dif=DOC_AMOUNT-RECEIPT_AMT+TDS_AMT+REBATE)
However it gives an error:-
Warning messages:
1: In Ops.factor(c(28831L, 28831L, 17504L, 4184L, 36187L, 25819L, 699L, :
'-' not meaningful for factors
2: In Ops.factor(c(28831L, 28831L, 17504L, 4184L, 36187L, 25819L, 699L, :
'+' not meaningful for factors
3: In Ops.factor(c(28831L, 28831L, 17504L, 4184L, 36187L, 25819L, 699L, :
'+' not meaningful for factors
This is an error when some of my variables are factors hence I have tried to
change these to numeric so used the expression as:
kp$DOC_TYPE=as.numeric(kp$DOC_TYPE).
this now shows as variable type of as "double". So expedite help on this one
i was trying to create a reproducible example and i am highly struggling to
create one. the data i have is approx. around 1 million rows with 21 columns
hence when i use a dput option it does not capture the entire detailing and
row level info required to share and even dput(head(kp$DOC_TYPE) does not
help either.
I have seen many stack overflow & r help column before composing this email.
Hence i need help to create this reproducible example to share with the
experts in the community. Apologies if this is a repeat.
PLEASE HELP AS I AM HIGHLY STRUGGLING TO BUILD ANY OUTCOME.
If you are working with a dataframe or matrix named x, just use
y <- x[1:10,]
to extract the first 10 rows. The error will probably occur with this
subset as well, and dput() will give you a reasonably sized amount of
output. If the error doesn't happen, just take a bigger subset, and
possibly leave off the beginning, e.g.
y <- x[101:110,]
for 10 lines starting at line 101.
Duncan Murdoch
______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.