[R] read.csv and Decimal places

Bill Poling Bill@Poling @ending from zeli@@com
Mon May 7 18:34:44 CEST 2018


Terrific, thank you all for the advice, I will continue my work with tutorials and see the help details for your suggestions.

WHP

William H. Poling, Ph.D., MPH

From: Bert Gunter [mailto:bgunter.4567 at gmail.com]
Sent: Monday, May 07, 2018 12:25 PM
To: Richard M. Heiberger <rmh at temple.edu>
Cc: Bill Poling <Bill.Poling at zelis.com>; r-help (r-help at r-project.org) <r-help at r-project.org>
Subject: Re: [R] read.csv and Decimal places

... and see also ?print.data.frame , the "digits" argument.
See also ?str

It might be worth your while spending time with an R tutorial or two that covers such topics, i.e. distinguishing between an object and various (S3) methods that "represent" it, such as print(), summary(), plot()  etc.

-- Bert

Bert Gunter

"The trouble with having an open mind is that people keep coming along and sticking things into it."
-- Opus (aka Berkeley Breathed in his "Bloom County" comic strip )

On Mon, May 7, 2018 at 9:10 AM, Richard M. Heiberger <rmh at temple.edu<mailto:rmh at temple.edu>> wrote:
The stored numbers are correct.  They are rounded on printing.
print(RevFCast, digits=17)

See
?options
And scroll down to digits.

On Mon, May 7, 2018 at 11:50 Bill Poling <Bill.Poling at zelis.com<mailto:Bill.Poling at zelis.com>> wrote:

