R中的十进制错误

时间:2013-08-11 02:13:55

标签: r decimal

我正在使用一个具有两位小数的数字变量的数据集。当我读取数据集时,它显示带有小数的变量,但任何分析结果都不显示小数。

例如

 dados <- read.csv("BANCO.csv",dec=",", sep=";", stringsAsFactors=FALSE) 

 dput(dados) 

 structure(list(VAR = c("PJ", "PJ", "PF", "PF", "PJ", "PJ", "PJ",  
 "PF", "PJ", "PJ", "PF", "PJ", "PJ", "PJ"), Saldo = c(99514,04, 
 49781,73, 49731,17, 49723,11, 398253,84, 49805,66, 49764,19,  
 100363,2, 49739,54, 99580,98, 49781,73, 198958,16, 49739,54, 
 49830,54)), .Names = c("VAR", "Saldo"), class = "data.frame", row.names = c(NA,  
 -14L)) 

 > summary(dados) 

      VAR                      
  Length:14              
  Class :character      
  Mode  :character     

 Saldo 
 Min.   : 49723   
 1st Qu.: 49746  
 Median : 49794 
 Mean   : 96040   
 3rd Qu.: 99564   
 Max.   :398254   

 > tapply(dados$Saldo, list(VAR=dados$VAR), sum, na.rm=TRUE) 

 VAR 

 PF 6111262   
 PJ 82400812  

1 个答案:

答案 0 :(得分:0)

浮动分离符号似乎有问题。尝试将“,”更改为“。”一切都应该有效。