How do i get rid of the NAs to get the actual values

library(tidyverse)
library(ggplot2)
library(dplyr)
library(RColorBrewer)
library(cronR)
library(miniUI)
library(shiny)
library(shinyFiles)
library(pdftools)
library(tm)
library(xlsx)
library(readtext)
library(stringr)
library(plyr)
library(lubridate)
library(openxlsx)
library(rio)
library(data.table)
RAO <- read.csv(file = "RateAddOnsExcel.csv", header = TRUE, sep = ",", na.strings = c("", "NA"))
names(RAO)[1] = c("ProviderName")
names(RAO)[6:17] = c("AIMNumber", "ChainName", "RateEffectiveDate", "ComponentTotal",
"VentAddOn", "QualityAddOn", "SpecialCareUnitAddOn", "AssessmentAddOn",
"SelectedExpenditureAddOn", "RateReduction", "CaseMixRate", "CaseMixAssessment")
RAO$X10.01.18 <- NULL
RAO$...4 <- NULL
RAO$...5 <- NULL
RAO$Quarter. <- NULL
View(RAO)

reprex::reprex()

1 Like

Could you please elaborate in your question and ideally provide a REPRoducible EXample (reprex)?, We don't know what are you referring to since we don't have access to your file and we can't see where the NAs are.

library(tidyverse)
library(ggplot2)
library(dplyr)
library(RColorBrewer)
library(cronR)
library(miniUI)
library(shiny)
library(shinyFiles)
library(pdftools)
library(tm)
#> Loading required package: NLP
#> 
#> Attaching package: 'NLP'
#> The following object is masked from 'package:ggplot2':
#> 
#>     annotate
library(xlsx)
#> Warning in system("/usr/libexec/java_home", intern = TRUE): running command
#> '/usr/libexec/java_home' had status 1
#> Error: package or namespace load failed for 'xlsx':
#>  .onLoad failed in loadNamespace() for 'rJava', details:
#>   call: dyn.load(file, DLLpath = DLLpath, ...)
#>   error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so':
#>   dlopen(/Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so, 6): Library not loaded: /Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/lib/server/libjvm.dylib
#>   Referenced from: /Library/Frameworks/R.framework/Versions/3.5/Resources/library/rJava/libs/rJava.so
#>   Reason: image not found
library(readtext)
library(stringr)
library(plyr)
#> -------------------------------------------------------------------------
#> You have loaded plyr after dplyr - this is likely to cause problems.
#> If you need functions from both plyr and dplyr, please load plyr first, then dplyr:
#> library(plyr); library(dplyr)
#> -------------------------------------------------------------------------
#> 
#> Attaching package: 'plyr'
#> The following objects are masked from 'package:dplyr':
#> 
#>     arrange, count, desc, failwith, id, mutate, rename, summarise,
#>     summarize
#> The following object is masked from 'package:purrr':
#> 
#>     compact
library(lubridate)
#> 
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:plyr':
#> 
#>     here
#> The following object is masked from 'package:base':
#> 
#>     date
library(openxlsx)
library(rio)
library(data.table)
#> 
#> Attaching package: 'data.table'
#> The following objects are masked from 'package:lubridate':
#> 
#>     hour, isoweek, mday, minute, month, quarter, second, wday,
#>     week, yday, year
#> The following objects are masked from 'package:dplyr':
#> 
#>     between, first, last
#> The following object is masked from 'package:purrr':
#> 
#>     transpose
RAO <- read.csv(file = "RateAddOnsExcel.csv", header = TRUE, sep = ",", na.strings = c("", "NA"))
#> Warning in file(file, "rt"): cannot open file 'RateAddOnsExcel.csv': No
#> such file or directory
#> Error in file(file, "rt"): cannot open the connection
names(RAO)[1] = c("ProviderName")
#> Error in names(RAO)[1] = c("ProviderName"): object 'RAO' not found
names(RAO)[6:17] = c("AIMNumber", "ChainName", "RateEffectiveDate", "ComponentTotal", 
                     "VentAddOn", "QualityAddOn", "SpecialCareUnitAddOn", "AssessmentAddOn", 
                     "SelectedExpenditureAddOn", "RateReduction", "CaseMixRate", "CaseMixAssessment")
