# Getting warning message

10 messages
Open this post in threaded view
|

## Getting warning message

 Hi Friends, I  have  a data frame X, and I want to add “%” & “\$” in row  4 and 5 respectively. when I’m trying using below logic, I’m getting warning message. Can anyone  help me out on this. X: Summary      G Y R T Accts     582 644 0 1226 AcctCov     230 165 0 395 Cov%      40 26 0 32 UnCov%     60 74 0 68 EqVol11\$MM8.5 10.6 0 19.1 Using this logic: Z16[5,2:5]<-paste("\$",Z16[5,2:5],sep="") Z16[3,2:5]<-paste(Z16[3,2:5],"%",sep="") Z16[4,2:5]<-paste(Z16[4,2:5],"%",sep="") Getting this Warning: In `[<-.factor`(`*tmp*`, iseq, value = c(3L, 1L, 2L, 4L, NA))                                             invalid factor level, NAs generate Final result: Summary   G Y R T Accts 582 644 0 1226 AcctCov 230 165 0 395 Cov% 40% 26% 0% 32% UnCov% 60% 74% 0% 68% EqVol11\$MM\$8.50 \$10.60 \$0 \$19.10 Thanks in Advance. Thanks, Namit
Open this post in threaded view
|

## Re: Getting warning message

 This post has NOT been accepted by the mailing list yet. Hi, Try this: dat1<-read.table(text=" Summary      G Y R T Accts     582 644 0 1226 AcctCov     230 165 0 395 Cov%      40 26 0 32 UnCov%     60 74 0 68 EqVol11\$MM 8.5 10.6 0 19.1 ",sep="",header=TRUE)  dat1[3,2:5]<-paste(dat1[3,2:5],"%",sep="")  dat1[4,2:5]<-paste(dat1[4,2:5],"%",sep="")  dat1[5,2:5]<-paste("\$",dat1[5,2:5],sep="")  dat1      Summary    G     Y  R     T #1      Accts  582   644  0  1226 #2    AcctCov  230   165  0   395 #3       Cov%  40%   26% 0%   32% #4     UnCov%  60%   74% 0%   68% #5 EqVol11\$MM \$8.5 \$10.6 \$0 \$19.1 A.K.
Open this post in threaded view
|

## Re: Getting warning message

 This post has NOT been accepted by the mailing list yet. In reply to this post by namit Hello, One more point: Please don't delete your messages.  I have seen that one of your messages were deleted.  It could be used for future references. A.K.
Open this post in threaded view
|

## Re: Getting warning message

 In reply to this post by namit HI, I posted reply in nabble. One more comment regarding your code.  If your dataset is X.  I wonder how it changed to Z16.  Probably, you have to use X[5,2:5].... A.K. ----- Original Message ----- From: namit <[hidden email]> To: [hidden email] Cc: Sent: Thursday, July 26, 2012 9:23 AM Subject: [R] Getting warning message Hi Friends, I  have  a data frame X, and I want to add “%” & “\$” in row  4 and 5 respectively. when I’m trying using below logic, I’m getting warning message. Can anyone  help me out on this. X: Summary          G    Y    R    T Accts         582    644    0    1226 AcctCov         230    165    0    395 Cov%          40    26    0    32 UnCov%         60    74    0    68 EqVol11\$MM8.5    10.6    0    19.1 Using this logic: Z16[5,2:5]<-paste("\$",Z16[5,2:5],sep="") Z16[3,2:5]<-paste(Z16[3,2:5],"%",sep="") Z16[4,2:5]<-paste(Z16[4,2:5],"%",sep="") Getting this Warning: In `[<-.factor`(`*tmp*`, iseq, value = c(3L, 1L, 2L, 4L, NA))                                             invalid factor level, NAs generate Final result: Summary   G    Y    R    T Accts    582    644    0    1226 AcctCov    230    165    0    395 Cov%    40%    26%    0%    32% UnCov%    60%    74%    0%    68% EqVol11\$MM\$8.50     \$10.60     \$0     \$19.10 Thanks in Advance. Thanks, Namit -- View this message in context: http://r.789695.n4.nabble.com/Getting-warning-message-tp4637928.htmlSent from the R help mailing list archive at Nabble.com. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code. ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Getting warning message

 In reply to this post by namit Hi. I don't know how did you create data frame X but if you check str(X) you will see that you have one or more factors inside. Try using stringsAsFactors=FALSE options while creating data frame. Hope this helps. Andrija On Thu, Jul 26, 2012 at 3:23 PM, namit <[hidden email]> wrote: > Hi Friends, > > > I  have  a data frame X, and I want to add % & \$ in row  4 and 5 > respectively. when Im trying using below logic, Im getting warning > message. > Can anyone  help me out on this. > > > X: > Summary       G Y       R       T > Accts        582        644     0       1226 > AcctCov      230        165     0       395 > Cov%          40        26      0       32 > UnCov%       60 74      0       68 > EqVol11\$MM8.5   10.6    0       19.1 > > Using this logic: > > Z16[5,2:5]<-paste("\$",Z16[5,2:5],sep="") > Z16[3,2:5]<-paste(Z16[3,2:5],"%",sep="") > Z16[4,2:5]<-paste(Z16[4,2:5],"%",sep="") > > Getting this Warning: In `[<-.factor`(`*tmp*`, iseq, value = c(3L, 1L, 2L, > 4L, NA)) >                                             invalid factor level, NAs > generate > > > Final result: > > Summary   G     Y       R       T > Accts   582     644     0       1226 > AcctCov 230     165     0       395 > Cov%    40%     26%     0%      32% > UnCov%  60%     74%     0%      68% > EqVol11\$MM\$8.50         \$10.60  \$0      \$19.10 > > > Thanks in Advance. > > Thanks, > Namit > > > > > -- > View this message in context: > http://r.789695.n4.nabble.com/Getting-warning-message-tp4637928.html> Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > [hidden email] 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. >         [[alternative HTML version deleted]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|

