Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 205449

Tidy dataframes with special characters

$
0
0

My dataset in csv format (available here) is as follows: enter image description here

I tried to import the data into R with the following document:

library(tidyverse)
data <- read_csv("<Path to file>\\Sample.csv")

When I tried to extract column with data$, I get the error:

Error in gsub(reStrip, "", completions, perl = TRUE) : 
  input string 4 is invalid UTF-8

Column D of my data contains both numbers and special characters * and the Pilcrow symbol. The number in the last last row for this column is 66.1 but is followed by #. Similarly, column I contains * and the Pilcrow symbol.

I want to clean the data so that for Column D and I, rows with * and the Pilcrow symbol are replaced with NA. In addition, "66.1 #" is converted to "66.1".

My desired table is as below: enter image description here

I would like to know how I could import the csv file into R and clean it to the desired format in R. Preferable with tidyverse.


Viewing all articles
Browse latest Browse all 205449

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>