> Hi, Novice UsR here.
>
> I have a csv file that contains 13 columns of numeric data that have
> decimal places (for the most part).
>
> After reading in the file
> RevFCast = read.csv("RevAnalysisNov2016_April2018.csv", header=TRUE, dec =
> ".", stringsAsFactors=FALSE)
>
> and viewing the data
> View(RevFCast)
>
> Some of the fields came in with the correct decimals and some not?
>
> The view in R:
>
>
> 5973157
>
> 1281576
>
> -39811.51
>
> -247443.9
>
> 994320.6
>
> 1534165
>
> 1384.30
>
> -95835.69
>
> 1439713
>
> 3910730
>
> -13913.00
>
> -357694.2
>
> 3539123
>
> 2
>
> Feb 2016 Totals:
>
> 2/28/2016
>
> 5159011
>
> 1231964
>
> -47356.74
>
> -372942.3
>
> 811664.5
>
> 1353568
>
> -14169.24
>
> -73436.06
>
> 1265963
>
> 3555562
>
> -29385.31
>
> -444792.8
>
> 3081384
>
> 3
>
> Mar 2016 Totals:
>
> 3/31/2016
>
> 6695767
>
> 1438387
>
> -49046.86
>
> -344080.8
>
> 1045259.4
>
> 1593530
>
> -1455.10
>
> -100240.36
>
> 1491835
>
> 4559655
>
> -39633.37
>
> -361349.6
>
> 4158672
>
> 4
>
> Apr 2016 Totals:
>
> 4/30/2016
>
> 6365359
>
> 1348557
>
> -41311.13
>
> -355586.2
>
> 951659.5
>
> 1437497
>
> -82397.77
>
> -78918.26
>
> 1276181
>
> 4547723
>
> -23487.13
>
> -386717.5
>
> 4137519
>
> 5
>
> May 2016 Totals:
>
> 5/31/2016
>
> 6495219
>
> 1207522
>
> -79063.98
>
> -458998.8
>
> 669458.9
>
> 1789405
>
> -15564.42
>
> -71763.56
>
> 1702078
>
> 4689307
>
> -18202.86
>
> -547422.1
>
> 4123682
>
> 6
>
> Jun 2016 Totals:
>
> 6/30/2016
>
> 7226302
>
> 1408744
>
> -43916.59
>
> -378086.4
>
> 986741.1
>
> 1502112
>
> 1808.77
>
> -83735.15
>
> 1420186
>
> 5394970
>
> -57335.49
>
> -518259.2
>
> 4819375
>
> 7
>
> Jul 2016 Totals:
>
> 7/31/2016
>
> 6835273
>
> 1374085
>
> -16746.33
>
> -333994.2
>
> 1023344.8
>
> 1533915
>
> -29776.31
>
> -34898.95
>
> 1469240
>
> 4786363
>
> -26061.45
>
> -417613.8
>
> 4342688
>
>
> But the dput indicates that the values that have decimals are correct?
>
>
> For example "TotalNetRev" row 1 in View = 5973157 however, as you can see
> below in the dput the value is 5973156.76
>
> Am I to believe that the true values in the CSV file are present in the R
> data or not?
>
> When I create a DF I see the decimals are similar to the view? 5973157 vs.
> 5973156.76
>
>
> tmp <- data.frame(RevFCast)
>
> > tmp
>
>                Date      Month TotalNetRev ClaimEditNew ClaimEditAdjusted
> ClaimEditCancelled ClaimEditNetRev  BRANew BRAAdjusted BRACancelled
> BRANetRev  OONNew OONAdjusted
>
> 1  Jan 2016 Totals:  1/31/2016     5973157      1281576         -39811.51
>         -247443.9        994320.6 1534165     1384.30    -95835.69
>  1439713 3910730   -13913.00
>
> 2  Feb 2016 Totals:  2/28/2016     5159011      1231964         -47356.74
>         -372942.3        811664.5 1353568   -14169.24    -73436.06
>  1265963 3555562   -29385.31
>
>
> dput(RevFCast)
> structure(list(Date = c("Jan 2016 Totals:", "Feb 2016 Totals:",
> "Mar 2016 Totals:", "Apr 2016 Totals:", "May 2016 Totals:", "Jun 2016
> Totals:",
> "Jul 2016 Totals:", "Aug 2016 Totals:", "Sep 2016 Totals:", "Oct 2016
> Totals:",
> "Nov 2016 Totals:", "Dec 2016 Totals:", "Jan 2017 Totals:", "Feb 2017
> Totals:",
> "Mar 2017 Totals:", "Apr 2017 Totals:", "May 2017 Totals:", "Jun 2017
> Totals:",
> "Jul 2017 Totals:", "Aug 2017 Totals:", "Sep 2017 Totals:", "Oct 2017
> Totals:",
> "Nov 2017 Totals:", "Dec 2017 Totals:", "Jan 2018 Totals:", "Feb 2018
> Totals:",
> "Mar 2018 Totals:", "Apr 2018 Totals:"), Month = c("1/31/2016",
> "2/28/2016", "3/31/2016", "4/30/2016", "5/31/2016", "6/30/2016",
> "7/31/2016", "8/31/2016", "9/30/2016", "10/31/2016", "11/30/2016",
> "12/31/2016", "1/31/2017", "2/28/2017", "3/31/2017", "4/30/2017",
> "5/31/2017", "6/30/2017", "7/31/2017", "8/31/2017", "9/30/2017",
> "10/31/2017", "11/30/2017", "12/31/2017", "1/31/2018", "2/28/2018",
> "3/31/2018", "4/30/2018"), TotalNetRev = c(5973156.76, 5159011.2,
> 6695766.64, 6365359, 6495218.53, 7226302.39, 6835272.7, 7383501.57,
> 6962748.19, 7623278.72, 7274994.33, 7919421.8, 7360740.81, 7436693.35,
> 8545765.55, 7337269.76, 8180585.44, 8376635.05, 7758261.24, 10374641.22,
> 8000314.11, 9114958.9, 9805149.15, 9336939.45, 10273849.1, 9159308.71,
> 10184703.33, 10251153.52), ClaimEditNew = c(1281575.96, 1231963.62,
> 1438387.07, 1348556.82, 1207521.76, 1408744.12, 1374085.33, 1544344,
> 1503967.3, 1507951.17, 1674381.12, 1793541.37, 1570560.29, 1438120.34,
> 1639998.72, 1382722.43, 1574674.27, 1626413.88, 1461438.39, 1780951.91,
> 1552983.02, 1837094.37, 1763023.4, 1798810.59, 1875755.41, 1589429.36,
> 1962239.1, 2110252.02), ClaimEditAdjusted = c(-39811.51, -47356.74,
> -49046.86, -41311.13, -79063.98, -43916.59, -16746.33, -38347.9,
> -84797.44, -38961.44, -72036.83, -62854.78, -35259.84, -44198.39,
> -34262.65, -49245.82, -34977.28, -36797.35, -47534.43, -33515.13,
> -25764.41, -29130.53, -57693.63, -51026.83, -49624.49, -36508.13,
> -32667.21, -37900.5), ClaimEditCancelled = c(-247443.87, -372942.34,
> -344080.78, -355586.21, -458998.84, -378086.44, -333994.18, -567024.45,
> -521499.8, -428915.13, -512034.28, -440865.42, -347494.22, -422436.19,
> -444588.65, -462891.57, -518395.47, -373818.5, -398899.53, -381573.69,
> -531449.2, -476238.48, -434296.86, -655679.94, -528999.52, -423725.95,
> -556977.31, -518633.95), ClaimEditNetRev = c(994320.58, 811664.54,
> 1045259.43, 951659.48, 669458.94, 986741.09, 1023344.82, 938971.65,
> 897670.06, 1040074.6, 1090310.01, 1289821.17, 1187806.23, 971485.76,
> 1161147.42, 870585.04, 1021301.52, 1215798.03, 1015004.43, 1365863.09,
> 995769.41, 1331725.36, 1271032.91, 1092103.82, 1297131.4, 1129195.28,
> 1372594.58, 1553717.57), BRANew = c(1534164.71, 1353568.09, 1593530.36,
> 1437496.77, 1789405.49, 1502112.48, 1533915.37, 1577119.44, 1675114.78,
> 1806743.02, 1768146.96, 1890956.35, 1543461.91, 1681545.83, 2035479.51,
> 1751531.76, 1718257.45, 1752827.66, 1747981.87, 1951933.29, 1670757.51,
> 1885995.3, 2251822.03, 2005832.91, 1754410.67, 1492373.55, 2091430.93,
> 2228246.29), BRAAdjusted = c(1384.3, -14169.24, -1455.1, -82397.77,
> -15564.42, 1808.77, -29776.31, -62641.51, -15418.52, -6170.87,
> -14208.48, -43046.76, -43853.35, -53907.65, -29729.62, -47990.07,
> 54674.99, 4029.92, -48323.28, 35197.06, -97430.56, -48994.68,
> -49803.5, -12870.97, -33126.07, -27147.19, -9559.51, -37699.07
> ), BRACancelled = c(-95835.69, -73436.06, -100240.36, -78918.26,
> -71763.56, -83735.15, -34898.95, -98622.59, -66763.2, -184645.76,
> -85494.47, -94503.59, -143120.57, -49829.96, -99636.61, -108242.24,
> -101192.2, -60214.25, -208992.81, -49769.11, -93133.14, -160933.77,
> -197905.84, -194055.39, -101310.71, -185137.96, -204476.75, -149305.62
> ), BRANetRev = c(1439713.32, 1265962.79, 1491834.9, 1276180.74,
> 1702077.51, 1420186.1, 1469240.11, 1415855.34, 1592933.06, 1615926.39,
> 1668444.01, 1753406, 1356487.99, 1577808.22, 1906113.28, 1595299.45,
> 1671740.24, 1696643.33, 1490665.78, 1937361.24, 1480193.81, 1676066.85,
> 2004112.69, 1798906.55, 1619973.89, 1280088.4, 1877394.67, 2041241.6
> ), OONNew = c(3910730.05, 3555561.93, 4559655.25, 4547723.46,
> 4689306.99, 5394969.91, 4786362.98, 5668186.11, 5294251.33, 5576123.33,
> 5115861.78, 5627184.08, 5521404.85, 5473811.77, 6507273.34, 5545007.69,
> 6446159.89, 6267921.46, 6299399.33, 7647395.08, 6300382.23, 7160174.41,
> 7579884.41, 7504770.29, 8105827.46, 7572040.64, 7736328.29, 7495161.98
> ), OONAdjusted = c(-13913, -29385.31, -39633.37, -23487.13, -18202.86,
> -57335.49, -26061.45, -60880.07, -17589.45, -35970.08, -89133.94,
> -84694.58, -31724.89, -29847.95, -65421.74, -34334.22, -48511.98,
> -30298.97, -38729.46, -29292.89, -46098.4, -65909.49, -85879.23,
> -71845.28, -69017.07, -93161.03, -70847.29, -85106.04), OONCancelled =
> c(-357694.19,
> -444792.75, -361349.57, -386717.55, -547422.05, -518259.22, -417613.76,
> -578631.46, -804516.81, -572875.52, -510487.53, -666294.87, -673233.37,
> -556564.45, -963346.75, -639288.2, -910104.23, -773428.8, -1008078.84,
> -546685.3, -729932.94, -987098.23, -964001.63, -986995.93, -680066.58,
> -728854.58, -730766.92, -753861.59), OONNetRev = c(3539122.86,
> 3081383.87, 4158672.31, 4137518.78, 4123682.08, 4819375.2, 4342687.77,
> 5028674.58, 4472145.07, 4967277.73, 4516240.31, 4876194.63, 4816446.59,
> 4887399.37, 5478504.85, 4871385.27, 5487543.68, 5464193.69, 5252591.03,
> 7071416.89, 5524350.89, 6107166.69, 6530003.55, 6445929.08, 7356743.81,
> 6750025.03, 6934714.08, 6656194.35)), .Names = c("Date", "Month",
> "TotalNetRev", "ClaimEditNew", "ClaimEditAdjusted", "ClaimEditCancelled",
> "ClaimEditNetRev", "BRANew", "BRAAdjusted", "BRACancelled", "BRANetRev",
> "OONNew", "OONAdjusted", "OONCancelled", "OONNetRev"), class =
> "data.frame", row.names = c(NA,
> -28L))
>
> Since I lack experience, I'd Just like to be sure what I have is what I
> read in?
>
> Thank you for any advice.
>
> WHP
>
> William H. Poling, Ph.D., MPH
>
>
> Confidentiality Notice This message is sent from Zelis. ...{{dropped:16}}
>
> ______________________________________________
> R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.R-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>
        [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help<https://stat.ethz.ch/mailman/listinfo/r-help>
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html<http://www.R-project.org/posting-guide.html>
and provide commented, minimal, self-contained, reproducible code.


Confidentiality Notice This message is sent from Zelis. This transmission may contain information which is privileged and confidential and is intended for the personal and confidential use of the named recipient only. Such information may be protected by applicable State and Federal laws from this disclosure or unauthorized use. If the reader of this message is not the intended recipient, or the employee or agent responsible for delivering the message to the intended recipient, you are hereby notified that any disclosure, review, discussion, copying, or taking any action in reliance on the contents of this transmission is strictly prohibited. If you have received this transmission in error, please contact the sender immediately. Zelis, 2018.

	[[alternative HTML version deleted]]



More information about the R-help mailing list