Is there a simple way to pull a few rows of a few variables from a large data set in R?

Rather than linking to a large data set of more that 50 variables and 700 rows, I would like to figure if there is an easier way than I found to create a few vectors from some variables from the data set.

Here is what I did.

library(tidyverse)
library("lubridate")
library("reprex")


turtle_activity_gtm <-  read_csv("https://www.dropbox.com/s/7ubvhajvkhx53kc/mpt_act_rep_cum_fc_cum_nest.csv?dl=1")
#Above file has cumulative false crawls and cumulative nests added along with proper date formats.

activity_date <- turtle_activity_gtm$activity_date

From the view of activity_date above I copied the first 20 rows, pasted them into Excel, formatted and copied the date column, special pasted (transpose) the date column. After copying this row, I pasted it into Notepad. In Notepad, I replaced all the spaces between dates with "," (That's quote comma quote). I had to put quotes at the beginning and end of the string. Also, the very first date was NA, I found I had to replace NA with "".

After all that I pasted to string with quotes and commas into the script and got activity_date as a date vector.

activity_date <- as.Date(c("","2022-04-19","2022-05-01","2022-05-01","2022-05-06","2022-05-06","2022-05-07","2022-05-07","2022-05-09","2022-05-09","2022-05-10","2022-05-13","2022-05-14","2022-05-14","2022-05-14","2022-05-15","2022-05-15","2022-05-15","2022-05-15","2022-05-15"))

Now I want to get a couple of more 20-row variables from the data set. Now, I know can to this via the Excel -> Notepad route for these other ones. However, is there an easier way? I would just save these few vectors with a few rows for later use. I eventually want to post some challenges I have been having with ggplot and ggplotly.

Thanks,
Jeff

take a loot at the datapasta package

Thanks. I figured out how to use clipr::write_clip() to copy a variable first.

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

If you have a query related to it or one of the replies, start a new topic and refer back with a link.