Write to CSV, column of string values

Hi Steve, and welcome to community.rstudio.com! To help you get the right help for your question, can you please turn it into a reprex (reproducible example)? This will ensure we're all looking at the same data and code. A guide for creating a reprex can be found here.

How is your data organized? What are you seeing (errors and/or output)?

Below I've created some dummy data to illustrate binding these into a dataframe and exporting to .csv.

library(tidyverse)

# Creating dummy data

Community_Name <- c("Mars", "Saturn", "Mercury", "Neptune")
Community_Code <- c(4, 6, 1, 8)

# Binding into a dataframe

community_df <- as.data.frame(cbind(Community_Name, Community_Code), stringsAsFactors = FALSE)

# Inspecting the structure of the dataframe

str(community_df)
#> 'data.frame':    4 obs. of  2 variables:
#>  $ Community_Name: chr  "Mars" "Saturn" "Mercury" "Neptune"
#>  $ Community_Code: chr  "4" "6" "1" "8"

# Exporting to .csv

community_out <- write_csv(community_df, "community_out.csv")

Created on 2018-10-06 by the reprex package (v0.2.0).

I hope this helps!

2 Likes