## Re: Getting warning message

 In reply to this post by arun kirshna Hi Arun, Bymistake it kept X instead of Z16.
Open this post in threaded view
|

## Re: Getting warning message

 This post has NOT been accepted by the mailing list yet. Hello Namit, The code that I posted before didn't gave any warning message.  I am using R 2.15.   I tried with your codes: Z16      Summary     G     Y R      T 1      Accts 582.0 644.0 0 1226.0 2    AcctCov 230.0 165.0 0  395.0 3       Cov%  40.0  26.0 0   32.0 4     UnCov%  60.0  74.0 0   68.0 5 EqVol11\$MM   8.5  10.6 0   19.1 #I have a doubt here: EqVol11\$MM8.5.  I read the data as EqVol11\$MM space 8.5. > str(Z16) 'data.frame': 5 obs. of  5 variables: # \$ Summary: Factor w/ 5 levels "AcctCov","Accts",..: 2 1 3 5 4  #\$ G      : num  582 230 40 60 8.5  #\$ Y      : num  644 165 26 74 10.6  #\$ R      : int  0 0 0 0 0  #\$ T      : num  1226 395 32 68 19.1  Z16[5,2:5]<-paste("\$",Z16[5,2:5],sep="")  Z16[3,2:5]<-paste(Z16[3,2:5],"%",sep="")  Z16[4,2:5]<-paste(Z16[4,2:5],"%",sep="")  Z16 #     Summary    G     Y  R     T #1      Accts  582   644  0  1226 #2    AcctCov  230   165  0   395 #3       Cov%  40%   26% 0%   32% #4     UnCov%  60%   74% 0%   68% #5 EqVol11\$MM \$8.5 \$10.6 \$0 \$19.1 ##No error messages. You can check str().     A.K.
Open this post in threaded view
|

## Re: Getting warning message

 Hi Arun, when i'm using the logic which you mention....I'm getting error..can you please help me on this. > Z16<-str(Z16) 'data.frame': 5 obs. of  5 variables:  \$ Summary: chr  "Accts" "AcctCov" "Cov%" "UnCov%" ...  \$ G      : Factor w/ 5 levels "224","39","568",..: 3 1 2 4 5  \$ Y      : Factor w/ 5 levels "10.6","158","25",..: 4 2 3 5 1  \$ R      : Factor w/ 1 level "0": 1 1 1 1 1  \$ T      : Factor w/ 5 levels "1196","19.1",..: 1 4 3 5 2 > Z16[5,2:5]<-paste("\$",Z16[5,2:5],sep="") Error in Z16[5, 2:5] <- paste("\$", Z16[5, 2:5], sep = "") :   incorrect number of subscripts on matrix Thanks in Advance. Thanks, Namit