Replace missing values (NA) in one data set with values from another where...
I have a data frame (datadf) with 3 columns, 'x', 'y, and z. Several 'x' values are missing (NA). 'y' and 'z' are non measured variables.x y z 153 a 1 163 b 1 NA d 1 123 a 2 145 e 2 NA c 2 NA b 1 199 a...
View ArticleLook for an character pattern in a column, and if it returns a match, add the...
I have a table in R which I would like to query using grep and return any matches and the surrounding 100 or so characters to a new column. I have looked at other solutions from previous questions but...
View ArticleHow to make hyperlink in tooltip text reachable in ggplotly?
I would like to make a clickable hyperlink in a tooltip text in ggplotly. The hyperlink does seem to appear in the tooltip, but it can't be clicked. Before I can click, the tooltip dissappears. How can...
View ArticleGraph multiple geom_lines with varied timestamped data over multiple days
I have data collected over multiple days, with timestamps that contain information for when food was eaten. Example dataframes:head(Day3)...
View ArticleUsing name of dataframe as graph title in a function in R when dataframes are...
I want to run an analysis on a large number of subsets of an initial dataframe, each subsetted dataframe is named according to the subset they represent. I have made a list of dataframes (below called...
View Articleextract substring in R
Suppose I have list of string "S[+229]EC[+57]VDSTDNSSK[+229]PSSEPTSHVAR" and need to get a vector of string that contains only numbers with bracket like eg. [+229][+57].Is there a convenient way in R...
View ArticleHow to avoid memory leakage when using reactiveFileReader() in Shiny?
I've built R shiny app, where I quite extensively use reactiveFileReader() to read saved data from a file. I've noticed that after some time, the server becomes very slow. After some research, I've...
View ArticleBookdown generated links in linux version of RStudio preview interpreted as...
When I build any bookdown document, including the Bookdown demo into gitbook or epub, all the links in RStudio preview are interpreted a relative. Only pdf version works correctly because it opens in...
View ArticleReshaping Data Frame (Spread and Make XTS)
I am trying to reshape a data frame from a long vector to a table with the date being first column (ideally its the index as I want to make this an xts format ultimately) and the place_id's being new...
View ArticleHow can i estimate the median in R using the median fuction?
i am trying to calculate some statistical moments, using the moments function, for a group of variables. In order to do this i try to program a functionWhen I try to use my function with my dataframe...
View ArticleRemove rows between two specific rows
I have a small issue regarding removing specific rows. In this example, I would like to remove the rows from the word "5055" in the column "power" until the word "Exer" in the column "fr". Importantly,...
View ArticleHow to import and create time series data frames in an efficient way?
I have many separate data files in csv format for a lot of daily stock prices. Over a few years there are hundreds of those data files, whose names are the dates of data record. In each file there are...
View ArticleConvert list of symbols to character string in own function
I have the following data frame:dat <- data.frame(time = runif(20), group1 = rep(1:2, times = 10), group2 = rep(1:2, each = 10), group3 = rep(3:4, each = 10)) I'm now writing a function my_function...
View ArticleAdding extra column in data frame
How can I add one extra column in the beginning of my dataframe and name is as # and fill that columns with series equivalent to my dataframe?# 1 2 3
View ArticleHow to add a second smooth line in a second y-axis and scale it with regard...
I have a dataframe df that summarizes the activity Activity of a fish species and the current's intensity C.I and current's direction C.D associated to this activity in the water column. As an example...
View ArticleSubset DF by Unique Data Values for Factors in R
I am trying to filter a dataframe in which I have three columns, the 1st one is the date in format: "day/month/year", the 2nd one is the client name, and the 3rd one is the client spending on an...
View ArticlePython's equivalent functions to fromJSON(), unlist(), attr() of R?
I wrote a code in R but it can't take my heavy files, so I switched to Python. But I've been looking for 3 Python's equivalent functions of R and haven't found any satisfying results.The 3 R functions...
View ArticleCheck where is function being called within R project?
I got a really large R project with multiple scripts calling from all of those. Is there a way to get all the instances of a function within the whole project in RStudio?
View ArticleWhy does col_search sometimes work and sometimes not, in funtion or not
I have a list of species (about 2000) that I want to verify : synonyms, spelling, recent names etc.Here is a subset :data <- c("Abalistes stellatus", "Abudefduf abdominalis", "Abudefduf...
View ArticleRound to machine tolerance
I'd like to take a set of predictions and round them to machine tolerance, then calculate a hash from those numbers. The goal is to determine whether a complicated R process which generates those...
View Article