#> Error in names(RAO)[6:17] = c("AIMNumber", "ChainName", "RateEffectiveDate", : object 'RAO' not found
RAO$X10.01.18 <- NULL
#> Error in RAO$X10.01.18 <- NULL: object 'RAO' not found
RAO$...4 <- NULL
#> Error in RAO$...4 <- NULL: object 'RAO' not found
RAO$...5 <- NULL
#> Error in RAO$...5 <- NULL: object 'RAO' not found
RAO$Quarter. <- NULL
#> Error in RAO$Quarter. <- NULL: object 'RAO' not found
View(RAO)
#> Error in as.data.frame(x): object 'RAO' not found

reprex::reprex()
#> No input provided and clipboard is not available.
#> Rendering reprex...

Created on 2019-06-18 by the reprex package (v0.2.1)

Again, that is not reproducible since we don't have access to this file RateAddOnsExcel.csv, also please narrow down your code to just the problematic part and explain what you mean by " get rid of the NAs to get the actual values"

1 Like

Im sorry im struggling with making the reprex could i email you my code and file?

Sorry but I don't do email support, you can share your file here by providing a link to the file hosted in some cloud storage service like Dropbox or Google Drive.


heres the link to the file i turned into a csv

RAO <- read.csv(file = "RateAddOnsExcel.csv", header = TRUE, sep = ",", na.strings = c("", "NA"))
#> Warning in file(file, "rt"): cannot open file 'RateAddOnsExcel.csv': No
#> such file or directory
#> Error in file(file, "rt"): cannot open the connection
names(RAO)[1] = c("ProviderName")
#> Error in names(RAO)[1] = c("ProviderName"): object 'RAO' not found
names(RAO)[6:17] = c("AIMNumber", "ChainName", "RateEffectiveDate", "ComponentTotal", 
                     "VentAddOn", "QualityAddOn", "SpecialCareUnitAddOn", "AssessmentAddOn", 
                     "SelectedExpenditureAddOn", "RateReduction", "CaseMixRate", "CaseMixAssessment")
#> Error in names(RAO)[6:17] = c("AIMNumber", "ChainName", "RateEffectiveDate", : object 'RAO' not found

Created on 2019-06-19 by the reprex package (v0.2.1)
I believe i got the reprex right this time i also need to get rid of the headers and get the actual values of the NAs

A reprex has to be reproducible, I can't copy that code into my own R session and reproduce your problem because I don't have your csv file, that is why you get this error when you run the reprex() function.

#> Warning in file(file, "rt"): cannot open file 'RateAddOnsExcel.csv': No
#> such file or directory

Maybe this video would help you to understand what a reprex is about

CMI <- read.csv(file = "CMI.csv", header = TRUE, sep = ",", na.strings = c("", "NA"))
#> Warning in file(file, "rt"): cannot open file 'CMI.csv': No such file or
#> directory
#> Error in file(file, "rt"): cannot open the connection
View(CMI)
#> Error in as.data.frame(x): object 'CMI' not found
names(CMI)[1] = c("ProviderName")
#> Error in names(CMI)[1] = c("ProviderName"): object 'CMI' not found
names(CMI)[6:16] = c("AIMNumber", "ChainName", "RateEffectiveDate", "RateYearEnd", 
                       "Fac.Avg.CMI", "MedicaidCMI", "DirectCareComp", "IndirectCareComp", "AdminComp", 
                       "CapitalComp", "TherapyComp")
#> Error in names(CMI)[6:16] = c("AIMNumber", "ChainName", "RateEffectiveDate", : object 'CMI' not found

Created on 2019-06-20 by the reprex package (v0.2.1)

Same problem, we don't know what is inside CMI.csv

I dont understand why though the file is in my directory.

Can you confirm that you've watched the video @andresrcs posted above + and/or read the link he gave you in his first reply? I feel like you are trying to take a shortcut and missing the point of reprex and it makes it awkward for everyone involved.

In simple words - noone (except you) has access to the files on your computer. So if you want to someone else (not you) to help you, you'll need to find a way to put this data here. Take a look at, e.g., datapasta package. It should be helpful in this case. Also, take a look at couple of examples here of how people ask questions. Here is completely random example I quickly found - case_when() with heterogeneous date formats

Sorry guys for the problems with the reprex, but i figured out the problem!

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.