An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20080926/e31e8414/attachment.pl>
Error in Cut command - 'x' must be numeric?
2 messages · Mackay Peter, Uwe Ligges
a is a data.frame that contains a numeric vector "tot_rdm_amt", hence you want to use cut(a$tot_rdm_amt,10), I guess Uwe Ligges
Mackay Peter wrote:
Hi Everyone I have a data set I want to bucket into deciles. Have been trying (without) success to use cut and using online help to understand my error. Here is my code to read in a few sample rows. I want to then create deciles by this variable
a<-read.csv("c:/temp/petrol.csv",header=TRUE,sep=",")
a
tot_rdm_amt 1 40.15 2 332.65 3 533.37 4 225.54 5 503.89 6 161.57 7 266.61 8 100.50 9 268.81 10 593.86 11 306.27 12 303.43 13 308.09 14 802.36 15 271.51 16 479.99 17 170.00 18 467.08 19 637.10
b<-cut(a,10)
Error in cut.default(a, 10) : 'x' must be numeric
summary(a)
tot_rdm_amt Min. : 40.15 1st Qu.:246.07 Median :306.27 Mean :356.46 3rd Qu.:491.94 Max. :802.36 I cannot work out why I am getting the error when summary produces sumamry stats, so clearly its reading as numeric? Yet when I run the following commands (from online R-Help doc), I get no issues:
Z <- stats::rnorm(10000) table(cut(Z, breaks = -6:6))
Any assistance would be greatful. Am new user to R so clearly missing something basic here! Thanks Peter Peter Mackay Data Mining Specialist Corporate - Customer Engagement Woolworths Limited P 02 8885 2345 | F 02 8888 2345 | M 0425 319 306 E pmackay at woolworths.com.au
1 Woolworths Way Bella Vista, NSW 2153 PO Box 8000 Baulkham Hills, NSW 2153
Mail point: E1.B7 P PLEASE CONSIDER THE ENVIRONMENT BEFORE YOU PRINT THIS E-MAIL *********************************************************** CAUTION: This email and files included in its transmission are solely intended for the use of the addressee(s) and may contain information that is confidential and privileged. If you receive this email in error, please advise us immediately and delete it without copying the contents contained within. Woolworths Limited (including its group of companies) do not accept liability for the views expressed within or the consequences of any computer viruses that may be transmitted with this email. The contents are also subject to copyright. No part of it should be reproduced, adapted or transmitted without the written consent of the copyright owner. *********************************************************** [[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list 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.